Browse Source

Further work on DD layer.

Former-commit-id: 061b428763
tempestpy_adaptions
dehnert 11 years ago
parent
commit
ac355a66eb
  1. 45
      src/storage/dd/CuddDd.cpp
  2. 29
      src/storage/dd/CuddDd.h

45
src/storage/dd/CuddDd.cpp

@ -188,6 +188,33 @@ namespace storm {
this->getCuddAdd().Maximum(cubeDd.getCuddAdd()); this->getCuddAdd().Maximum(cubeDd.getCuddAdd());
} }
void Dd<CUDD>::swapVariables(std::vector<std::pair<std::string, std::string>> const& metaVariablePairs) {
std::vector<ADD> from;
std::vector<ADD> to;
for (auto const& metaVariablePair : metaVariablePairs) {
DdMetaVariable<CUDD> const& variable1 = this->getDdManager()->getMetaVariable(metaVariablePair.first);
DdMetaVariable<CUDD> const& variable2 = this->getDdManager()->getMetaVariable(metaVariablePair.second);
// Check if it's legal so swap the meta variables.
if (variable1.getNumberOfDdVariables() != variable2.getNumberOfDdVariables()) {
throw storm::exceptions::InvalidArgumentException() << "Unable to swap meta variables with different size.";
}
// Keep track of the contained meta variables in the DD.
bool containsVariable1 = this->containsMetaVariable(metaVariablePair.first);
bool containsVariable2 = this->containsMetaVariable(metaVariablePair.second);
if (containsVariable1 && !containsVariable2) {
this->removeContainedMetaVariable(metaVariablePair.first);
this->addContainedMetaVariable(metaVariablePair.second);
} else if (!containsVariable1 && containsVariable2) {
this->removeContainedMetaVariable(metaVariablePair.second);
this->addContainedMetaVariable(metaVariablePair.first);
}
}
// FIXME: complete this and add matrix-matrix multiplication.
}
uint_fast64_t Dd<CUDD>::getNonZeroCount() const { uint_fast64_t Dd<CUDD>::getNonZeroCount() const {
std::size_t numberOfDdVariables = 0; std::size_t numberOfDdVariables = 0;
for (auto const& metaVariableName : this->containedMetaVariableNames) { for (auto const& metaVariableName : this->containedMetaVariableNames) {
@ -200,16 +227,18 @@ namespace storm {
return static_cast<uint_fast64_t>(this->cuddAdd.CountLeaves()); return static_cast<uint_fast64_t>(this->cuddAdd.CountLeaves());
} }
uint_fast64_t Dd<CUDD>::getNodeCount() const {
return static_cast<uint_fast64_t>(this->cuddAdd.nodeCount());
}
double Dd<CUDD>::getMin() const { double Dd<CUDD>::getMin() const {
ADD constantMinAdd = this->getCuddAdd().FindMin(); ADD constantMinAdd = this->getCuddAdd().FindMin();
// FIXME
return 0;
return static_cast<double>(Cudd_V(constantMinAdd));
} }
double Dd<CUDD>::getMax() const { double Dd<CUDD>::getMax() const {
ADD constantMaxAdd = this->getCuddAdd().FindMax(); ADD constantMaxAdd = this->getCuddAdd().FindMax();
// FIXME
return 0;
return static_cast<double>(Cudd_V(constantMaxAdd));
} }
void Dd<CUDD>::setValue(std::string const& metaVariableName, int_fast64_t variableValue, double targetValue) { void Dd<CUDD>::setValue(std::string const& metaVariableName, int_fast64_t variableValue, double targetValue) {
@ -280,6 +309,14 @@ namespace storm {
return this->cuddAdd; return this->cuddAdd;
} }
void Dd<CUDD>::addContainedMetaVariable(std::string const& metaVariableName) {
this->getContainedMetaVariableNames().insert(metaVariableName);
}
void Dd<CUDD>::removeContainedMetaVariable(std::string const& metaVariableName) {
this->getContainedMetaVariableNames().erase(metaVariableName);
}
std::shared_ptr<DdManager<CUDD>> Dd<CUDD>::getDdManager() const { std::shared_ptr<DdManager<CUDD>> Dd<CUDD>::getDdManager() const {
return this->ddManager; return this->ddManager;
} }

29
src/storage/dd/CuddDd.h

@ -202,6 +202,14 @@ namespace storm {
*/ */
void maxAbstract(std::unordered_set<std::string> const& metaVariableNames); void maxAbstract(std::unordered_set<std::string> const& metaVariableNames);
/*!
* Swaps the given pairs of meta variables in the DD. The pairs of meta variables must be guaranteed to have
* the same number of underlying DD variables.
*
* @param metaVariablePairs A vector of meta variable pairs that are to be swapped for one another.
*/
void swapVariables(std::vector<std::pair<std::string, std::string>> const& metaVariablePairs);
/*! /*!
* Retrieves the number of encodings that are mapped to a non-zero value. * Retrieves the number of encodings that are mapped to a non-zero value.
* *
@ -216,6 +224,13 @@ namespace storm {
*/ */
uint_fast64_t getLeafCount() const; uint_fast64_t getLeafCount() const;
/*!
* Retrieves the number of nodes necessary to represent the DD.
*
* @return The number of nodes in this DD.
*/
uint_fast64_t getNodeCount() const;
/*! /*!
* Retrieves the lowest function value of any encoding. * Retrieves the lowest function value of any encoding.
* *
@ -340,6 +355,20 @@ namespace storm {
*/ */
ADD const& getCuddAdd() const; ADD const& getCuddAdd() const;
/*!
* Adds the given meta variable name to the set of meta variables that are contained in this DD.
*
* @param metaVariableName The name of the meta variable to add.
*/
void addContainedMetaVariable(std::string const& metaVariableName);
/*!
* Removes the given meta variable name to the set of meta variables that are contained in this DD.
*
* @param metaVariableName The name of the meta variable to remove.
*/
void removeContainedMetaVariable(std::string const& metaVariableName);
/*! /*!
* Creates a DD that encapsulates the given CUDD ADD. * Creates a DD that encapsulates the given CUDD ADD.
* *

Loading…
Cancel
Save