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