3#include <boost/optional.hpp>
6#include <unordered_map>
21template<DdType LibraryType>
22class DdManager :
public std::enable_shared_from_this<DdManager<LibraryType>> {
24 friend class Bdd<LibraryType>;
26 template<DdType LibraryTypePrime,
typename ValueType>
29 template<DdType LibraryTypePrime,
typename ValueType>
58 template<
typename ValueType>
73 template<
typename ValueType>
81 template<
typename ValueType>
89 template<
typename ValueType>
97 template<
typename ValueType>
129 template<
typename ValueType>
138 Bdd<LibraryType> getIdentity(std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>>
const& variablePairs,
139 bool restrictToFirstRange =
true)
const;
174 boost::optional<uint64_t>
const& numberOfLayers = boost::none);
183 std::pair<storm::expressions::Variable, storm::expressions::Variable>
addMetaVariable(
184 std::string
const& variableName, int_fast64_t low, int_fast64_t high,
185 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>>
const& position = boost::none);
194 std::string
const& variableName, int_fast64_t low, int_fast64_t high, uint64_t numberOfLayers,
195 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>>
const& position = boost::none);
204 std::string
const& variableName, uint64_t bits, uint64_t numberOfLayers,
205 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>>
const& position = boost::none);
212 std::pair<storm::expressions::Variable, storm::expressions::Variable>
addMetaVariable(
213 std::string
const& variableName, boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>>
const& position = boost::none);
222 std::string
const& variableName, uint64_t numberOfLayers,
223 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>>
const& position = boost::none);
310 std::vector<uint_fast64_t>
getSortedVariableIndices(std::set<storm::expressions::Variable>
const& metaVariables)
const;
339 void execute(std::function<
void()>
const& f)
const;
349 std::vector<storm::expressions::Variable> addMetaVariableHelper(
350 MetaVariableType const& type, std::string
const& name, uint64_t numberOfDdVariables, uint64_t numberOfLayers,
351 boost::optional<std::pair<MetaVariablePosition, storm::expressions::Variable>>
const& position = boost::none,
352 boost::optional<std::pair<int_fast64_t, int_fast64_t>>
const& bounds = boost::none);
359 std::vector<std::string> getDdVariableNames()
const;
366 std::vector<storm::expressions::Variable> getDdVariables()
const;
403 std::unordered_map<storm::expressions::Variable, DdMetaVariable<LibraryType>> metaVariableMap;
406 std::shared_ptr<storm::expressions::ExpressionManager> manager;
storm::expressions::Variable getMetaVariable(std::string const &variableName) const
Retrieves the given meta variable by name.
Add< LibraryType, ValueType > getAddOne() const
Retrieves an ADD representing the constant one function.
bool hasMetaVariable(std::string const &variableName) const
Retrieves whether the given meta variable name is already in use.
std::shared_ptr< DdManager< LibraryType > > asSharedPointer()
Add< LibraryType, ValueType > getAddZero() const
Retrieves an ADD representing the constant zero function.
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...
std::set< storm::expressions::Variable > getAllMetaVariables() const
Retrieves the set of meta variables contained in the DD.
InternalDdManager< LibraryType > & getInternalDdManager()
Retrieves the internal DD manager.
Bdd< LibraryType > getCube(storm::expressions::Variable const &variable) const
Retrieves a BDD that is the cube of the variables representing the given meta variable.
Add< LibraryType, ValueType > getInfinity() const
Retrieves an ADD representing the constant infinity function.
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.
DdManager(DdManager< LibraryType > &&other)=default
DdManager()
Creates an empty manager without any meta variables.
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.
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...
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...
Add< LibraryType, ValueType > getAddUndefined() const
Retrieves an ADD representing an undefined value.
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
Add< LibraryType, ValueType > getConstant(ValueType const &value) const
Retrieves an ADD representing the constant function with the given value.
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 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...