Browse Source

more work on making sylvan mtbdds work

Former-commit-id: 98454b0ff4
tempestpy_adaptions
dehnert 9 years ago
parent
commit
8194454621
  1. 83
      resources/3rdparty/sylvan/src/sylvan_mtbdd.c
  2. 13
      resources/3rdparty/sylvan/src/sylvan_mtbdd.h
  3. 15
      resources/3rdparty/sylvan/src/sylvan_obj.cpp
  4. 10
      resources/3rdparty/sylvan/src/sylvan_obj.hpp
  5. 13
      src/storage/dd/Add.cpp
  6. 2
      src/storage/dd/cudd/InternalCuddAdd.cpp
  7. 6
      src/storage/dd/cudd/InternalCuddAdd.h
  8. 3
      src/storage/dd/cudd/InternalCuddBdd.h
  9. 72
      src/storage/dd/sylvan/InternalSylvanAdd.cpp
  10. 16
      src/storage/dd/sylvan/InternalSylvanAdd.h
  11. 9
      src/storage/dd/sylvan/InternalSylvanBdd.h
  12. 34
      src/storage/dd/sylvan/InternalSylvanDdManager.cpp
  13. 25
      src/storage/dd/sylvan/InternalSylvanDdManager.h
  14. 6
      src/storage/dd/sylvan/SylvanAddIterator.h
  15. 68
      test/functional/storage/SylvanDdTest.cpp

83
resources/3rdparty/sylvan/src/sylvan_mtbdd.c

@ -1191,6 +1191,89 @@ TASK_IMPL_2(MTBDD, mtbdd_op_times, MTBDD*, pa, MTBDD*, pb)
return mtbdd_invalid;
}
/**
* Binary operation Times (for MTBDDs of same type)
* Only for MTBDDs where either all leaves are Double.
* For Integer/Double MTBDD, if either operand is mtbdd_false (not defined),
* then the result is mtbdd_false (i.e. not defined).
*/
TASK_IMPL_2(MTBDD, mtbdd_op_divide, MTBDD*, pa, MTBDD*, pb)
{
MTBDD a = *pa, b = *pb;
// if (a == mtbdd_false || b == mtbdd_false) return mtbdd_false;
// Handle Boolean MTBDDs: interpret as And
// if (a == mtbdd_true) return b;
// if (b == mtbdd_true) return a;
mtbddnode_t na = GETNODE(a);
mtbddnode_t nb = GETNODE(b);
if (mtbddnode_isleaf(na) && mtbddnode_isleaf(nb)) {
// uint64_t val_a = mtbddnode_getvalue(na);
// uint64_t val_b = mtbddnode_getvalue(nb);
// if (mtbddnode_gettype(na) == 0 && mtbddnode_gettype(nb) == 0) {
// // both uint64_t
// if (val_a == 0) return a;
// else if (val_b == 0) return b;
// else {
// MTBDD result;
// if (val_a == 1) result = b;
// else if (val_b == 1) result = a;
// else result = mtbdd_uint64(val_a*val_b);
// int nega = mtbdd_isnegated(a);
// int negb = mtbdd_isnegated(b);
// if (nega ^ negb) return mtbdd_negate(result);
// else return result;
// }
// } else if (mtbddnode_gettype(na) == 1 && mtbddnode_gettype(nb) == 1) {
if (mtbddnode_gettype(na) == 1 && mtbddnode_gettype(nb) == 1) {
// both double
double vval_a = *(double*)&val_a;
double vval_b = *(double*)&val_b;
if (vval_a == 0.0) return a;
else if (vval_b == 0.0) return b;
else {
MTBDD result;
if (vval_a == 0.0 || vval_b == 1.0) result = a;
int nega = mtbdd_isnegated(a);
int negb = mtbdd_isnegated(b);
result = mtbdd_double(a / b);
if (nega ^ negb) return mtbdd_negate(result);
else return result;
}
}
// else if (mtbddnode_gettype(na) == 2 && mtbddnode_gettype(nb) == 2) {
// // both fraction
// uint64_t nom_a = val_a>>32;
// uint64_t nom_b = val_b>>32;
// uint64_t denom_a = val_a&0xffffffff;
// uint64_t denom_b = val_b&0xffffffff;
// // multiply!
// uint32_t c = gcd(nom_b, denom_a);
// uint32_t d = gcd(nom_a, denom_b);
// nom_a /= d;
// denom_a /= c;
// nom_a *= (nom_b/c);
// denom_a *= (denom_b/d);
// // compute result
// int nega = mtbdd_isnegated(a);
// int negb = mtbdd_isnegated(b);
// MTBDD result = mtbdd_fraction(nom_a, denom_a);
// if (nega ^ negb) return mtbdd_negate(result);
// else return result;
// }
}
// if (a < b) {
// *pa = b;
// *pb = a;
// }
return mtbdd_invalid;
}
/**
* Binary operation Minimum (for MTBDDs of same type)
* Only for MTBDDs where either all leaves are Boolean, or Integer, or Double.

13
resources/3rdparty/sylvan/src/sylvan_mtbdd.h

@ -224,6 +224,14 @@ TASK_DECL_3(MTBDD, mtbdd_abstract_op_plus, MTBDD, MTBDD, int);
TASK_DECL_2(MTBDD, mtbdd_op_times, MTBDD*, MTBDD*);
TASK_DECL_3(MTBDD, mtbdd_abstract_op_times, MTBDD, MTBDD, int);
/**
* Binary operation Divide (for MTBDDs of same type)
* Only for MTBDDs where all leaves are Double.
* If either operand is mtbdd_false (not defined),
* then the result is mtbdd_false (i.e. not defined).
*/
TASK_DECL_2(MTBDD, mtbdd_op_divide, MTBDD*, MTBDD*);
/**
* Binary operation Minimum (for MTBDDs of same type)
* Only for MTBDDs where either all leaves are Boolean, or Integer, or Double.
@ -257,6 +265,11 @@ TASK_DECL_3(MTBDD, mtbdd_abstract_op_max, MTBDD, MTBDD, int);
*/
#define mtbdd_times(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_times))
/**
* Compute a / b
*/
#define mtbdd_divide(a, b) mtbdd_apply(a, b, TASK(mtbdd_op_divide))
/**
* Compute min(a, b)
*/

15
resources/3rdparty/sylvan/src/sylvan_obj.cpp

@ -724,6 +724,14 @@ Mtbdd::Plus(const Mtbdd &other) const
return mtbdd_plus(mtbdd, other.mtbdd);
}
Mtbdd
Mtbdd::Minus(const Mtbdd &other) const
{
LACE_ME;
return mtbdd_minus(mtbdd, other.mtbdd);
}
Mtbdd
Mtbdd::Times(const Mtbdd &other) const
{
@ -731,6 +739,13 @@ Mtbdd::Times(const Mtbdd &other) const
return mtbdd_times(mtbdd, other.mtbdd);
}
Mtbdd
Mtbdd::Divide(const Mtbdd &other) const
{
LACE_ME;
return mtbdd_divide(mtbdd, other.mtbdd);
}
Mtbdd
Mtbdd::Min(const Mtbdd &other) const
{

10
resources/3rdparty/sylvan/src/sylvan_obj.hpp

@ -516,11 +516,21 @@ public:
*/
Mtbdd Plus(const Mtbdd &other) const;
/**
* @brief Computes f - g
*/
Mtbdd Minus(const Mtbdd &other) const;
/**
* @brief Computes f * g
*/
Mtbdd Times(const Mtbdd &other) const;
/**
* @brief Computes f / g
*/
Mtbdd Divide(const Mtbdd &other) const;
/**
* @brief Computes min(f, g)
*/

13
src/storage/dd/Add.cpp

@ -287,10 +287,17 @@ namespace storm {
template<DdType LibraryType, typename ValueType>
uint_fast64_t Add<LibraryType, ValueType>::getNonZeroCount() const {
std::size_t numberOfDdVariables = 0;
for (auto const& metaVariable : this->getContainedMetaVariables()) {
numberOfDdVariables += this->getDdManager()->getMetaVariable(metaVariable).getNumberOfDdVariables();
if (LibraryType == DdType::CUDD) {
std::size_t numberOfDdVariables = 0;
for (auto const& metaVariable : this->getContainedMetaVariables()) {
numberOfDdVariables += this->getDdManager()->getMetaVariable(metaVariable).getNumberOfDdVariables();
}
}
Bdd<LibraryType> cube;
if (LibraryType == DdType::Sylvan) {
cube = Bdd<LibraryType>::getCube(*this->getDdManager(), this->getContainedMetaVariables());
}
return internalAdd.getNonZeroCount(numberOfDdVariables);
return internalAdd.getNonZeroCount(cube, numberOfDdVariables);
}
template<DdType LibraryType, typename ValueType>

2
src/storage/dd/cudd/InternalCuddAdd.cpp

@ -245,7 +245,7 @@ namespace storm {
}
template<typename ValueType>
uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getNonZeroCount(uint_fast64_t numberOfDdVariables) const {
uint_fast64_t InternalAdd<DdType::CUDD, ValueType>::getNonZeroCount(InternalBdd<DdType::CUDD> const& cube, uint_fast64_t numberOfDdVariables) const {
return static_cast<uint_fast64_t>(this->getCuddAdd().CountMinterm(static_cast<int>(numberOfDdVariables)));
}

6
src/storage/dd/cudd/InternalCuddAdd.h

@ -45,7 +45,6 @@ namespace storm {
*
* @param ddManager The manager responsible for this DD.
* @param cuddAdd The CUDD ADD to store.
* @param containedMetaVariables The meta variables that appear in the DD.
*/
InternalAdd(InternalDdManager<DdType::CUDD> const* ddManager, cudd::ADD cuddAdd);
@ -406,10 +405,11 @@ namespace storm {
/*!
* Retrieves the number of encodings that are mapped to a non-zero value.
*
* @param The number of DD variables contained in this ADD.
* @param cube A cube of variables that is ignored.
* @param numberOfDdVariables The number of DD variables contained in this BDD.
* @return The number of encodings that are mapped to a non-zero value.
*/
virtual uint_fast64_t getNonZeroCount(uint_fast64_t numberOfDdVariables) const;
uint_fast64_t getNonZeroCount(InternalBdd<DdType::CUDD> const& cube, uint_fast64_t numberOfDdVariables) const;
/*!
* Retrieves the number of leaves of the ADD.

3
src/storage/dd/cudd/InternalCuddBdd.h

@ -28,7 +28,8 @@ namespace storm {
template<>
class InternalBdd<DdType::CUDD> {
public:
friend class InternalAdd<DdType::CUDD, double>;
template <DdType LibraryType, typename ValueType>
friend class InternalAdd;
/*!
* Creates a DD that encapsulates the given CUDD ADD.

72
src/storage/dd/sylvan/InternalSylvanAdd.cpp

@ -1,18 +1,25 @@
#include "src/storage/dd/sylvan/InternalSylvanAdd.h"
#include "src/storage/dd/sylvan/InternalSylvanDdManager.h"
#include "src/utility/macros.h"
#include "src/exceptions/NotImplementedException.h"
namespace storm {
namespace dd {
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>::InternalAdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Mtbdd const& sylvanMtbdd) : ddManager(ddManager), sylvanMtbdd(sylvanMtbdd) {
// Intentionally left empty.
}
template<typename ValueType>
bool InternalAdd<DdType::Sylvan, ValueType>::operator==(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return this->sylvanMtbdd == other.sylvanMtbdd;
}
template<typename ValueType>
bool InternalAdd<DdType::Sylvan, ValueType>::operator!=(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return this->sylvanMtbdd != other.sylvanMtbdd;
}
template<typename ValueType>
@ -33,37 +40,39 @@ namespace storm {
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>& InternalAdd<DdType::Sylvan, ValueType>::operator|=(InternalAdd<DdType::Sylvan, ValueType> const& other) {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::operator+(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.Plus(other.sylvanMtbdd));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>& InternalAdd<DdType::Sylvan, ValueType>::operator+=(InternalAdd<DdType::Sylvan, ValueType> const& other) {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
this->sylvanMtbdd = this->sylvanMtbdd.Plus(other.sylvanMtbdd);
return *this;
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::operator*(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.Times(other.sylvanMtbdd));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>& InternalAdd<DdType::Sylvan, ValueType>::operator*=(InternalAdd<DdType::Sylvan, ValueType> const& other) {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
this->sylvanMtbdd = this->sylvanMtbdd.Times(other.sylvanMtbdd);
return *this;
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::operator-(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.Minus(other.sylvanMtbdd));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>& InternalAdd<DdType::Sylvan, ValueType>::operator-=(InternalAdd<DdType::Sylvan, ValueType> const& other) {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
this->sylvanMtbdd = this->sylvanMtbdd.Plus(other.sylvanMtbdd.Negate());
return *this;
}
template<typename ValueType>
@ -133,27 +142,27 @@ namespace storm {
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::minimum(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.Min(other.sylvanMtbdd));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::maximum(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.Max(other.sylvanMtbdd));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::sumAbstract(InternalBdd<DdType::Sylvan> const& cube) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.AbstractPlus(static_cast<MTBDD>(cube.sylvanBdd.GetBDD())));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::minAbstract(InternalBdd<DdType::Sylvan> const& cube) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.AbstractMin(static_cast<MTBDD>(cube.sylvanBdd.GetBDD())));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::maxAbstract(InternalBdd<DdType::Sylvan> const& cube) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.AbstractMax(static_cast<MTBDD>(cube.sylvanBdd.GetBDD())));
}
template<typename ValueType>
@ -168,27 +177,31 @@ namespace storm {
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::multiplyMatrix(InternalAdd<DdType::Sylvan, ValueType> const& otherMatrix, std::vector<InternalAdd<DdType::Sylvan, ValueType>> const& summationDdVariables) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
sylvan::Mtbdd summationVariables = sylvan::Mtbdd::mtbddOne();
for (auto const& ddVariable : summationDdVariables) {
summationVariables *= ddVariable.sylvanMtbdd;
}
return InternalAdd<DdType::Sylvan, ValueType>(ddManager, this->sylvanMtbdd.AndExists(otherMatrix.sylvanMtbdd, summationVariables));
}
template<typename ValueType>
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::greater(ValueType const& value) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalBdd<DdType::Sylvan>(ddManager, this->sylvanMtbdd.BddStrictThreshold(value));
}
template<typename ValueType>
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::greaterOrEqual(ValueType const& value) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalBdd<DdType::Sylvan>(ddManager, this->sylvanMtbdd.BddThreshold(value));
}
template<typename ValueType>
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::less(ValueType const& value) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return !this->greaterOrEqual(value);
}
template<typename ValueType>
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::lessOrEqual(ValueType const& value) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return !this->greater(value);
}
template<typename ValueType>
@ -208,12 +221,12 @@ namespace storm {
template<typename ValueType>
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::getSupport() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalBdd<DdType::Sylvan>(ddManager, sylvan::Bdd(static_cast<BDD>(this->sylvanMtbdd.Support().GetMTBDD())));
}
template<typename ValueType>
uint_fast64_t InternalAdd<DdType::Sylvan, ValueType>::getNonZeroCount(uint_fast64_t numberOfDdVariables) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
uint_fast64_t InternalAdd<DdType::Sylvan, ValueType>::getNonZeroCount(InternalBdd<DdType::Sylvan> const& cube, uint_fast64_t numberOfDdVariables) const {
return static_cast<uint_fast64_t>(this->sylvanMtbdd.SatCount(cube.sylvanBdd));
}
template<typename ValueType>
@ -223,7 +236,7 @@ namespace storm {
template<typename ValueType>
uint_fast64_t InternalAdd<DdType::Sylvan, ValueType>::getNodeCount() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return static_cast<uint_fast64_t>(this->sylvanMtbdd.NodeCount()) + this->getLeafCount();
}
template<typename ValueType>
@ -243,27 +256,30 @@ namespace storm {
template<typename ValueType>
bool InternalAdd<DdType::Sylvan, ValueType>::isOne() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return *this == ddManager->getAddOne<ValueType>();
}
template<typename ValueType>
bool InternalAdd<DdType::Sylvan, ValueType>::isZero() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return *this == ddManager->getAddZero<ValueType>();
}
template<typename ValueType>
bool InternalAdd<DdType::Sylvan, ValueType>::isConstant() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return this->sylvanMtbdd.isTerminal();
}
template<typename ValueType>
uint_fast64_t InternalAdd<DdType::Sylvan, ValueType>::getIndex() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return static_cast<uint_fast64_t>(this->sylvanMtbdd.TopVar());
}
template<typename ValueType>
void InternalAdd<DdType::Sylvan, ValueType>::exportToDot(std::string const& filename, std::vector<std::string> const& ddVariableNamesAsStrings) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
// Open the file, dump the DD and close it again.
FILE* filePointer = fopen(filename.c_str() , "w");
mtbdd_fprintdot(filePointer, this->sylvanMtbdd.GetMTBDD(), nullptr);
fclose(filePointer);
}
template<typename ValueType>

16
src/storage/dd/sylvan/InternalSylvanAdd.h

@ -40,13 +40,21 @@ namespace storm {
template<typename ValueType>
class InternalAdd<DdType::Sylvan, ValueType> {
public:
/*!
* Creates an ADD that encapsulates the given Sylvan MTBDD.
*
* @param ddManager The manager responsible for this DD.
* @param sylvanMtbdd The sylvan MTBDD to store.
*/
InternalAdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Mtbdd const& sylvanMtbdd);
// Instantiate all copy/move constructors/assignments with the default implementation.
InternalAdd() = default;
InternalAdd(InternalAdd<DdType::Sylvan, ValueType> const& other) = default;
InternalAdd& operator=(InternalAdd<DdType::Sylvan, ValueType> const& other) = default;
InternalAdd(InternalAdd<DdType::Sylvan, ValueType>&& other) = default;
InternalAdd& operator=(InternalAdd<DdType::Sylvan, ValueType>&& other) = default;
/*!
* Retrieves whether the two DDs represent the same function.
*
@ -397,10 +405,11 @@ namespace storm {
/*!
* Retrieves the number of encodings that are mapped to a non-zero value.
*
* @param The number of DD variables contained in this ADD.
* @param cube The cube of variables contained in this BDD.
* @param numberOfDdVariables The number of DD variables contained in this BDD. This is ignored.
* @return The number of encodings that are mapped to a non-zero value.
*/
virtual uint_fast64_t getNonZeroCount(uint_fast64_t numberOfDdVariables) const;
virtual uint_fast64_t getNonZeroCount(InternalBdd<DdType::Sylvan> const& cube, uint_fast64_t numberOfDdVariables) const;
/*!
* Retrieves the number of leaves of the ADD.
@ -574,6 +583,7 @@ namespace storm {
private:
InternalDdManager<DdType::Sylvan> const* ddManager;
sylvan::Mtbdd sylvanMtbdd;
};
}
}

9
src/storage/dd/sylvan/InternalSylvanBdd.h

@ -1,5 +1,5 @@
#ifndef STORM_STORAGE_DD_CUDD_INTERNALSYLVANBDD_H_
#define STORM_STORAGE_DD_CUDD_INTERNALSYLVANBDD_H_
#ifndef STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANBDD_H_
#define STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANBDD_H_
#include <vector>
#include <functional>
@ -24,7 +24,8 @@ namespace storm {
template<>
class InternalBdd<DdType::Sylvan> {
public:
friend class InternalAdd<DdType::Sylvan, double>;
template <DdType LibraryType, typename ValueType>
friend class InternalAdd;
InternalBdd(InternalDdManager<DdType::Sylvan> const* ddManager, sylvan::Bdd const& sylvanBdd);
@ -305,4 +306,4 @@ namespace storm {
}
}
#endif /* STORM_STORAGE_DD_CUDD_INTERNALSYLVANBDD_H_ */
#endif /* STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANBDD_H_ */

34
src/storage/dd/sylvan/InternalSylvanDdManager.cpp

@ -1,5 +1,6 @@
#include "src/storage/dd/sylvan/InternalSylvanDdManager.h"
#include "src/utility/constants.h"
#include "src/utility/macros.h"
#include "src/exceptions/NotImplementedException.h"
#include "src/exceptions/NotSupportedException.h"
@ -33,23 +34,38 @@ namespace storm {
return InternalBdd<DdType::Sylvan>(this, sylvan::Bdd::bddOne());
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalDdManager<DdType::Sylvan>::getAddOne() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
template<>
InternalAdd<DdType::Sylvan, double> InternalDdManager<DdType::Sylvan>::getAddOne() const {
return InternalAdd<DdType::Sylvan, double>(this, sylvan::Mtbdd::doubleTerminal(storm::utility::one<double>()));
}
template<>
InternalAdd<DdType::Sylvan, uint_fast64_t> InternalDdManager<DdType::Sylvan>::getAddOne() const {
return InternalAdd<DdType::Sylvan, uint_fast64_t>(this, sylvan::Mtbdd::uint64Terminal(storm::utility::one<uint_fast64_t>()));
}
InternalBdd<DdType::Sylvan> InternalDdManager<DdType::Sylvan>::getBddZero() const {
return InternalBdd<DdType::Sylvan>(this, sylvan::Bdd::bddZero());
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalDdManager<DdType::Sylvan>::getAddZero() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
template<>
InternalAdd<DdType::Sylvan, double> InternalDdManager<DdType::Sylvan>::getAddZero() const {
return InternalAdd<DdType::Sylvan, double>(this, sylvan::Mtbdd::doubleTerminal(storm::utility::zero<double>()));
}
template<>
InternalAdd<DdType::Sylvan, uint_fast64_t> InternalDdManager<DdType::Sylvan>::getAddZero() const {
return InternalAdd<DdType::Sylvan, uint_fast64_t>(this, sylvan::Mtbdd::uint64Terminal(storm::utility::zero<uint_fast64_t>()));
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalDdManager<DdType::Sylvan>::getConstant(ValueType const& value) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
template<>
InternalAdd<DdType::Sylvan, double> InternalDdManager<DdType::Sylvan>::getConstant(double const& value) const {
return InternalAdd<DdType::Sylvan, double>(this, sylvan::Mtbdd::doubleTerminal(value));
}
template<>
InternalAdd<DdType::Sylvan, uint_fast64_t> InternalDdManager<DdType::Sylvan>::getConstant(uint_fast64_t const& value) const {
return InternalAdd<DdType::Sylvan, uint_fast64_t>(this, sylvan::Mtbdd::uint64Terminal(value));
}
std::pair<InternalBdd<DdType::Sylvan>, InternalBdd<DdType::Sylvan>> InternalDdManager<DdType::Sylvan>::createNewDdVariablePair() {

25
src/storage/dd/sylvan/InternalSylvanDdManager.h

@ -1,5 +1,5 @@
#ifndef STORM_STORAGE_DD_INTERNALSYLVANDDMANAGER_H_
#define STORM_STORAGE_DD_INTERNALSYLVANDDMANAGER_H_
#ifndef STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANDDMANAGER_H_
#define STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANDDMANAGER_H_
#include "src/storage/dd/DdType.h"
#include "src/storage/dd/InternalDdManager.h"
@ -107,7 +107,26 @@ namespace storm {
// manager is implicitly 'global'.
static uint_fast64_t nextFreeVariableIndex;
};
template<>
InternalAdd<DdType::Sylvan, double> InternalDdManager<DdType::Sylvan>::getAddOne() const;
template<>
InternalAdd<DdType::Sylvan, uint_fast64_t> InternalDdManager<DdType::Sylvan>::getAddOne() const;
template<>
InternalAdd<DdType::Sylvan, double> InternalDdManager<DdType::Sylvan>::getAddZero() const;
template<>
InternalAdd<DdType::Sylvan, uint_fast64_t> InternalDdManager<DdType::Sylvan>::getAddZero() const;
template<>
InternalAdd<DdType::Sylvan, double> InternalDdManager<DdType::Sylvan>::getConstant(double const& value) const;
template<>
InternalAdd<DdType::Sylvan, uint_fast64_t> InternalDdManager<DdType::Sylvan>::getConstant(uint_fast64_t const& value) const;
}
}
#endif /* STORM_STORAGE_DD_INTERNALSYLVANDDMANAGER_H_ */
#endif /* STORM_STORAGE_DD_SYLVAN_INTERNALSYLVANDDMANAGER_H_ */

6
src/storage/dd/sylvan/SylvanAddIterator.h

@ -1,5 +1,5 @@
#ifndef STORM_STORAGE_DD_SYLVANADDITERATOR_H_
#define STORM_STORAGE_DD_SYLVANADDITERATOR_H_
#ifndef STORM_STORAGE_DD_SYLVAN_SYLVANADDITERATOR_H_
#define STORM_STORAGE_DD_SYLVAN_SYLVANADDITERATOR_H_
#include "src/storage/dd/AddIterator.h"
#include "src/storage/expressions/SimpleValuation.h"
@ -66,4 +66,4 @@ namespace storm {
}
}
#endif /* STORM_STORAGE_DD_SYLVANADDITERATOR_H_ */
#endif /* STORM_STORAGE_DD_SYLVAN_SYLVANADDITERATOR_H_ */

68
test/functional/storage/SylvanDdTest.cpp

@ -102,38 +102,38 @@ TEST(SylvanDd, RangeTest) {
// EXPECT_EQ(21ul, identity.getNodeCount());
//}
//
//TEST(SylvanDd, OperatorTest) {
// std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::Sylvan>> manager(new storm::dd::DdManager<storm::dd::DdType::Sylvan>());
// std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
// EXPECT_TRUE(manager->template getAddZero<double>() == manager->template getAddZero<double>());
// EXPECT_FALSE(manager->template getAddZero<double>() == manager->template getAddOne<double>());
//
// EXPECT_FALSE(manager->template getAddZero<double>() != manager->template getAddZero<double>());
// EXPECT_TRUE(manager->template getAddZero<double>() != manager->template getAddOne<double>());
//
// storm::dd::Add<storm::dd::DdType::Sylvan, double> dd1 = manager->template getAddOne<double>();
// storm::dd::Add<storm::dd::DdType::Sylvan, double> dd2 = manager->template getAddOne<double>();
// storm::dd::Add<storm::dd::DdType::Sylvan, double> dd3 = dd1 + dd2;
// EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
//
// dd3 += manager->template getAddZero<double>();
// EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
//
// dd3 = dd1 * manager->template getConstant<double>(3);
// EXPECT_TRUE(dd3 == manager->template getConstant<double>(3));
//
// dd3 *= manager->template getConstant<double>(2);
// EXPECT_TRUE(dd3 == manager->template getConstant<double>(6));
//
// dd3 = dd1 - dd2;
// EXPECT_TRUE(dd3.isZero());
//
// dd3 -= manager->template getConstant<double>(-2);
// EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
//
// dd3 /= manager->template getConstant<double>(2);
// EXPECT_TRUE(dd3.isOne());
//
TEST(SylvanDd, OperatorTest) {
std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::Sylvan>> manager(new storm::dd::DdManager<storm::dd::DdType::Sylvan>());
std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
EXPECT_TRUE(manager->template getAddZero<double>() == manager->template getAddZero<double>());
EXPECT_FALSE(manager->template getAddZero<double>() == manager->template getAddOne<double>());
EXPECT_FALSE(manager->template getAddZero<double>() != manager->template getAddZero<double>());
EXPECT_TRUE(manager->template getAddZero<double>() != manager->template getAddOne<double>());
storm::dd::Add<storm::dd::DdType::Sylvan, double> dd1 = manager->template getAddOne<double>();
storm::dd::Add<storm::dd::DdType::Sylvan, double> dd2 = manager->template getAddOne<double>();
storm::dd::Add<storm::dd::DdType::Sylvan, double> dd3 = dd1 + dd2;
EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
dd3 += manager->template getAddZero<double>();
EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
dd3 = dd1 * manager->template getConstant<double>(3);
EXPECT_TRUE(dd3 == manager->template getConstant<double>(3));
dd3 *= manager->template getConstant<double>(2);
EXPECT_TRUE(dd3 == manager->template getConstant<double>(6));
dd3 = dd1 - dd2;
EXPECT_TRUE(dd3.isZero());
dd3 -= manager->template getConstant<double>(-2);
EXPECT_TRUE(dd3 == manager->template getConstant<double>(2));
dd3 /= manager->template getConstant<double>(2);
EXPECT_TRUE(dd3.isOne());
// dd3 = !dd3;
// EXPECT_TRUE(dd3.isZero());
//
@ -182,8 +182,8 @@ TEST(SylvanDd, RangeTest) {
// dd2 = manager->template getConstant<double>(0.01 + 1e-6);
// EXPECT_TRUE(dd1.equalModuloPrecision(dd2, 1e-6, false));
// EXPECT_FALSE(dd1.equalModuloPrecision(dd2, 1e-6));
//}
//
}
//TEST(SylvanDd, AbstractionTest) {
// std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::Sylvan>> manager(new storm::dd::DdManager<storm::dd::DdType::Sylvan>());
// std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);

Loading…
Cancel
Save