11template<
typename RationalFunctionType>
17template<
typename RationalFunctionType>
19 return boost::any_cast<RationalFunctionType>(expression.
accept(*
this, boost::none));
22template<
typename RationalFunctionType>
32template<
typename RationalFunctionType>
34 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Expression cannot be translated into a rational function.");
37template<
typename RationalFunctionType>
39 RationalFunctionType firstOperandAsRationalFunction = boost::any_cast<RationalFunctionType>(expression.
getFirstOperand()->accept(*
this, data));
40 RationalFunctionType secondOperandAsRationalFunction = boost::any_cast<RationalFunctionType>(expression.
getSecondOperand()->accept(*
this, data));
43 return firstOperandAsRationalFunction + secondOperandAsRationalFunction;
45 return firstOperandAsRationalFunction - secondOperandAsRationalFunction;
47 return firstOperandAsRationalFunction * secondOperandAsRationalFunction;
49 return firstOperandAsRationalFunction / secondOperandAsRationalFunction;
52 "Exponent of power operator must be an integer but is " << secondOperandAsRationalFunction <<
".");
53 auto exponentAsInteger = storm::utility::convertNumber<carl::sint>(secondOperandAsRationalFunction);
64template<
typename RationalFunctionType>
66 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Expression cannot be translated into a rational function.");
69template<
typename RationalFunctionType>
71 auto valueIt = valueMapping.find(expression.
getVariable());
72 if (valueIt != valueMapping.end()) {
73 return valueIt->second;
76 auto variablePair = variableToVariableMap.find(expression.
getVariable());
77 if (variablePair != variableToVariableMap.end()) {
78 return convertVariableToPolynomial(variablePair->second);
81 variableToVariableMap.emplace(expression.
getVariable(), carlVariable);
82 return convertVariableToPolynomial(carlVariable);
86template<
typename RationalFunctionType>
88 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Expression cannot be translated into a rational function.");
91template<
typename RationalFunctionType>
93 RationalFunctionType operandAsRationalFunction = boost::any_cast<RationalFunctionType>(expression.
getOperand()->accept(*
this, data));
96 return -operandAsRationalFunction;
98 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Expression cannot be translated into a rational function.");
103template<
typename RationalFunctionType>
105 STORM_LOG_THROW(
false, storm::exceptions::InvalidArgumentException,
"Expression cannot be translated into a rational function.");
108template<
typename RationalFunctionType>
110 return RationalFunctionType(storm::utility::convertNumber<storm::RationalFunction>(expression.
getValue()));
113template<
typename RationalFunctionType>
115 return storm::utility::convertNumber<storm::RationalFunction>(expression.
getValue());
118template<
typename RationalFunctionType>
120 valueMapping[variable] = value;
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.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
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.
ToRationalFunctionVisitor(ExpressionEvaluatorBase< RationalFunctionType > const &evaluator)
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data) override
RationalFunctionType toRationalFunction(Expression const &expression)
void setMapping(storm::expressions::Variable const &variable, RationalFunctionType const &value)
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_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
bool isInteger(ValueType const &number)
ValueType pow(ValueType const &value, int_fast64_t exponent)
RationalFunctionVariable createRFVariable(std::string const &name)
carl::Variable RationalFunctionVariable