11#include "storm-config.h"
19template<storm::dd::DdType Type,
typename ValueType>
22 std::shared_ptr<std::map<storm::expressions::Variable, storm::expressions::Variable>>
const& variableMapping)
23 : ddManager(ddManager), variableMapping(variableMapping) {
27template<storm::dd::DdType Type,
typename ValueType>
30 return boost::any_cast<storm::dd::Bdd<Type>>(expression.
accept(*
this, boost::none)).
template toAdd<ValueType>();
32 return boost::any_cast<storm::dd::Add<Type, ValueType>>(expression.
accept(*
this, boost::none));
36template<storm::dd::DdType Type,
typename ValueType>
39 return boost::any_cast<storm::dd::Bdd<Type>>(expression.
accept(*
this, boost::none));
42template<storm::dd::DdType Type,
typename ValueType>
44 valueMapping[variable] = value;
47template<storm::dd::DdType Type,
typename ValueType>
53 return conditionDd.
ite(thenDd, elseDd);
58 return conditionDd.
ite(thenDd, elseDd);
62template<storm::dd::DdType Type,
typename ValueType>
70 result = (leftResult && rightResult);
73 result = (leftResult || rightResult);
76 result = (leftResult.
iff(rightResult));
79 result = (!leftResult || rightResult);
89template<storm::dd::DdType Type,
typename ValueType>
97 result = leftResult + rightResult;
100 result = leftResult - rightResult;
103 result = leftResult * rightResult;
106 result = leftResult / rightResult;
109 result = leftResult.
maximum(rightResult);
112 result = leftResult.
minimum(rightResult);
115 result = leftResult.
pow(rightResult);
118 result = leftResult.
mod(rightResult);
121 result = leftResult.
logxy(rightResult);
124 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Cannot translate expression containing power operator.");
130template<storm::dd::DdType Type,
typename ValueType>
138 result = leftResult.
equals(rightResult);
141 result = leftResult.
notEquals(rightResult);
144 result = leftResult.
less(rightResult);
150 result = leftResult.
greater(rightResult);
160template<storm::dd::DdType Type,
typename ValueType>
162 auto valueIt = valueMapping.find(expression.
getVariable());
163 if (valueIt != valueMapping.end()) {
164 return ddManager->getConstant(valueIt->second);
166 auto const& variablePair = variableMapping->find(expression.
getVariable());
167 STORM_LOG_THROW(variablePair != variableMapping->end(), storm::exceptions::InvalidArgumentException,
168 "Cannot translate the given expression, because it contains the variable '" << expression.
getVariableName()
169 <<
"' for which no DD counterpart is known.");
171 return ddManager->template getIdentity<ValueType>(variablePair->second).toBdd();
173 return ddManager->template getIdentity<ValueType>(variablePair->second);
178template<storm::dd::DdType Type,
typename ValueType>
191template<storm::dd::DdType Type,
typename ValueType>
200 result = result.
floor();
203 result = result.
ceil();
206 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Cannot translate expression containing floor/ceil operator.");
212template<storm::dd::DdType Type,
typename ValueType>
214 return expression.
getValue() ? ddManager->getBddOne() : ddManager->getBddZero();
217template<storm::dd::DdType Type,
typename ValueType>
219 return ddManager->getConstant(storm::utility::convertNumber<ValueType>(expression.
getValue()));
222template<storm::dd::DdType Type,
typename ValueType>
224 return ddManager->getConstant(storm::utility::convertNumber<ValueType>(expression.
getValue()));
231#ifdef STORM_HAVE_CARL
storm::dd::Add< Type, ValueType > translateExpression(storm::expressions::Expression const &expression)
storm::dd::Bdd< Type > translateBooleanExpression(storm::expressions::Expression const &expression)
virtual boost::any visit(storm::expressions::IfThenElseExpression const &expression, boost::any const &data) override
void setValue(storm::expressions::Variable const &variable, ValueType const &value)
AddExpressionAdapter(std::shared_ptr< storm::dd::DdManager< Type > > ddManager, std::shared_ptr< std::map< storm::expressions::Variable, storm::expressions::Variable > > const &variableMapping)
Add< LibraryType, ValueType > pow(Add< LibraryType, ValueType > const &other) const
Retrieves the function that represents the current ADD to the power of the given ADD.
Bdd< LibraryType > equals(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one that have identical function values.
Add< LibraryType, ValueType > floor() const
Retrieves the function that floors all values in the current ADD.
Bdd< LibraryType > lessOrEqual(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are les...
Add< LibraryType, ValueType > logxy(Add< LibraryType, ValueType > const &other) const
Retrieves the function that represents the logarithm of the current ADD to the bases given by the sec...
Add< LibraryType, ValueType > minimum(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to the minimum of the function values of the two ADD...
Bdd< LibraryType > greater(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are gre...
Add< LibraryType, ValueType > maximum(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to the maximum of the function values of the two ADD...
Bdd< LibraryType > greaterOrEqual(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are gre...
Add< LibraryType, ValueType > mod(Add< LibraryType, ValueType > const &other) const
Retrieves the function that represents the current ADD modulo the given ADD.
Bdd< LibraryType > notEquals(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one that have distinct function values.
Add< LibraryType, ValueType > ceil() const
Retrieves the function that ceils all values in the current ADD.
Bdd< LibraryType > less(Add< LibraryType, ValueType > const &other) const
Retrieves the function that maps all evaluations to one whose function value in the first ADD are les...
Bdd< LibraryType > ite(Bdd< LibraryType > const &thenBdd, Bdd< LibraryType > const &elseBdd) const
Performs an if-then-else with the given operands, i.e.
Bdd< LibraryType > iff(Bdd< LibraryType > const &other) const
Performs a logical iff of the current and the given BDD.
Bdd< LibraryType > exclusiveOr(Bdd< LibraryType > const &other) const
Performs a logical exclusive-or of the current and the given BDD.
bool hasBooleanType() const
Retrieves whether the expression has a boolean type.
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
std::shared_ptr< BaseExpression const > const & getSecondOperand() const
Retrieves the second operand of the expression.
std::shared_ptr< BaseExpression const > const & getFirstOperand() const
Retrieves the first operand of the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
RelationType getRelationType() const
Retrieves the relation associated with the expression.
bool getValue() const
Retrieves the value of the boolean literal.
bool hasBooleanType() const
Retrieves whether the expression has a boolean return type.
boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const
Accepts the given visitor.
std::shared_ptr< BaseExpression const > getElseExpression() const
Retrieves the else expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getCondition() const
Retrieves the condition expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getThenExpression() const
Retrieves the then expression of the if-then-else expression.
int_fast64_t getValue() const
Retrieves the value of the integer literal.
storm::RationalNumber getValue() const
Retrieves the value of the double literal.
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
Variable const & getVariable() const
Retrieves the variable associated with this expression.
std::string const & getVariableName() const
Retrieves the name of the variable associated with this expression.
#define STORM_LOG_THROW(cond, exception, message)