Browse Source

removed conversion operator for Bdd

tempestpy_adaptions
dehnert 8 years ago
parent
commit
2441d9b8d7
  1. 30
      src/storm/storage/dd/Add.cpp
  2. 43
      src/storm/storage/dd/Bdd.cpp
  3. 5
      src/storm/storage/dd/Bdd.h

30
src/storm/storage/dd/Add.cpp

@ -154,31 +154,31 @@ namespace storm {
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::sumAbstract(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = Bdd<LibraryType>::getCube(this->getDdManager(), metaVariables);
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.sumAbstract(cube), Dd<LibraryType>::subtractMetaVariables(*this, cube));
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.sumAbstract(cube.getInternalBdd()), Dd<LibraryType>::subtractMetaVariables(*this, cube));
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::minAbstract(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = Bdd<LibraryType>::getCube(this->getDdManager(), metaVariables);
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.minAbstract(cube), Dd<LibraryType>::subtractMetaVariables(*this, cube));
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.minAbstract(cube.getInternalBdd()), Dd<LibraryType>::subtractMetaVariables(*this, cube));
}
template<DdType LibraryType, typename ValueType>
Bdd<LibraryType> Add<LibraryType, ValueType>::minAbstractRepresentative(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = Bdd<LibraryType>::getCube(this->getDdManager(), metaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalAdd.minAbstractRepresentative(cube), this->getContainedMetaVariables());
return Bdd<LibraryType>(this->getDdManager(), internalAdd.minAbstractRepresentative(cube.getInternalBdd()), this->getContainedMetaVariables());
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::maxAbstract(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = Bdd<LibraryType>::getCube(this->getDdManager(), metaVariables);
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.maxAbstract(cube), Dd<LibraryType>::subtractMetaVariables(*this, cube));
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.maxAbstract(cube.getInternalBdd()), Dd<LibraryType>::subtractMetaVariables(*this, cube));
}
template<DdType LibraryType, typename ValueType>
Bdd<LibraryType> Add<LibraryType, ValueType>::maxAbstractRepresentative(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = Bdd<LibraryType>::getCube(this->getDdManager(), metaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalAdd.maxAbstractRepresentative(cube), this->getContainedMetaVariables());
return Bdd<LibraryType>(this->getDdManager(), internalAdd.maxAbstractRepresentative(cube.getInternalBdd()), this->getContainedMetaVariables());
}
template<DdType LibraryType, typename ValueType>
@ -195,14 +195,14 @@ namespace storm {
STORM_LOG_THROW(this->containsMetaVariable(metaVariable), storm::exceptions::InvalidOperationException, "Cannot rename variable '" << metaVariable.getName() << "' that is not present.");
DdMetaVariable<LibraryType> const& ddMetaVariable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : ddMetaVariable.getDdVariables()) {
fromBdds.push_back(ddVariable);
fromBdds.push_back(ddVariable.getInternalBdd());
}
}
for (auto const& metaVariable : to) {
STORM_LOG_THROW(!this->containsMetaVariable(metaVariable), storm::exceptions::InvalidOperationException, "Cannot rename to variable '" << metaVariable.getName() << "' that is already present.");
DdMetaVariable<LibraryType> const& ddMetaVariable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : ddMetaVariable.getDdVariables()) {
toBdds.push_back(ddVariable);
toBdds.push_back(ddVariable.getInternalBdd());
}
}
@ -240,10 +240,10 @@ namespace storm {
}
}
for (auto const& ddVariable : variable1.getDdVariables()) {
from.push_back(ddVariable);
from.push_back(ddVariable.getInternalBdd());
}
for (auto const& ddVariable : variable2.getDdVariables()) {
to.push_back(ddVariable);
to.push_back(ddVariable.getInternalBdd());
}
}
@ -272,10 +272,10 @@ namespace storm {
}
for (auto const& ddVariable : variable1.getDdVariables()) {
from.push_back(ddVariable);
from.push_back(ddVariable.getInternalBdd());
}
for (auto const& ddVariable : variable2.getDdVariables()) {
to.push_back(ddVariable);
to.push_back(ddVariable.getInternalBdd());
}
}
@ -293,7 +293,7 @@ namespace storm {
std::vector<InternalBdd<LibraryType>> summationDdVariables;
for (auto const& metaVariable : summationMetaVariables) {
for (auto const& ddVariable : this->getDdManager().getMetaVariable(metaVariable).getDdVariables()) {
summationDdVariables.push_back(ddVariable);
summationDdVariables.push_back(ddVariable.getInternalBdd());
}
}
@ -310,7 +310,7 @@ namespace storm {
std::vector<InternalBdd<LibraryType>> summationDdVariables;
for (auto const& metaVariable : summationMetaVariables) {
for (auto const& ddVariable : this->getDdManager().getMetaVariable(metaVariable).getDdVariables()) {
summationDdVariables.push_back(ddVariable);
summationDdVariables.push_back(ddVariable.getInternalBdd());
}
}
@ -318,7 +318,7 @@ namespace storm {
std::set<storm::expressions::Variable> containedMetaVariables;
std::set_difference(unionOfMetaVariables.begin(), unionOfMetaVariables.end(), summationMetaVariables.begin(), summationMetaVariables.end(), std::inserter(containedMetaVariables, containedMetaVariables.begin()));
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.multiplyMatrix(otherMatrix, summationDdVariables), containedMetaVariables);
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.multiplyMatrix(otherMatrix.getInternalBdd(), summationDdVariables), containedMetaVariables);
}
template<DdType LibraryType, typename ValueType>
@ -843,7 +843,7 @@ namespace storm {
numberOfDdVariables += ddMetaVariable.getNumberOfDdVariables();
}
return internalAdd.begin(this->getDdManager(), Bdd<LibraryType>::getCube(this->getDdManager(), this->getContainedMetaVariables()), numberOfDdVariables, this->getContainedMetaVariables(), enumerateDontCareMetaVariables);
return internalAdd.begin(this->getDdManager(), Bdd<LibraryType>::getCube(this->getDdManager(), this->getContainedMetaVariables()).getInternalBdd(), numberOfDdVariables, this->getContainedMetaVariables(), enumerateDontCareMetaVariables);
}
template<DdType LibraryType, typename ValueType>

43
src/storm/storage/dd/Bdd.cpp

@ -141,19 +141,19 @@ namespace storm {
template<DdType LibraryType>
Bdd<LibraryType> Bdd<LibraryType>::existsAbstract(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = getCube(this->getDdManager(), metaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalBdd.existsAbstract(cube), Dd<LibraryType>::subtractMetaVariables(*this, cube));
return Bdd<LibraryType>(this->getDdManager(), internalBdd.existsAbstract(cube.getInternalBdd()), Dd<LibraryType>::subtractMetaVariables(*this, cube));
}
template<DdType LibraryType>
Bdd<LibraryType> Bdd<LibraryType>::existsAbstractRepresentative(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = getCube(this->getDdManager(), metaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalBdd.existsAbstractRepresentative(cube), this->getContainedMetaVariables());
return Bdd<LibraryType>(this->getDdManager(), internalBdd.existsAbstractRepresentative(cube.getInternalBdd()), this->getContainedMetaVariables());
}
template<DdType LibraryType>
Bdd<LibraryType> Bdd<LibraryType>::universalAbstract(std::set<storm::expressions::Variable> const& metaVariables) const {
Bdd<LibraryType> cube = getCube(this->getDdManager(), metaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalBdd.universalAbstract(cube), Dd<LibraryType>::subtractMetaVariables(*this, cube));
return Bdd<LibraryType>(this->getDdManager(), internalBdd.universalAbstract(cube.getInternalBdd()), Dd<LibraryType>::subtractMetaVariables(*this, cube));
}
template<DdType LibraryType>
@ -165,17 +165,17 @@ namespace storm {
std::set<storm::expressions::Variable> containedMetaVariables;
std::set_difference(unionOfMetaVariables.begin(), unionOfMetaVariables.end(), existentialVariables.begin(), existentialVariables.end(), std::inserter(containedMetaVariables, containedMetaVariables.begin()));
return Bdd<LibraryType>(this->getDdManager(), internalBdd.andExists(other, cube), containedMetaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalBdd.andExists(other.getInternalBdd(), cube.getInternalBdd()), containedMetaVariables);
}
template<DdType LibraryType>
Bdd<LibraryType> Bdd<LibraryType>::constrain(Bdd<LibraryType> const& constraint) const {
return Bdd<LibraryType>(this->getDdManager(), internalBdd.constrain(constraint), Dd<LibraryType>::joinMetaVariables(*this, constraint));
return Bdd<LibraryType>(this->getDdManager(), internalBdd.constrain(constraint.getInternalBdd()), Dd<LibraryType>::joinMetaVariables(*this, constraint));
}
template<DdType LibraryType>
Bdd<LibraryType> Bdd<LibraryType>::restrict(Bdd<LibraryType> const& constraint) const {
return Bdd<LibraryType>(this->getDdManager(), internalBdd.restrict(constraint), Dd<LibraryType>::joinMetaVariables(*this, constraint));
return Bdd<LibraryType>(this->getDdManager(), internalBdd.restrict(constraint.getInternalBdd()), Dd<LibraryType>::joinMetaVariables(*this, constraint));
}
template<DdType LibraryType>
@ -187,7 +187,7 @@ namespace storm {
for (auto const& metaVariable : rowMetaVariables) {
DdMetaVariable<LibraryType> const& variable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : variable.getDdVariables()) {
rowVariables.push_back(ddVariable);
rowVariables.push_back(ddVariable.getInternalBdd());
}
}
@ -195,11 +195,11 @@ namespace storm {
for (auto const& metaVariable : columnMetaVariables) {
DdMetaVariable<LibraryType> const& variable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : variable.getDdVariables()) {
columnVariables.push_back(ddVariable);
columnVariables.push_back(ddVariable.getInternalBdd());
}
}
return Bdd<LibraryType>(this->getDdManager(), internalBdd.relationalProduct(relation, rowVariables, columnVariables), newMetaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalBdd.relationalProduct(relation.getInternalBdd(), rowVariables, columnVariables), newMetaVariables);
}
template<DdType LibraryType>
@ -211,7 +211,7 @@ namespace storm {
for (auto const& metaVariable : rowMetaVariables) {
DdMetaVariable<LibraryType> const& variable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : variable.getDdVariables()) {
rowVariables.push_back(ddVariable);
rowVariables.push_back(ddVariable.getInternalBdd());
}
}
@ -219,11 +219,11 @@ namespace storm {
for (auto const& metaVariable : columnMetaVariables) {
DdMetaVariable<LibraryType> const& variable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : variable.getDdVariables()) {
columnVariables.push_back(ddVariable);
columnVariables.push_back(ddVariable.getInternalBdd());
}
}
return Bdd<LibraryType>(this->getDdManager(), internalBdd.inverseRelationalProduct(relation, rowVariables, columnVariables), newMetaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalBdd.inverseRelationalProduct(relation.getInternalBdd(), rowVariables, columnVariables), newMetaVariables);
}
template<DdType LibraryType>
@ -235,7 +235,7 @@ namespace storm {
for (auto const& metaVariable : rowMetaVariables) {
DdMetaVariable<LibraryType> const& variable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : variable.getDdVariables()) {
rowVariables.push_back(ddVariable);
rowVariables.push_back(ddVariable.getInternalBdd());
}
}
@ -243,11 +243,11 @@ namespace storm {
for (auto const& metaVariable : columnMetaVariables) {
DdMetaVariable<LibraryType> const& variable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : variable.getDdVariables()) {
columnVariables.push_back(ddVariable);
columnVariables.push_back(ddVariable.getInternalBdd());
}
}
return Bdd<LibraryType>(this->getDdManager(), internalBdd.inverseRelationalProductWithExtendedRelation(relation, rowVariables, columnVariables), newMetaVariables);
return Bdd<LibraryType>(this->getDdManager(), internalBdd.inverseRelationalProductWithExtendedRelation(relation.getInternalBdd(), rowVariables, columnVariables), newMetaVariables);
}
template<DdType LibraryType>
@ -278,10 +278,10 @@ namespace storm {
}
for (auto const& ddVariable : variable1.getDdVariables()) {
from.push_back(ddVariable);
from.emplace_back(ddVariable.getInternalBdd());
}
for (auto const& ddVariable : variable2.getDdVariables()) {
to.push_back(ddVariable);
to.emplace_back(ddVariable.getInternalBdd());
}
}
@ -301,14 +301,14 @@ namespace storm {
STORM_LOG_THROW(this->containsMetaVariable(metaVariable), storm::exceptions::InvalidOperationException, "Cannot rename variable '" << metaVariable.getName() << "' that is not present.");
DdMetaVariable<LibraryType> const& ddMetaVariable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : ddMetaVariable.getDdVariables()) {
fromBdds.push_back(ddVariable);
fromBdds.push_back(ddVariable.getInternalBdd());
}
}
for (auto const& metaVariable : to) {
STORM_LOG_THROW(!this->containsMetaVariable(metaVariable), storm::exceptions::InvalidOperationException, "Cannot rename to variable '" << metaVariable.getName() << "' that is already present.");
DdMetaVariable<LibraryType> const& ddMetaVariable = this->getDdManager().getMetaVariable(metaVariable);
for (auto const& ddVariable : ddMetaVariable.getDdVariables()) {
toBdds.push_back(ddVariable);
toBdds.push_back(ddVariable.getInternalBdd());
}
}
@ -418,11 +418,6 @@ namespace storm {
return result;
}
template<DdType LibraryType>
Bdd<LibraryType>::operator InternalBdd<LibraryType>() const {
return internalBdd;
}
template class Bdd<DdType::CUDD>;
template Bdd<DdType::CUDD> Bdd<DdType::CUDD>::fromVector(DdManager<DdType::CUDD> const& ddManager, std::vector<double> const& explicitValues, storm::dd::Odd const& odd, std::set<storm::expressions::Variable> const& metaVariables, storm::logic::ComparisonType comparisonType, double value);

5
src/storm/storage/dd/Bdd.h

@ -384,11 +384,6 @@ namespace storm {
friend struct FromVectorHelper;
private:
/*!
* We provide a conversion operator from the BDD to its internal type to ease calling the internal functions.
*/
operator InternalBdd<LibraryType>() const;
// The internal BDD that depends on the chosen library.
InternalBdd<LibraryType> internalBdd;
};

Loading…
Cancel
Save