Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DdManager.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_DD_DDMANAGER_H_
2#define STORM_STORAGE_DD_DDMANAGER_H_
3
4#include <boost/optional.hpp>
5#include <functional>
6#include <set>
7#include <unordered_map>
8
15
17
20
21namespace storm {
22namespace dd {
23// Declare DdManager class so we can then specialize it for the different DD types.
24template<DdType LibraryType>
25class DdManager : public std::enable_shared_from_this<DdManager<LibraryType>> {
26 public:
27 friend class Bdd<LibraryType>;
28
29 template<DdType LibraryTypePrime, typename ValueType>
30 friend class Add;
31
32 template<DdType LibraryTypePrime, typename ValueType>
33 friend class AddIterator;
34
38 DdManager();
39
40 // Explictly forbid copying a DdManager, but allow moving it.
41 DdManager(DdManager<LibraryType> const& other) = delete;
45
46 std::shared_ptr<DdManager<LibraryType>> asSharedPointer();
47 std::shared_ptr<DdManager<LibraryType> const> asSharedPointer() const;
48
55
61 template<typename ValueType>
63
70
76 template<typename ValueType>
78
84 template<typename ValueType>
86
92 template<typename ValueType>
94
100 template<typename ValueType>
101 Add<LibraryType, ValueType> getConstant(ValueType const& value) const;
102
114 Bdd<LibraryType> getEncoding(storm::expressions::Variable const& variable, int_fast64_t value, bool mostSignificantBitAtTop = true) const;
115
124
132 template<typename ValueType>
134
141 Bdd<LibraryType> getIdentity(std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>> const& variablePairs,
142 bool restrictToFirstRange = true) const;
143
151 Bdd<LibraryType> getIdentity(storm::expressions::Variable const& first, storm::expressions::Variable const& second, bool restrictToFirstRange = true) const;
152
160
167 Bdd<LibraryType> getCube(std::set<storm::expressions::Variable> const& variables) const;
168
176 std::vector<storm::expressions::Variable> cloneVariable(storm::expressions::Variable const& variable, std::string const& newVariableName,
177 boost::optional<uint64_t> const& numberOfLayers = boost::none);
178
186 std::pair<storm::expressions::Variable, storm::expressions::Variable> addMetaVariable(
187 std::string const& variableName, int_fast64_t low, int_fast64_t high,
188 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>> const& position = boost::none);
189
196 std::vector<storm::expressions::Variable> addMetaVariable(
197 std::string const& variableName, int_fast64_t low, int_fast64_t high, uint64_t numberOfLayers,
198 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>> const& position = boost::none);
199
206 std::vector<storm::expressions::Variable> addBitVectorMetaVariable(
207 std::string const& variableName, uint64_t bits, uint64_t numberOfLayers,
208 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>> const& position = boost::none);
209
215 std::pair<storm::expressions::Variable, storm::expressions::Variable> addMetaVariable(
216 std::string const& variableName, boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>> const& position = boost::none);
217
224 std::vector<storm::expressions::Variable> addMetaVariable(
225 std::string const& variableName, uint64_t numberOfLayers,
226 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>> const& position = boost::none);
227
233 std::set<std::string> getAllMetaVariableNames() const;
234
240 std::size_t getNumberOfMetaVariables() const;
241
248 bool hasMetaVariable(std::string const& variableName) const;
249
256 storm::expressions::Variable getMetaVariable(std::string const& variableName) const;
257
264 bool supportsOrderedInsertion() const;
265
271 void allowDynamicReordering(bool value);
272
278 bool isDynamicReorderingAllowed() const;
279
283 void triggerReordering();
284
292
298 std::set<storm::expressions::Variable> getAllMetaVariables() const;
299
307 std::vector<uint_fast64_t> getSortedVariableIndices() const;
308
316 std::vector<uint_fast64_t> getSortedVariableIndices(std::set<storm::expressions::Variable> const& metaVariables) const;
317
324
331
335 void debugCheck() const;
336
345 void execute(std::function<void()> const& f) const;
346
347 private:
355 std::vector<storm::expressions::Variable> addMetaVariableHelper(
356 MetaVariableType const& type, std::string const& name, uint64_t numberOfDdVariables, uint64_t numberOfLayers,
357 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>> const& position = boost::none,
358 boost::optional<std::pair<int_fast64_t, int_fast64_t>> const& bounds = boost::none);
359
365 std::vector<std::string> getDdVariableNames() const;
366
372 std::vector<storm::expressions::Variable> getDdVariables() const;
373
379 storm::expressions::ExpressionManager const& getExpressionManager() const;
380
386 storm::expressions::ExpressionManager& getExpressionManager();
387
393 InternalDdManager<LibraryType>* getInternalDdManagerPointer();
394
400 InternalDdManager<LibraryType> const* getInternalDdManagerPointer() const;
401
402 // ATTENTION: as the DD packages typically perform garbage collection, the order of members is crucial here:
403 // First, the references to the DDs of the meta variables need to be disposed of and *then* the manager.
404
405 // The DD manager that is customized according to the selected library type.
406 InternalDdManager<LibraryType> internalDdManager;
407
408 // A mapping from variables to the meta variable information.
409 std::unordered_map<storm::expressions::Variable, DdMetaVariable<LibraryType>> metaVariableMap;
410
411 // The manager responsible for the variables.
412 std::shared_ptr<storm::expressions::ExpressionManager> manager;
413};
414} // namespace dd
415} // namespace storm
416
417#endif /* STORM_STORAGE_DD_DDMANAGER_H_ */
storm::expressions::Variable getMetaVariable(std::string const &variableName) const
Retrieves the given meta variable by name.
Add< LibraryType, ValueType > getInfinity() const
Retrieves an ADD representing the constant infinity function.
Definition DdManager.cpp:65
bool hasMetaVariable(std::string const &variableName) const
Retrieves whether the given meta variable name is already in use.
std::shared_ptr< DdManager< LibraryType > > asSharedPointer()
Definition DdManager.cpp:26
std::vector< uint_fast64_t > getSortedVariableIndices() const
Retrieves the (sorted) list of the variable indices of the DD variables given by the meta variable se...
Add< LibraryType, ValueType > getAddZero() const
Retrieves an ADD representing the constant zero function.
Definition DdManager.cpp:53
std::set< storm::expressions::Variable > getAllMetaVariables() const
Retrieves the set of meta variables contained in the DD.
Add< LibraryType, ValueType > getAddUndefined() const
Retrieves an ADD representing an undefined value.
Definition DdManager.cpp:59
Add< LibraryType, ValueType > getAddOne() const
Retrieves an ADD representing the constant one function.
Definition DdManager.cpp:42
InternalDdManager< LibraryType > & getInternalDdManager()
Retrieves the internal DD manager.
Add< LibraryType, ValueType > getConstant(ValueType const &value) const
Retrieves an ADD representing the constant function with the given value.
Definition DdManager.cpp:71
Bdd< LibraryType > getCube(storm::expressions::Variable const &variable) const
Retrieves a BDD that is the cube of the variables representing the given meta variable.
void execute(std::function< void()> const &f) const
All code that manipulates DDs shall be called through this function.
Bdd< LibraryType > getBddOne() const
Retrieves a BDD representing the constant one function.
Definition DdManager.cpp:36
DdManager(DdManager< LibraryType > &&other)=default
DdManager()
Creates an empty manager without any meta variables.
Definition DdManager.cpp:21
std::set< std::string > getAllMetaVariableNames() const
Retrieves the names of all meta variables that have been added to the manager.
Bdd< LibraryType > getBddZero() const
Retrieves a BDD representing the constant zero function.
Definition DdManager.cpp:47
void triggerReordering()
Triggers a reordering of the DDs managed by this manager (if supported).
DdManager(DdManager< LibraryType > const &other)=delete
Bdd< LibraryType > getEncoding(storm::expressions::Variable const &variable, int_fast64_t value, bool mostSignificantBitAtTop=true) const
Retrieves the BDD representing the function that maps all inputs which have the given meta variable e...
Definition DdManager.cpp:76
bool isDynamicReorderingAllowed() const
Retrieves whether dynamic reordering is currently allowed (if supported).
std::vector< storm::expressions::Variable > cloneVariable(storm::expressions::Variable const &variable, std::string const &newVariableName, boost::optional< uint64_t > const &numberOfLayers=boost::none)
Clones the given meta variable and optionally changes the number of layers of the variable.
Add< LibraryType, ValueType > getIdentity(storm::expressions::Variable const &variable) const
Retrieves the ADD representing the identity of the meta variable, i.e., a function that maps all lega...
bool supportsOrderedInsertion() const
Checks whether this manager supports the ordered insertion of variables, i.e.
Bdd< LibraryType > getRange(storm::expressions::Variable const &variable) const
Retrieves the BDD representing the range of the meta variable, i.e., a function that maps all legal v...
std::pair< storm::expressions::Variable, storm::expressions::Variable > addMetaVariable(std::string const &variableName, int_fast64_t low, int_fast64_t high, boost::optional< std::pair< MetaVariablePosition, storm::expressions::Variable > > const &position=boost::none)
Adds an integer meta variable with the given range with two layers (a 'normal' and a 'primed' one).
DdManager< LibraryType > & operator=(DdManager< LibraryType > const &other)=delete
DdManager< LibraryType > & operator=(DdManager< LibraryType > &&other)=default
std::vector< storm::expressions::Variable > addBitVectorMetaVariable(std::string const &variableName, uint64_t bits, uint64_t numberOfLayers, boost::optional< std::pair< MetaVariablePosition, storm::expressions::Variable > > const &position=boost::none)
Creates a meta variable with the given number of layers.
void allowDynamicReordering(bool value)
Sets whether or not dynamic reordering is allowed for the DDs managed by this manager (if supported).
void debugCheck() const
Performs a debug check if available.
std::size_t getNumberOfMetaVariables() const
Retrieves the number of meta variables that are contained in this manager.
This class is responsible for managing a set of typed variables and all expressions using these varia...
LabParser.cpp.
Definition cli.cpp:18