Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Dd.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4
8
9namespace storm {
10namespace dd {
11template<DdType LibraryType>
12Dd<LibraryType>::Dd(DdManager<LibraryType> const& ddManager, std::set<storm::expressions::Variable> const& containedMetaVariables)
13 : ddManager(const_cast<DdManager<LibraryType>*>(&ddManager)), containedMetaVariables(containedMetaVariables) {
14 // Intentionally left empty.
15}
16
17template<DdType LibraryType>
19 return containedMetaVariables.contains(metaVariable);
20}
21
22template<DdType LibraryType>
23bool Dd<LibraryType>::containsMetaVariables(std::set<storm::expressions::Variable> const& metaVariables) const {
24 return std::includes(containedMetaVariables.begin(), containedMetaVariables.end(), metaVariables.begin(), metaVariables.end());
25}
26
27template<DdType LibraryType>
28std::set<storm::expressions::Variable> const& Dd<LibraryType>::getContainedMetaVariables() const {
29 return this->containedMetaVariables;
30}
31
32template<DdType LibraryType>
33std::set<storm::expressions::Variable>& Dd<LibraryType>::getContainedMetaVariables() {
34 return this->containedMetaVariables;
35}
36
37template<DdType LibraryType>
39 return *this->ddManager;
40}
41
42template<DdType LibraryType>
43void Dd<LibraryType>::addMetaVariables(std::set<storm::expressions::Variable> const& metaVariables) {
44 std::set<storm::expressions::Variable> result;
45 std::set_union(containedMetaVariables.begin(), containedMetaVariables.end(), metaVariables.begin(), metaVariables.end(),
46 std::inserter(result, result.begin()));
47 containedMetaVariables = std::move(result);
48}
49
50template<DdType LibraryType>
52 this->getContainedMetaVariables().insert(metaVariable);
53}
54
55template<DdType LibraryType>
57 this->getContainedMetaVariables().erase(metaVariable);
58}
59
60template<DdType LibraryType>
61void Dd<LibraryType>::removeMetaVariables(std::set<storm::expressions::Variable> const& metaVariables) {
62 std::set<storm::expressions::Variable> result;
63 std::set_difference(containedMetaVariables.begin(), containedMetaVariables.end(), metaVariables.begin(), metaVariables.end(),
64 std::inserter(result, result.begin()));
65 containedMetaVariables = std::move(result);
66}
67
68template<DdType LibraryType>
69std::vector<uint_fast64_t> Dd<LibraryType>::getSortedVariableIndices() const {
70 return this->getDdManager().getSortedVariableIndices(this->getContainedMetaVariables());
71}
72
73template<DdType LibraryType>
74std::set<storm::expressions::Variable> Dd<LibraryType>::joinMetaVariables(storm::dd::Dd<LibraryType> const& first, storm::dd::Dd<LibraryType> const& second) {
75 std::set<storm::expressions::Variable> metaVariables;
76 std::set_union(first.getContainedMetaVariables().begin(), first.getContainedMetaVariables().end(), second.getContainedMetaVariables().begin(),
77 second.getContainedMetaVariables().end(), std::inserter(metaVariables, metaVariables.begin()));
78 return metaVariables;
79}
80
81template<DdType LibraryType>
82std::set<storm::expressions::Variable> Dd<LibraryType>::subtractMetaVariables(storm::dd::Dd<LibraryType> const& first,
83 storm::dd::Dd<LibraryType> const& second) {
84 bool includesAllMetaVariables = std::includes(first.getContainedMetaVariables().begin(), first.getContainedMetaVariables().end(),
85 second.getContainedMetaVariables().begin(), second.getContainedMetaVariables().end());
86 STORM_LOG_THROW(includesAllMetaVariables, storm::exceptions::InvalidArgumentException, "Cannot subtract meta variables that are not contained in the DD.");
87 std::set<storm::expressions::Variable> metaVariables;
88 std::set_difference(first.getContainedMetaVariables().begin(), first.getContainedMetaVariables().end(), second.getContainedMetaVariables().begin(),
89 second.getContainedMetaVariables().end(), std::inserter(metaVariables, metaVariables.begin()));
90 return metaVariables;
91}
92
93template class Dd<storm::dd::DdType::CUDD>;
95} // namespace dd
96} // namespace storm
void addMetaVariable(storm::expressions::Variable const &metaVariable)
Adds the given meta variable to the set of meta variables that are contained in this DD.
Definition Dd.cpp:51
Dd()=default
static std::set< storm::expressions::Variable > joinMetaVariables(storm::dd::Dd< LibraryType > const &first, storm::dd::Dd< LibraryType > const &second)
Retrieves the set of meta variables contained in both DDs.
Definition Dd.cpp:74
void addMetaVariables(std::set< storm::expressions::Variable > const &metaVariables)
Adds the given set of meta variables to the DD.
Definition Dd.cpp:43
void removeMetaVariables(std::set< storm::expressions::Variable > const &metaVariables)
Removes the given set of meta variables from the DD.
Definition Dd.cpp:61
bool containsMetaVariable(storm::expressions::Variable const &metaVariable) const
Retrieves whether the given meta variable is contained in the DD.
Definition Dd.cpp:18
void removeMetaVariable(storm::expressions::Variable const &metaVariable)
Removes the given meta variable to the set of meta variables that are contained in this DD.
Definition Dd.cpp:56
std::vector< uint_fast64_t > getSortedVariableIndices() const
Retrieves the (sorted) list of the variable indices of DD variables contained in this DD.
Definition Dd.cpp:69
static std::set< storm::expressions::Variable > subtractMetaVariables(storm::dd::Dd< LibraryType > const &first, storm::dd::Dd< LibraryType > const &second)
Retrieves the set of meta variables that are contained in the first but not the second DD.
Definition Dd.cpp:82
std::set< storm::expressions::Variable > const & getContainedMetaVariables() const
Retrieves the set of all meta variables contained in the DD.
Definition Dd.cpp:28
DdManager< LibraryType > & getDdManager() const
Retrieves the manager that is responsible for this DD.
Definition Dd.cpp:38
bool containsMetaVariables(std::set< storm::expressions::Variable > const &metaVariables) const
Retrieves whether the given meta variables are all contained in the DD.
Definition Dd.cpp:23
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30