Browse Source

changed return type of equal, notEqual, less, lessOrEqual, greater, greaterOrEqual to BDD since returning an ADD is logically not quite correct

Former-commit-id: 64bf8b0704
main
dehnert 10 years ago
parent
commit
472851508c
  1. 4
      resources/3rdparty/sylvan/src/llmsset.h
  2. 2
      resources/3rdparty/sylvan/src/refs.h
  3. 4
      resources/3rdparty/sylvan/src/stats.h
  4. 16
      resources/3rdparty/sylvan/src/sylvan.h
  5. 2
      resources/3rdparty/sylvan/src/sylvan_bdd.h
  6. 2
      resources/3rdparty/sylvan/src/sylvan_cache.h
  7. 6
      resources/3rdparty/sylvan/src/sylvan_common.h
  8. 2
      resources/3rdparty/sylvan/src/sylvan_gmp.h
  9. 131
      resources/3rdparty/sylvan/src/sylvan_mtbdd.c
  10. 10
      resources/3rdparty/sylvan/src/sylvan_mtbdd.h
  11. 9
      resources/3rdparty/sylvan/src/sylvan_obj.cpp
  12. 6
      resources/3rdparty/sylvan/src/sylvan_obj.hpp
  13. 32
      src/adapters/AddExpressionAdapter.cpp
  14. 26
      src/builder/DdPrismModelBuilder.cpp
  15. 2
      src/models/symbolic/Model.cpp
  16. 2
      src/solver/SymbolicLinearEquationSolver.cpp
  17. 29
      src/storage/dd/Add.cpp
  18. 12
      src/storage/dd/Add.h
  19. 1
      src/storage/dd/Bdd.cpp
  20. 31
      src/storage/dd/cudd/InternalCuddAdd.cpp
  21. 20
      src/storage/dd/cudd/InternalCuddAdd.h
  22. 26
      src/storage/dd/sylvan/InternalSylvanAdd.cpp
  23. 20
      src/storage/dd/sylvan/InternalSylvanAdd.h
  24. 30
      test/functional/storage/CuddDdTest.cpp

4
resources/3rdparty/sylvan/src/llmsset.h

@ -14,11 +14,11 @@
* limitations under the License.
*/
#include <sylvan_config.h>
#include "sylvan_config.h"
#include <stdint.h>
#include <unistd.h>
#include <lace.h>
#include "lace.h"
#ifndef LLMSSET_H
#define LLMSSET_H

2
resources/3rdparty/sylvan/src/refs.h

@ -15,7 +15,7 @@
*/
#include <stdint.h> // for uint32_t etc
#include <sylvan_config.h>
#include "sylvan_config.h"
#ifndef REFS_INLINE_H
#define REFS_INLINE_H

4
resources/3rdparty/sylvan/src/stats.h

@ -14,8 +14,8 @@
* limitations under the License.
*/
#include <lace.h>
#include <sylvan_config.h>
#include "lace.h"
#include "sylvan_config.h"
#ifndef SYLVAN_STATS_H
#define SYLVAN_STATS_H

16
resources/3rdparty/sylvan/src/sylvan.h

@ -35,16 +35,16 @@
* To temporarily disable garbage collection, use sylvan_gc_disable() and sylvan_gc_enable().
*/
#include <sylvan_config.h>
#include "sylvan_config.h"
#include <stdint.h>
#include <stdio.h> // for FILE
#include <stdlib.h>
#include <lace.h> // for definitions
#include "lace.h" // for definitions
#include <sylvan_cache.h>
#include <llmsset.h>
#include <stats.h>
#include "sylvan_cache.h"
#include "llmsset.h"
#include "stats.h"
#ifndef SYLVAN_H
#define SYLVAN_H
@ -175,8 +175,8 @@ extern llmsset_t nodes;
}
#endif /* __cplusplus */
#include <sylvan_bdd.h>
#include <sylvan_ldd.h>
#include <sylvan_mtbdd.h>
#include "sylvan_bdd.h"
#include "sylvan_ldd.h"
#include "sylvan_mtbdd.h"
#endif

2
resources/3rdparty/sylvan/src/sylvan_bdd.h

@ -16,7 +16,7 @@
/* Do not include this file directly. Instead, include sylvan.h */
#include <tls.h>
#include "tls.h"
#ifndef SYLVAN_BDD_H
#define SYLVAN_BDD_H

2
resources/3rdparty/sylvan/src/sylvan_cache.h

@ -1,6 +1,6 @@
#include <stdint.h> // for uint32_t etc
#include <sylvan_config.h>
#include "sylvan_config.h"
#ifndef CACHE_H
#define CACHE_H

6
resources/3rdparty/sylvan/src/sylvan_common.h

@ -15,9 +15,9 @@
*/
#include <assert.h>
#include <sylvan.h>
#include <tls.h>
#include <sylvan_config.h>
#include "sylvan.h"
#include "tls.h"
#include "sylvan_config.h"
#ifndef SYLVAN_COMMON_H
#define SYLVAN_COMMON_H

2
resources/3rdparty/sylvan/src/sylvan_gmp.h

@ -21,7 +21,7 @@
#ifndef SYLVAN_GMP_H
#define SYLVAN_GMP_H
#include <sylvan.h>
#include "sylvan.h"
#include <gmp.h>
#ifdef __cplusplus

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

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include <sylvan_config.h>
#include "sylvan_config.h"
#include <assert.h>
#include <inttypes.h>
@ -25,11 +25,11 @@
#include <stdlib.h>
#include <string.h>
#include <refs.h>
#include <sha2.h>
#include <sylvan.h>
#include <sylvan_common.h>
#include <sylvan_mtbdd_int.h>
#include "refs.h"
#include "sha2.h"
#include "sylvan.h"
#include "sylvan_common.h"
#include "sylvan_mtbdd_int.h"
/* Primitives */
int
@ -1193,41 +1193,38 @@ TASK_IMPL_2(MTBDD, mtbdd_op_times, MTBDD*, pa, MTBDD*, pb)
/**
* 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),
* Only for MTBDDs where either all leaves are Integer or Double.
* 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;
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;
// Do not handle Boolean MTBDDs...
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) {
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) {
// both double
double vval_a = *(double*)&val_a;
double vval_b = *(double*)&val_b;
@ -1244,32 +1241,32 @@ TASK_IMPL_2(MTBDD, mtbdd_op_divide, MTBDD*, pa, MTBDD*, pb)
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;
// }
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(denom_b, denom_a);
uint32_t d = gcd(nom_a, nom_b);
nom_a /= d;
denom_a /= c;
nom_a *= (denom_b/c);
denom_a *= (nom_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;
}
@ -1538,6 +1535,28 @@ TASK_IMPL_2(MTBDD, mtbdd_op_strict_threshold_double, MTBDD, a, size_t, svalue)
return mtbdd_invalid;
}
TASK_IMPL_1(MTBDD, mtbdd_not_zero, MTBDD, a)
{
/* We only expect "double" terminals, or false */
if (a == mtbdd_false) return mtbdd_false;
if (a == mtbdd_true) return mtbdd_invalid;
// a != constant
mtbddnode_t na = GETNODE(a);
if (mtbddnode_isleaf(na)) {
if (mtbddnode_gettype(na) == 0) {
return mtbdd_getuint64(a) != 0 ? mtbdd_true : mtbdd_false;
} else if (mtbddnode_gettype(na) == 1) {
return mtbdd_getdouble(a) != 0.0 ? mtbdd_true : mtbdd_false;
} else if (mtbddnode_gettype(na) == 2) {
return mtbdd_getnumer(a) != 0 ? mtbdd_true : mtbdd_false;
}
}
return mtbdd_invalid;
}
TASK_IMPL_2(MTBDD, mtbdd_threshold_double, MTBDD, dd, double, d)
{
return mtbdd_uapply(dd, TASK(mtbdd_op_threshold_double), *(size_t*)&d);

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

@ -226,7 +226,7 @@ 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.
* Only for MTBDDs where all leaves are Integer or Double.
* If either operand is mtbdd_false (not defined),
* then the result is mtbdd_false (i.e. not defined).
*/
@ -258,7 +258,7 @@ TASK_DECL_3(MTBDD, mtbdd_abstract_op_max, MTBDD, MTBDD, int);
/**
* Compute a - b
*/
#define mtbdd_minus(a, b) mtbdd_plus(a, mtbdd_negate(minus))
#define mtbdd_minus(a, b) mtbdd_plus(a, mtbdd_negate(b))
/**
* Compute a * b
@ -324,6 +324,12 @@ TASK_DECL_2(MTBDD, mtbdd_op_threshold_double, MTBDD, size_t)
*/
TASK_DECL_2(MTBDD, mtbdd_op_strict_threshold_double, MTBDD, size_t)
/**
* Monad that converts double to a Boolean MTBDD, translate terminals != 0 to 1 and to 0 otherwise;
*/
TASK_DECL_1(MTBDD, mtbdd_not_zero, MTBDD)
#define mtbdd_not_zero(dd) CALL(mtbdd_not_zero, dd)
/**
* Convert double to a Boolean MTBDD, translate terminals >= value to 1 and to 0 otherwise;
*/

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

@ -14,7 +14,7 @@
* limitations under the License.
*/
#include <sylvan_obj.hpp>
#include "sylvan_obj.hpp"
using namespace sylvan;
@ -899,6 +899,13 @@ Mtbdd::BddStrictThreshold(double value) const
return mtbdd_strict_threshold_double(mtbdd, value);
}
Bdd
Mtbdd::NotZero() const
{
LACE_ME;
return mtbdd_not_zero(mtbdd);
}
Mtbdd
Mtbdd::Support() const
{

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

@ -20,8 +20,8 @@
#include <string>
#include <vector>
#include <lace.h>
#include <sylvan.h>
#include "lace.h"
#include "sylvan.h"
namespace sylvan {
@ -588,6 +588,8 @@ public:
*/
Bdd BddStrictThreshold(double value) const;
Bdd NotZero() const;
/**
* @brief Computes the support of a Mtbdd.
*/

32
src/adapters/AddExpressionAdapter.cpp

@ -18,8 +18,12 @@ namespace storm {
template<storm::dd::DdType Type, typename ValueType>
storm::dd::Add<Type> AddExpressionAdapter<Type, ValueType>::translateExpression(storm::expressions::Expression const& expression) {
if (expression.hasBooleanType()) {
return boost::any_cast<storm::dd::Bdd<Type>>(expression.accept(*this)).template toAdd<ValueType>();
} else {
return boost::any_cast<storm::dd::Add<Type>>(expression.accept(*this));
}
}
template<storm::dd::DdType Type, typename ValueType>
boost::any AddExpressionAdapter<Type, ValueType>::visit(storm::expressions::IfThenElseExpression const& expression) {
@ -31,25 +35,25 @@ namespace storm {
template<storm::dd::DdType Type, typename ValueType>
boost::any AddExpressionAdapter<Type, ValueType>::visit(storm::expressions::BinaryBooleanFunctionExpression const& expression) {
storm::dd::Bdd<Type> leftResult = boost::any_cast<storm::dd::Add<Type>>(expression.getFirstOperand()->accept(*this)).toBdd();
storm::dd::Bdd<Type> rightResult = boost::any_cast<storm::dd::Add<Type>>(expression.getSecondOperand()->accept(*this)).toBdd();
storm::dd::Bdd<Type> leftResult = boost::any_cast<storm::dd::Bdd<Type>>(expression.getFirstOperand()->accept(*this));
storm::dd::Bdd<Type> rightResult = boost::any_cast<storm::dd::Bdd<Type>>(expression.getSecondOperand()->accept(*this));
storm::dd::Add<Type, ValueType> result;
storm::dd::Bdd<Type> result;
switch (expression.getOperatorType()) {
case storm::expressions::BinaryBooleanFunctionExpression::OperatorType::And:
result = (leftResult && rightResult).template toAdd<ValueType>();
result = (leftResult && rightResult);
break;
case storm::expressions::BinaryBooleanFunctionExpression::OperatorType::Or:
result = (leftResult || rightResult).template toAdd<ValueType>();
result = (leftResult || rightResult);
break;
case storm::expressions::BinaryBooleanFunctionExpression::OperatorType::Iff:
result = (leftResult.iff(rightResult)).template toAdd<ValueType>();
result = (leftResult.iff(rightResult));
break;
case storm::expressions::BinaryBooleanFunctionExpression::OperatorType::Implies:
result = (!leftResult || rightResult).template toAdd<ValueType>();
result = (!leftResult || rightResult);
break;
case storm::expressions::BinaryBooleanFunctionExpression::OperatorType::Xor:
result = (leftResult.exclusiveOr(rightResult)).template toAdd<ValueType>();
result = (leftResult.exclusiveOr(rightResult));
break;
}
@ -96,7 +100,7 @@ namespace storm {
storm::dd::Add<Type> leftResult = boost::any_cast<storm::dd::Add<Type>>(expression.getFirstOperand()->accept(*this));
storm::dd::Add<Type> rightResult = boost::any_cast<storm::dd::Add<Type>>(expression.getSecondOperand()->accept(*this));
storm::dd::Add<Type> result;
storm::dd::Bdd<Type> result;
switch (expression.getRelationType()) {
case storm::expressions::BinaryRelationExpression::RelationType::Equal:
result = leftResult.equals(rightResult);
@ -125,12 +129,16 @@ namespace storm {
boost::any AddExpressionAdapter<Type, ValueType>::visit(storm::expressions::VariableExpression const& expression) {
auto const& variablePair = variableMapping.find(expression.getVariable());
STORM_LOG_THROW(variablePair != variableMapping.end(), storm::exceptions::InvalidArgumentException, "Cannot translate the given expression, because it contains the variable '" << expression.getVariableName() << "' for which no DD counterpart is known.");
if (expression.hasBooleanType()) {
return ddManager->template getIdentity<ValueType>(variablePair->second).toBdd();
} else {
return ddManager->template getIdentity<ValueType>(variablePair->second);
}
}
template<storm::dd::DdType Type, typename ValueType>
boost::any AddExpressionAdapter<Type, ValueType>::visit(storm::expressions::UnaryBooleanFunctionExpression const& expression) {
storm::dd::Bdd<Type> result = boost::any_cast<storm::dd::Add<Type>>(expression.getOperand()->accept(*this)).toBdd();
storm::dd::Bdd<Type> result = boost::any_cast<storm::dd::Bdd<Type>>(expression.getOperand()->accept(*this));
switch (expression.getOperatorType()) {
case storm::expressions::UnaryBooleanFunctionExpression::OperatorType::Not:
@ -138,7 +146,7 @@ namespace storm {
break;
}
return result.template toAdd<ValueType>();
return result;
}
template<storm::dd::DdType Type, typename ValueType>
@ -164,7 +172,7 @@ namespace storm {
template<storm::dd::DdType Type, typename ValueType>
boost::any AddExpressionAdapter<Type, ValueType>::visit(storm::expressions::BooleanLiteralExpression const& expression) {
return ddManager->getConstant(static_cast<ValueType>(expression.getValue()));
return expression.getValue() ? ddManager->getBddOne() : ddManager->getBddZero();
}
template<storm::dd::DdType Type, typename ValueType>

26
src/builder/DdPrismModelBuilder.cpp

@ -118,7 +118,7 @@ namespace storm {
columnMetaVariables.insert(variablePair.second);
variableToColumnMetaVariableMap.emplace(integerVariable.getExpressionVariable(), variablePair.second);
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second)) * manager->getRange(variablePair.first).template toAdd<ValueType>() * manager->getRange(variablePair.second).template toAdd<ValueType>();
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second)).template toAdd<ValueType>() * manager->getRange(variablePair.first).template toAdd<ValueType>() * manager->getRange(variablePair.second).template toAdd<ValueType>();
variableToIdentityMap.emplace(integerVariable.getExpressionVariable(), variableIdentity);
rowColumnMetaVariablePairs.push_back(variablePair);
@ -135,7 +135,7 @@ namespace storm {
columnMetaVariables.insert(variablePair.second);
variableToColumnMetaVariableMap.emplace(booleanVariable.getExpressionVariable(), variablePair.second);
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second));
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second)).template toAdd<ValueType>();
variableToIdentityMap.emplace(booleanVariable.getExpressionVariable(), variableIdentity);
rowColumnMetaVariablePairs.push_back(variablePair);
@ -159,7 +159,7 @@ namespace storm {
columnMetaVariables.insert(variablePair.second);
variableToColumnMetaVariableMap.emplace(integerVariable.getExpressionVariable(), variablePair.second);
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second)) * manager->getRange(variablePair.first).template toAdd<ValueType>() * manager->getRange(variablePair.second).template toAdd<ValueType>();
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second)).template toAdd<ValueType>() * manager->getRange(variablePair.first).template toAdd<ValueType>() * manager->getRange(variablePair.second).template toAdd<ValueType>();
variableToIdentityMap.emplace(integerVariable.getExpressionVariable(), variableIdentity);
moduleIdentity *= variableIdentity;
moduleRange *= manager->getRange(variablePair.first).template toAdd<ValueType>();
@ -176,7 +176,7 @@ namespace storm {
columnMetaVariables.insert(variablePair.second);
variableToColumnMetaVariableMap.emplace(booleanVariable.getExpressionVariable(), variablePair.second);
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second)) * manager->getRange(variablePair.first).template toAdd<ValueType>() * manager->getRange(variablePair.second).template toAdd<ValueType>();
storm::dd::Add<Type, ValueType> variableIdentity = manager->template getIdentity<ValueType>(variablePair.first).equals(manager->template getIdentity<ValueType>(variablePair.second)).template toAdd<ValueType>() * manager->getRange(variablePair.first).template toAdd<ValueType>() * manager->getRange(variablePair.second).template toAdd<ValueType>();
variableToIdentityMap.emplace(booleanVariable.getExpressionVariable(), variableIdentity);
moduleIdentity *= variableIdentity;
moduleRange *= manager->getRange(variablePair.first).template toAdd<ValueType>();
@ -334,7 +334,7 @@ namespace storm {
storm::dd::Add<Type, ValueType> result = updateExpression * guard;
// Combine the variable and the assigned expression.
result = result.equals(writtenVariable);
result = result.equals(writtenVariable).template toAdd<ValueType>();
result *= guard;
// Restrict the transitions to the range of the written variable.
@ -572,9 +572,9 @@ namespace storm {
// Calculate number of required variables to encode the nondeterminism.
uint_fast64_t numberOfBinaryVariables = static_cast<uint_fast64_t>(std::ceil(storm::utility::math::log2(maxChoices)));
storm::dd::Add<Type, ValueType> equalsNumberOfChoicesDd = generationInfo.manager->template getAddZero<ValueType>();
storm::dd::Bdd<Type> equalsNumberOfChoicesDd;
std::vector<storm::dd::Add<Type, ValueType>> choiceDds(maxChoices, generationInfo.manager->template getAddZero<ValueType>());
std::vector<storm::dd::Add<Type, ValueType>> remainingDds(maxChoices, generationInfo.manager->template getAddZero<ValueType>());
std::vector<storm::dd::Bdd<Type>> remainingDds(maxChoices, generationInfo.manager->getBddZero());
for (uint_fast64_t currentChoices = 1; currentChoices <= maxChoices; ++currentChoices) {
// Determine the set of states with exactly currentChoices choices.
@ -594,7 +594,7 @@ namespace storm {
for (std::size_t j = 0; j < commandDds.size(); ++j) {
// Check if command guard overlaps with equalsNumberOfChoicesDd. That is, there are states with exactly currentChoices
// choices such that one outgoing choice is given by the j-th command.
storm::dd::Add<Type, ValueType> guardChoicesIntersection = commandDds[j].guardDd * equalsNumberOfChoicesDd;
storm::dd::Bdd<Type> guardChoicesIntersection = commandDds[j].guardDd.toBdd() && equalsNumberOfChoicesDd;
// If there is no such state, continue with the next command.
if (guardChoicesIntersection.isZero()) {
@ -604,19 +604,19 @@ namespace storm {
// Split the currentChoices nondeterministic choices.
for (uint_fast64_t k = 0; k < currentChoices; ++k) {
// Calculate the overlapping part of command guard and the remaining DD.
storm::dd::Add<Type, ValueType> remainingGuardChoicesIntersection = guardChoicesIntersection * remainingDds[k];
storm::dd::Bdd<Type> remainingGuardChoicesIntersection = guardChoicesIntersection && remainingDds[k];
// Check if we can add some overlapping parts to the current index.
if (!remainingGuardChoicesIntersection.isZero()) {
// Remove overlapping parts from the remaining DD.
remainingDds[k] = remainingDds[k] * !remainingGuardChoicesIntersection;
remainingDds[k] = remainingDds[k] && !remainingGuardChoicesIntersection;
// Combine the overlapping part of the guard with command updates and add it to the resulting DD.
choiceDds[k] += remainingGuardChoicesIntersection * commandDds[j].transitionsDd;
choiceDds[k] += remainingGuardChoicesIntersection.template toAdd<ValueType>() * commandDds[j].transitionsDd;
}
// Remove overlapping parts from the command guard DD
guardChoicesIntersection = guardChoicesIntersection * !remainingGuardChoicesIntersection;
guardChoicesIntersection = guardChoicesIntersection && !remainingGuardChoicesIntersection;
// If the guard DD has become equivalent to false, we can stop here.
if (guardChoicesIntersection.isZero()) {
@ -631,7 +631,7 @@ namespace storm {
}
// Delete currentChoices out of overlapping DD
sumOfGuards = sumOfGuards * !equalsNumberOfChoicesDd;
sumOfGuards = sumOfGuards * (!equalsNumberOfChoicesDd).template toAdd<ValueType>();
}
return ActionDecisionDiagram(allGuards, allCommands, assignedGlobalVariables, nondeterminismVariableOffset + numberOfBinaryVariables);

2
src/models/symbolic/Model.cpp

@ -123,7 +123,7 @@ namespace storm {
storm::dd::Add<Type, ValueType> Model<Type, ValueType>::getRowColumnIdentity() const {
storm::dd::Add<Type, ValueType> result = this->getManager().template getAddOne<ValueType>();
for (auto const& pair : this->getRowColumnMetaVariablePairs()) {
result *= this->getManager().template getIdentity<ValueType>(pair.first).equals(this->getManager().template getIdentity<ValueType>(pair.second));
result *= this->getManager().template getIdentity<ValueType>(pair.first).equals(this->getManager().template getIdentity<ValueType>(pair.second)).template toAdd<ValueType>();
result *= this->getManager().getRange(pair.first).template toAdd<ValueType>() * this->getManager().getRange(pair.second).template toAdd<ValueType>();
}
return result;

2
src/solver/SymbolicLinearEquationSolver.cpp

@ -30,7 +30,7 @@ namespace storm {
// Start by computing the Jacobi decomposition of the matrix A.
storm::dd::Add<DdType, ValueType> diagonal = x.getDdManager()->template getAddOne<ValueType>();
for (auto const& pair : rowColumnMetaVariablePairs) {
diagonal *= x.getDdManager()->template getIdentity<ValueType>(pair.first).equals(x.getDdManager()->template getIdentity<ValueType>(pair.second));
diagonal *= x.getDdManager()->template getIdentity<ValueType>(pair.first).equals(x.getDdManager()->template getIdentity<ValueType>(pair.second)).template toAdd<ValueType>();
diagonal *= x.getDdManager()->getRange(pair.first).template toAdd<ValueType>() * x.getDdManager()->getRange(pair.second).template toAdd<ValueType>();
}
diagonal *= allRows.template toAdd<ValueType>();

29
src/storage/dd/Add.cpp

@ -107,35 +107,35 @@ namespace storm {
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::equals(Add<LibraryType, ValueType> const& other) const {
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.equals(other), Dd<LibraryType>::joinMetaVariables(*this, other));
Bdd<LibraryType> Add<LibraryType, ValueType>::equals(Add<LibraryType, ValueType> const& other) const {
return Bdd<LibraryType>(this->getDdManager(), internalAdd.equals(other), Dd<LibraryType>::joinMetaVariables(*this, other));
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::notEquals(Add<LibraryType, ValueType> const& other) const {
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.notEquals(other), Dd<LibraryType>::joinMetaVariables(*this, other));
Bdd<LibraryType> Add<LibraryType, ValueType>::notEquals(Add<LibraryType, ValueType> const& other) const {
return Bdd<LibraryType>(this->getDdManager(), internalAdd.notEquals(other), Dd<LibraryType>::joinMetaVariables(*this, other));
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::less(Add<LibraryType, ValueType> const& other) const {
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.less(other), Dd<LibraryType>::joinMetaVariables(*this, other));
Bdd<LibraryType> Add<LibraryType, ValueType>::less(Add<LibraryType, ValueType> const& other) const {
return Bdd<LibraryType>(this->getDdManager(), internalAdd.less(other), Dd<LibraryType>::joinMetaVariables(*this, other));
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::lessOrEqual(Add<LibraryType, ValueType> const& other) const {
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.lessOrEqual(other), Dd<LibraryType>::joinMetaVariables(*this, other));
Bdd<LibraryType> Add<LibraryType, ValueType>::lessOrEqual(Add<LibraryType, ValueType> const& other) const {
return Bdd<LibraryType>(this->getDdManager(), internalAdd.lessOrEqual(other), Dd<LibraryType>::joinMetaVariables(*this, other));
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::greater(Add<LibraryType, ValueType> const& other) const {
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.greater(other), Dd<LibraryType>::joinMetaVariables(*this, other));
Bdd<LibraryType> Add<LibraryType, ValueType>::greater(Add<LibraryType, ValueType> const& other) const {
return Bdd<LibraryType>(this->getDdManager(), internalAdd.greater(other), Dd<LibraryType>::joinMetaVariables(*this, other));
}
template<DdType LibraryType, typename ValueType>
Add<LibraryType, ValueType> Add<LibraryType, ValueType>::greaterOrEqual(Add<LibraryType, ValueType> const& other) const {
return Add<LibraryType, ValueType>(this->getDdManager(), internalAdd.greaterOrEqual(other), Dd<LibraryType>::joinMetaVariables(*this, other));
Bdd<LibraryType> Add<LibraryType, ValueType>::greaterOrEqual(Add<LibraryType, ValueType> const& other) const {
return Bdd<LibraryType>(this->getDdManager(), internalAdd.greaterOrEqual(other), Dd<LibraryType>::joinMetaVariables(*this, other));
}
@ -266,7 +266,7 @@ namespace storm {
template<DdType LibraryType, typename ValueType>
Bdd<LibraryType> Add<LibraryType, ValueType>::notZero() const {
return this->toBdd();
return Bdd<LibraryType>(this->getDdManager(), internalAdd.notZero(), this->getContainedMetaVariables());
}
template<DdType LibraryType, typename ValueType>
@ -288,7 +288,6 @@ namespace storm {
uint_fast64_t Add<LibraryType, ValueType>::getNonZeroCount() const {
std::size_t numberOfDdVariables = 0;
if (LibraryType == DdType::CUDD) {
std::size_t numberOfDdVariables = 0;
for (auto const& metaVariable : this->getContainedMetaVariables()) {
numberOfDdVariables += this->getDdManager()->getMetaVariable(metaVariable).getNumberOfDdVariables();
}
@ -775,7 +774,7 @@ namespace storm {
template<DdType LibraryType, typename ValueType>
Bdd<LibraryType> Add<LibraryType, ValueType>::toBdd() const {
return Bdd<LibraryType>(this->getDdManager(), internalAdd.toBdd(), this->getContainedMetaVariables());
return this->notZero();
}
template<DdType LibraryType, typename ValueType>

12
src/storage/dd/Add.h

@ -178,7 +178,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
Add<LibraryType, ValueType> equals(Add<LibraryType, ValueType> const& other) const;
Bdd<LibraryType> equals(Add<LibraryType, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one that have distinct function values.
@ -186,7 +186,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
Add<LibraryType, ValueType> notEquals(Add<LibraryType, ValueType> const& other) const;
Bdd<LibraryType> notEquals(Add<LibraryType, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are less
@ -195,7 +195,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
Add<LibraryType, ValueType> less(Add<LibraryType, ValueType> const& other) const;
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 less or
@ -204,7 +204,7 @@ namespace storm {
* @param other The DD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
Add<LibraryType, ValueType> lessOrEqual(Add<LibraryType, ValueType> const& other) const;
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 greater
@ -213,7 +213,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
Add<LibraryType, ValueType> greater(Add<LibraryType, ValueType> const& other) const;
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 greater
@ -222,7 +222,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
Add<LibraryType, ValueType> greaterOrEqual(Add<LibraryType, ValueType> const& other) const;
Bdd<LibraryType> greaterOrEqual(Add<LibraryType, ValueType> const& other) const;
/*!
* Retrieves the function that represents the current ADD to the power of the given ADD.

1
src/storage/dd/Bdd.cpp

@ -189,7 +189,6 @@ namespace storm {
uint_fast64_t Bdd<LibraryType>::getNonZeroCount() const {
std::size_t numberOfDdVariables = 0;
if (LibraryType == DdType::CUDD) {
std::size_t numberOfDdVariables = 0;
for (auto const& metaVariable : this->getContainedMetaVariables()) {
numberOfDdVariables += this->getDdManager()->getMetaVariable(metaVariable).getNumberOfDdVariables();
}

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

@ -93,33 +93,33 @@ namespace storm {
}
template<typename ValueType>
InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::equals(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().Equals(other.getCuddAdd()));
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::equals(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().Equals(other.getCuddAdd()).BddPattern());
}
template<typename ValueType>
InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::notEquals(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().NotEquals(other.getCuddAdd()));
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::notEquals(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().NotEquals(other.getCuddAdd()).BddPattern());
}
template<typename ValueType>
InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::less(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().LessThan(other.getCuddAdd()));
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::less(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().LessThan(other.getCuddAdd()).BddPattern());
}
template<typename ValueType>
InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::lessOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().LessThanOrEqual(other.getCuddAdd()));
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::lessOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().LessThanOrEqual(other.getCuddAdd()).BddPattern());
}
template<typename ValueType>
InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::greater(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().GreaterThan(other.getCuddAdd()));
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::greater(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().GreaterThan(other.getCuddAdd()).BddPattern());
}
template<typename ValueType>
InternalAdd<DdType::CUDD, ValueType> InternalAdd<DdType::CUDD, ValueType>::greaterOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalAdd<DdType::CUDD, ValueType>(ddManager, this->getCuddAdd().GreaterThanOrEqual(other.getCuddAdd()));
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::greaterOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const {
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().GreaterThanOrEqual(other.getCuddAdd()).BddPattern());
}
template<typename ValueType>
@ -226,7 +226,7 @@ namespace storm {
template<typename ValueType>
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::notZero() const {
return this->toBdd();
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().BddPattern());
}
template<typename ValueType>
@ -271,11 +271,6 @@ namespace storm {
return static_cast<double>(Cudd_V(constantMaxAdd.getNode()));
}
template<typename ValueType>
InternalBdd<DdType::CUDD> InternalAdd<DdType::CUDD, ValueType>::toBdd() const {
return InternalBdd<DdType::CUDD>(ddManager, this->getCuddAdd().BddPattern());
}
template<typename ValueType>
bool InternalAdd<DdType::CUDD, ValueType>::isOne() const {
return this->getCuddAdd().IsOne();

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

@ -178,7 +178,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::CUDD, ValueType> equals(InternalAdd<DdType::CUDD, ValueType> const& other) const;
InternalBdd<DdType::CUDD> equals(InternalAdd<DdType::CUDD, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one that have distinct function values.
@ -186,7 +186,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::CUDD, ValueType> notEquals(InternalAdd<DdType::CUDD, ValueType> const& other) const;
InternalBdd<DdType::CUDD> notEquals(InternalAdd<DdType::CUDD, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are less
@ -195,7 +195,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::CUDD, ValueType> less(InternalAdd<DdType::CUDD, ValueType> const& other) const;
InternalBdd<DdType::CUDD> less(InternalAdd<DdType::CUDD, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are less or
@ -204,7 +204,7 @@ namespace storm {
* @param other The DD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::CUDD, ValueType> lessOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const;
InternalBdd<DdType::CUDD> lessOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are greater
@ -213,7 +213,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::CUDD, ValueType> greater(InternalAdd<DdType::CUDD, ValueType> const& other) const;
InternalBdd<DdType::CUDD> greater(InternalAdd<DdType::CUDD, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are greater
@ -222,7 +222,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::CUDD, ValueType> greaterOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const;
InternalBdd<DdType::CUDD> greaterOrEqual(InternalAdd<DdType::CUDD, ValueType> const& other) const;
/*!
* Retrieves the function that represents the current ADD to the power of the given ADD.
@ -439,14 +439,6 @@ namespace storm {
*/
ValueType getMax() const;
/*!
* Converts the ADD to a BDD by mapping all values unequal to zero to 1. This effectively does the same as
* a call to notZero().
*
* @return The corresponding BDD.
*/
InternalBdd<DdType::CUDD> toBdd() const;
/*!
* Retrieves whether this ADD represents the constant one function.
*

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

@ -71,47 +71,48 @@ namespace storm {
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType>& InternalAdd<DdType::Sylvan, ValueType>::operator-=(InternalAdd<DdType::Sylvan, ValueType> const& other) {
this->sylvanMtbdd = this->sylvanMtbdd.Plus(other.sylvanMtbdd.Negate());
this->sylvanMtbdd = this->sylvanMtbdd.Minus(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.Divide(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.Divide(other.sylvanMtbdd);
return *this;
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::equals(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::equals(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::notEquals(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::notEquals(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::less(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::less(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::lessOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::lessOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::greater(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::greater(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
InternalAdd<DdType::Sylvan, ValueType> InternalAdd<DdType::Sylvan, ValueType>::greaterOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::greaterOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
@ -206,7 +207,7 @@ namespace storm {
template<typename ValueType>
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::notZero() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
return InternalBdd<DdType::Sylvan>(ddManager, this->sylvanMtbdd.NotZero());
}
template<typename ValueType>
@ -249,11 +250,6 @@ namespace storm {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
InternalBdd<DdType::Sylvan> InternalAdd<DdType::Sylvan, ValueType>::toBdd() const {
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Not yet implemented.");
}
template<typename ValueType>
bool InternalAdd<DdType::Sylvan, ValueType>::isOne() const {
return *this == ddManager->getAddOne<ValueType>();

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

@ -178,7 +178,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::Sylvan, ValueType> equals(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
InternalBdd<DdType::Sylvan> equals(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one that have distinct function values.
@ -186,7 +186,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::Sylvan, ValueType> notEquals(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
InternalBdd<DdType::Sylvan> notEquals(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are less
@ -195,7 +195,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::Sylvan, ValueType> less(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
InternalBdd<DdType::Sylvan> less(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are less or
@ -204,7 +204,7 @@ namespace storm {
* @param other The DD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::Sylvan, ValueType> lessOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
InternalBdd<DdType::Sylvan> lessOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are greater
@ -213,7 +213,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::Sylvan, ValueType> greater(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
InternalBdd<DdType::Sylvan> greater(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
/*!
* Retrieves the function that maps all evaluations to one whose function value in the first ADD are greater
@ -222,7 +222,7 @@ namespace storm {
* @param other The ADD with which to perform the operation.
* @return The resulting function represented as an ADD.
*/
InternalAdd<DdType::Sylvan, ValueType> greaterOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
InternalBdd<DdType::Sylvan> greaterOrEqual(InternalAdd<DdType::Sylvan, ValueType> const& other) const;
/*!
* Retrieves the function that represents the current ADD to the power of the given ADD.
@ -439,14 +439,6 @@ namespace storm {
*/
ValueType getMax() const;
/*!
* Converts the ADD to a BDD by mapping all values unequal to zero to 1. This effectively does the same as
* a call to notZero().
*
* @return The corresponding BDD.
*/
InternalBdd<DdType::Sylvan> toBdd() const;
/*!
* Retrieves whether this ADD represents the constant one function.
*

30
test/functional/storage/CuddDdTest.cpp

@ -145,26 +145,26 @@ TEST(CuddDd, OperatorTest) {
dd1 = manager->template getIdentity<double>(x.first);
dd2 = manager->template getConstant<double>(5);
dd3 = dd1.equals(dd2);
dd3 = dd1.equals(dd2).template toAdd<double>();
EXPECT_EQ(1ul, dd3.getNonZeroCount());
storm::dd::Add<storm::dd::DdType::CUDD, double> dd4 = dd1.notEquals(dd2);
storm::dd::Add<storm::dd::DdType::CUDD, double> dd4 = dd1.notEquals(dd2).template toAdd<double>();
EXPECT_TRUE(dd4.toBdd() == !dd3.toBdd());
dd3 = dd1.less(dd2);
dd3 = dd1.less(dd2).template toAdd<double>();
EXPECT_EQ(11ul, dd3.getNonZeroCount());
dd3 = dd1.lessOrEqual(dd2);
dd3 = dd1.lessOrEqual(dd2).template toAdd<double>();
EXPECT_EQ(12ul, dd3.getNonZeroCount());
dd3 = dd1.greater(dd2);
dd3 = dd1.greater(dd2).template toAdd<double>();
EXPECT_EQ(4ul, dd3.getNonZeroCount());
dd3 = dd1.greaterOrEqual(dd2);
dd3 = dd1.greaterOrEqual(dd2).template toAdd<double>();
EXPECT_EQ(5ul, dd3.getNonZeroCount());
dd3 = (manager->getEncoding(x.first, 2).template toAdd<double>()).ite(dd2, dd1);
dd4 = dd3.less(dd2);
dd4 = dd3.less(dd2).template toAdd<double>();
EXPECT_EQ(10ul, dd4.getNonZeroCount());
dd4 = dd3.minimum(dd1);
@ -192,7 +192,7 @@ TEST(CuddDd, AbstractionTest) {
dd1 = manager->template getIdentity<double>(x.first);
dd2 = manager->template getConstant<double>(5);
dd3 = dd1.equals(dd2);
dd3 = dd1.equals(dd2).template toAdd<double>();
storm::dd::Bdd<storm::dd::DdType::CUDD> dd3Bdd = dd3.toBdd();
EXPECT_EQ(1ul, dd3Bdd.getNonZeroCount());
ASSERT_THROW(dd3Bdd = dd3Bdd.existsAbstract({x.second}), storm::exceptions::InvalidArgumentException);
@ -200,28 +200,28 @@ TEST(CuddDd, AbstractionTest) {
EXPECT_EQ(1ul, dd3Bdd.getNonZeroCount());
EXPECT_EQ(1, dd3Bdd.template toAdd<double>().getMax());
dd3 = dd1.equals(dd2);
dd3 = dd1.equals(dd2).template toAdd<double>();
dd3 *= manager->template getConstant<double>(3);
EXPECT_EQ(1ul, dd3.getNonZeroCount());
ASSERT_THROW(dd3Bdd = dd3.toBdd().existsAbstract({x.second}), storm::exceptions::InvalidArgumentException);
ASSERT_NO_THROW(dd3Bdd = dd3.toBdd().existsAbstract({x.first}));
EXPECT_TRUE(dd3Bdd.isOne());
dd3 = dd1.equals(dd2);
dd3 = dd1.equals(dd2).template toAdd<double>();
dd3 *= manager->template getConstant<double>(3);
ASSERT_THROW(dd3 = dd3.sumAbstract({x.second}), storm::exceptions::InvalidArgumentException);
ASSERT_NO_THROW(dd3 = dd3.sumAbstract({x.first}));
EXPECT_EQ(1ul, dd3.getNonZeroCount());
EXPECT_EQ(3, dd3.getMax());
dd3 = dd1.equals(dd2);
dd3 = dd1.equals(dd2).template toAdd<double>();
dd3 *= manager->template getConstant<double>(3);
ASSERT_THROW(dd3 = dd3.minAbstract({x.second}), storm::exceptions::InvalidArgumentException);
ASSERT_NO_THROW(dd3 = dd3.minAbstract({x.first}));
EXPECT_EQ(0ul, dd3.getNonZeroCount());
EXPECT_EQ(0, dd3.getMax());
dd3 = dd1.equals(dd2);
dd3 = dd1.equals(dd2).template toAdd<double>();
dd3 *= manager->template getConstant<double>(3);
ASSERT_THROW(dd3 = dd3.maxAbstract({x.second}), storm::exceptions::InvalidArgumentException);
ASSERT_NO_THROW(dd3 = dd3.maxAbstract({x.first}));
@ -247,7 +247,7 @@ TEST(CuddDd, MultiplyMatrixTest) {
std::shared_ptr<storm::dd::DdManager<storm::dd::DdType::CUDD>> manager(new storm::dd::DdManager<storm::dd::DdType::CUDD>());
std::pair<storm::expressions::Variable, storm::expressions::Variable> x = manager->addMetaVariable("x", 1, 9);
storm::dd::Add<storm::dd::DdType::CUDD, double> dd1 = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second));
storm::dd::Add<storm::dd::DdType::CUDD, double> dd1 = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)).template toAdd<double>();
storm::dd::Add<storm::dd::DdType::CUDD, double> dd2 = manager->getRange(x.second).template toAdd<double>();
storm::dd::Add<storm::dd::DdType::CUDD, double> dd3;
dd1 *= manager->template getConstant<double>(2);
@ -336,7 +336,7 @@ TEST(CuddDd, AddOddTest) {
}
// Create a non-trivial matrix.
dd = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)) * manager->getRange(x.first).template toAdd<double>();
dd = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
dd += manager->getEncoding(x.first, 1).template toAdd<double>() * manager->getRange(x.second).template toAdd<double>() + manager->getEncoding(x.second, 1).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
// Create the ODDs.
@ -382,7 +382,7 @@ TEST(CuddDd, BddOddTest) {
storm::dd::Add<storm::dd::DdType::CUDD, double> vectorAdd = storm::dd::Add<storm::dd::DdType::CUDD, double>::fromVector(manager, ddAsVector, odd, {x.first});
// Create a non-trivial matrix.
dd = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)) * manager->getRange(x.first).template toAdd<double>();
dd = manager->template getIdentity<double>(x.first).equals(manager->template getIdentity<double>(x.second)).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
dd += manager->getEncoding(x.first, 1).template toAdd<double>() * manager->getRange(x.second).template toAdd<double>() + manager->getEncoding(x.second, 1).template toAdd<double>() * manager->getRange(x.first).template toAdd<double>();
// Create the ODDs.

Loading…
Cancel
Save