1#ifndef STORM_STORAGE_DD_ADD_H_
2#define STORM_STORAGE_DD_ADD_H_
17#include "storm-config.h"
21template<DdType LibraryType>
24template<DdType LibraryType,
typename ValueType>
27namespace bisimulation {
28template<DdType LibraryType,
typename ValueType>
32template<DdType LibraryType,
typename ValueType =
double>
33class Add :
public Dd<LibraryType> {
36 friend class Bdd<LibraryType>;
38 template<DdType LibraryTypePrime,
typename ValueTypePrime>
60 std::set<storm::expressions::Variable>
const& metaVariables);
268 template<
typename TargetValueType>
270 template<
typename TargetValueType>
346 std::set<storm::expressions::Variable>
const& to)
const;
356 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>>
const& metaVariablePairs)
const;
366 std::vector<std::pair<storm::expressions::Variable, storm::expressions::Variable>>
const& metaVariablePairs)
const;
378 std::set<storm::expressions::Variable>
const& summationMetaVariables)
const;
523 int_fast64_t variableValue2, ValueType
const& targetValue);
533 void setValue(std::map<storm::expressions::Variable, int_fast64_t>
const& metaVariableToValueMap = std::map<storm::expressions::Variable, int_fast64_t>(),
534 ValueType
const& targetValue = 0);
544 std::map<storm::expressions::Variable, int_fast64_t>
const& metaVariableToValueMap = std::map<storm::expressions::Variable, int_fast64_t>())
const;
567 virtual uint_fast64_t
getIndex()
const override;
569 virtual uint_fast64_t
getLevel()
const override;
576 std::vector<ValueType>
toVector()
const;
606 std::set<storm::expressions::Variable>
const& rowMetaVariables,
607 std::set<storm::expressions::Variable>
const& columnMetaVariables,
608 std::set<storm::expressions::Variable>
const& groupMetaVariables,
storm::dd::Odd const& rowOdd)
const;
640 std::set<storm::expressions::Variable>
const& columnMetaVariables,
storm::dd::Odd const& rowOdd,
689 std::set<storm::expressions::Variable>
const& rowMetaVariables, std::set<storm::expressions::Variable>
const& columnMetaVariables,
691 std::vector<std::set<storm::expressions::Variable>>
const& labelMetaVariables = std::vector<std::set<storm::expressions::Variable>>())
const;
707 std::set<storm::expressions::Variable>
const& groupMetaVariables,
710 std::pair<storm::storage::SparseMatrix<ValueType>, std::vector<ValueType>>
toMatrixVector(
712 std::set<storm::expressions::Variable>
const& rowMetaVariables, std::set<storm::expressions::Variable>
const& columnMetaVariables,
728 std::pair<storm::storage::SparseMatrix<ValueType>, std::vector<std::vector<ValueType>>>
toMatrixVectors(
731 std::pair<storm::storage::SparseMatrix<ValueType>, std::vector<std::vector<ValueType>>>
toMatrixVectors(
733 std::set<storm::expressions::Variable>
const& rowMetaVariables, std::set<storm::expressions::Variable>
const& columnMetaVariables,
741 void exportToDot(std::string
const& filename,
bool showVariablesIfPossible =
true)
const override;
743 virtual void exportToText(std::string
const& filename)
const override;
761 template<DdType LibraryTypePrime,
typename ValueTypePrime>
798 std::set<storm::expressions::Variable>
const& containedMetaVariables = std::set<storm::expressions::Variable>());
821 std::set<storm::expressions::Variable>
const& rowMetaVariables,
822 std::set<storm::expressions::Variable>
const& columnMetaVariables,
823 std::set<storm::expressions::Variable>
const& groupMetaVariables,
Add< LibraryType, ValueType > restrict(Add< LibraryType, ValueType > const &constraint) const
Computes the restriction of the current ADD with the given constraint.
Add< LibraryType, ValueType > swapVariables(std::vector< std::pair< storm::expressions::Variable, storm::expressions::Variable > > const &metaVariablePairs) const
Swaps the given pairs of meta variables in the ADD.
MatrixAndLabeling toLabeledMatrix(std::set< storm::expressions::Variable > const &rowMetaVariables, std::set< storm::expressions::Variable > const &columnMetaVariables, std::set< storm::expressions::Variable > const &groupMetaVariables, storm::dd::Odd const &rowOdd, storm::dd::Odd const &columnOdd, std::vector< std::set< storm::expressions::Variable > > const &labelMetaVariables=std::vector< std::set< storm::expressions::Variable > >()) const
Add< LibraryType, ValueType > pow(Add< LibraryType, ValueType > const &other) const
Retrieves the function that represents the current ADD to the power of the given ADD.
Bdd< LibraryType > equals(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one that have identical function values.
bool isOne() const
Retrieves whether this ADD represents the constant one function.
Add< LibraryType, ValueType > operator+(Add< LibraryType, ValueType > const &other) const
Adds the two ADDs.
Add< LibraryType, ValueType > operator*(Add< LibraryType, ValueType > const &other) const
Multiplies the two ADDs.
ValueType getMax() const
Retrieves the highest function value of any encoding.
void exportToDot(std::string const &filename, bool showVariablesIfPossible=true) const override
Exports the DD to the given file in the dot format.
InternalAdd< LibraryType, ValueType > const & getInternalAdd() const
Retrieves the internal ADD.
friend std::ostream & operator<<(std::ostream &out, Add< LibraryTypePrime, ValueTypePrime > const &add)
Add< LibraryType, ValueType > floor() const
Retrieves the function that floors all values in the current ADD.
Add & operator=(Add< LibraryType, ValueType > &&other)=default
Add(Add< LibraryType, ValueType > &&other)=default
Bdd< LibraryType > lessOrEqual(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are les...
std::pair< storm::storage::SparseMatrix< ValueType >, std::vector< std::vector< ValueType > > > toMatrixVectors(std::vector< storm::dd::Add< LibraryType, ValueType > > const &vectors, std::set< storm::expressions::Variable > const &groupMetaVariables, storm::dd::Odd const &rowOdd, storm::dd::Odd const &columnOdd) const
Converts the ADD to a row-grouped (sparse) matrix and the given vectors to row-grouped vectors.
virtual uint_fast64_t getLevel() const override
Retrieves the level of the topmost variable in the DD.
Add< LibraryType, ValueType > operator-() const
Subtracts the ADD from the constant zero function.
bool operator==(Add< LibraryType, ValueType > const &other) const
Retrieves whether the two DDs represent the same function.
Add< LibraryType, ValueType > logxy(Add< LibraryType, ValueType > const &other) const
Retrieves the function that represents the logarithm of the current ADD to the bases given by the sec...
Add< LibraryType, ValueType > minimum(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to the minimum of the function values of the two ADD...
Add< LibraryType, ValueType > & operator+=(Add< LibraryType, ValueType > const &other)
Adds the given ADD to the current one.
Add(Add< LibraryType, ValueType > const &other)=default
Add< LibraryType, storm::RationalNumber > sharpenKwekMehlhorn(uint64_t precision) const
Retrieves the function that sharpens all values in the current ADD with the Kwek-Mehlhorn algorithm.
std::enable_if< std::is_same< TargetValueType, ValueType >::value, Add< LibraryType, TargetValueType > >::type toValueType() const
Replaces the leaves in this MTBDD, converting them to double if possible, and -1.0 else.
storm::storage::SparseMatrix< ValueType > toMatrix() const
Converts the ADD to a (sparse) matrix.
Add & operator=(Add< LibraryType, ValueType > const &other)=default
ValueType getMin() const
Retrieves the lowest function value of any encoding.
Bdd< LibraryType > greater(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are gre...
Add< LibraryType, ValueType > maximum(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to the maximum of the function values of the two ADD...
ValueType getValue(std::map< storm::expressions::Variable, int_fast64_t > const &metaVariableToValueMap=std::map< storm::expressions::Variable, int_fast64_t >()) const
Retrieves the value of the function when all meta variables are assigned the values of the given mapp...
Add< LibraryType, ValueType > renameVariables(std::set< storm::expressions::Variable > const &from, std::set< storm::expressions::Variable > const &to) const
Renames the given meta variables in the ADD.
Add< LibraryType, ValueType > maxAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Max-abstracts from the given meta variables.
std::pair< storm::storage::SparseMatrix< ValueType >, std::vector< ValueType > > toMatrixVector(storm::dd::Add< LibraryType, ValueType > const &vector, std::set< storm::expressions::Variable > const &groupMetaVariables, storm::dd::Odd const &rowOdd, storm::dd::Odd const &columnOdd) const
Converts the ADD to a row-grouped (sparse) matrix and the given vector to a row-grouped vector.
static Add< LibraryType, ValueType > fromVector(DdManager< LibraryType > const &ddManager, std::vector< ValueType > const &values, Odd const &odd, std::set< storm::expressions::Variable > const &metaVariables)
Builds an ADD representing the given vector.
AddIterator< LibraryType, ValueType > begin(bool enumerateDontCareMetaVariables=true) const
Retrieves an iterator that points to the first meta variable assignment with a non-zero function valu...
InternalDdManager< LibraryType > const & getInternalDdManager() const
Retrieves the internal ADD.
virtual uint_fast64_t getNonZeroCount() const override
Retrieves the number of encodings that are mapped to a non-zero value.
Add< LibraryType, ValueType > sumAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Sum-abstracts from the given meta variables.
virtual uint_fast64_t getNodeCount() const override
Retrieves the number of nodes necessary to represent the DD.
Bdd< LibraryType > getSupport() const override
Retrieves the support of the current ADD.
Bdd< LibraryType > minAbstractRepresentative(std::set< storm::expressions::Variable > const &metaVariables) const
Similar to minAbstract, but does not abstract from the variables but rather picks a valuation of each...
Bdd< LibraryType > greaterOrEqual(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are gre...
Add< LibraryType, ValueType > minAbstract(std::set< storm::expressions::Variable > const &metaVariables) const
Min-abstracts from the given meta variables.
Odd createOdd() const
Creates an ODD based on the current ADD.
AddIterator< LibraryType, ValueType > end() const
Retrieves an iterator that points past the end of the container.
virtual uint_fast64_t getIndex() const override
Retrieves the index of the topmost variable in the DD.
bool isZero() const
Retrieves whether this ADD represents the constant zero function.
Add< LibraryType, ValueType > multiplyMatrix(Add< LibraryType, ValueType > const &otherMatrix, std::set< storm::expressions::Variable > const &summationMetaVariables) const
Multiplies the current ADD (representing a matrix) with the given matrix by summing over the given me...
Add< LibraryType, ValueType > & operator-=(Add< LibraryType, ValueType > const &other)
Subtracts the given ADD from the current one and assigns the result to the current ADD.
Add< LibraryType, ValueType > mod(Add< LibraryType, ValueType > const &other) const
Retrieves the function that represents the current ADD modulo the given ADD.
Add< LibraryType, ValueType > & operator*=(Add< LibraryType, ValueType > const &other)
Multiplies the given ADD with the current one and assigns the result to the current ADD.
Add< LibraryType, ValueType > operator/(Add< LibraryType, ValueType > const &other) const
Divides the current ADD by the given one.
virtual uint_fast64_t getLeafCount() const override
Retrieves the number of leaves of the ADD.
bool isConstant() const
Retrieves whether this ADD represents a constant function.
Bdd< LibraryType > toBdd() const
Converts the ADD to a BDD by mapping all values unequal to zero to 1.
Add< LibraryType, ValueType > constrain(Add< LibraryType, ValueType > const &constraint) const
Computes the constraint of the current ADD with the given constraint.
bool equalModuloPrecision(Add< LibraryType, ValueType > const &other, ValueType const &precision, bool relative=true) const
Checks whether the current and the given ADD represent the same function modulo some given precision.
Bdd< LibraryType > notEquals(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one that have distinct function values.
virtual void exportToText(std::string const &filename) const override
Exports the DD to the given file in the dot format.
void setValue(storm::expressions::Variable const &metaVariable, int_fast64_t variableValue, ValueType const &targetValue)
Sets the function values of all encodings that have the given value of the meta variable to the given...
Bdd< LibraryType > notZero() const
Computes a BDD that represents the function in which all assignments with a function value unequal to...
Add< LibraryType, ValueType > ceil() const
Retrieves the function that ceils all values in the current ADD.
Add< LibraryType, ValueType > & operator/=(Add< LibraryType, ValueType > const &other)
Divides the current ADD by the given one and assigns the result to the current ADD.
Bdd< LibraryType > maxAbstractRepresentative(std::set< storm::expressions::Variable > const &metaVariables) const
Similar to maxAbstract, but does not abstract from the variables but rather picks a valuation of each...
bool operator!=(Add< LibraryType, ValueType > const &other) const
Retrieves whether the two DDs represent different functions.
std::vector< ValueType > toVector() const
Converts the ADD to a vector.
Add< LibraryType, ValueType > renameVariablesAbstract(std::set< storm::expressions::Variable > const &from, std::set< storm::expressions::Variable > const &to) const
Renames the given meta variables in the ADD.
Add< LibraryType, ValueType > permuteVariables(std::vector< std::pair< storm::expressions::Variable, storm::expressions::Variable > > const &metaVariablePairs) const
Permutes the given pairs of meta variables in the ADD.
Bdd< LibraryType > less(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are les...
A class that holds a possibly non-square matrix in the compressed row storage format.
Converts the ADD to a row-grouped (sparse) matrix.
MatrixAndLabeling(storm::storage::SparseMatrix< ValueType > &&matrix)
std::vector< std::vector< uint64_t > > labelings
MatrixAndLabeling(storm::storage::SparseMatrix< ValueType > const &matrix)
MatrixAndLabeling()=default
storm::storage::SparseMatrix< ValueType > matrix