1#include "storm-config.h"
12TEST(ExpressionEvaluation, NaiveEvaluation) {
18 ASSERT_NO_THROW(x = manager->declareBooleanVariable(
"x"));
19 ASSERT_NO_THROW(y = manager->declareIntegerVariable(
"y"));
20 ASSERT_NO_THROW(z = manager->declareRationalVariable(
"z"));
28 for (int_fast64_t i = 0; i < 1000; ++i) {
34 for (int_fast64_t i = 0; i < 1000; ++i) {
35 double zValue = i /
static_cast<double>(10);
41TEST(ExpressionEvaluation, ExprTkEvaluation) {
47 ASSERT_NO_THROW(x = manager->declareBooleanVariable(
"x"));
48 ASSERT_NO_THROW(y = manager->declareIntegerVariable(
"y"));
49 ASSERT_NO_THROW(z = manager->declareRationalVariable(
"z"));
56 for (int_fast64_t i = 0; i < 1000; ++i) {
58 EXPECT_NEAR(8.5 + i, eval.
asRational(iteExpression), 1e-6);
62 for (int_fast64_t i = 0; i < 1000; ++i) {
63 double zValue = i /
static_cast<double>(10);
65 EXPECT_NEAR(3 * zValue, eval.
asRational(iteExpression), 1e-6);
69TEST(ExpressionEvaluation, NegativeModulo) {
73 std::unordered_map<std::string, storm::expressions::Expression> mapping;
82 auto positiveModulo = [](
int a,
int b) {
return a >= 0 ? a % b : (a % b) + b; };
84 int expectedInt = positiveModulo(-1, 4);
85 double expectedDouble(expectedInt);
88 int result1 = evaluator.
asInt(expr);
93 EXPECT_EQ(result1, expectedInt);
94 EXPECT_EQ(result2, expectedInt);
95 EXPECT_NEAR(result3, expectedDouble, 1e-6);
96 EXPECT_NEAR(result4, expectedDouble, 1e-6);
TEST(ExpressionEvaluation, NaiveEvaluation)
int_fast64_t evaluateAsInt(Valuation const *valuation=nullptr) const
Evaluates the expression under the valuation of variables given by the valuation and returns the resu...
double evaluateAsDouble(Valuation const *valuation=nullptr) const
Evaluates the expression under the valuation of variables given by the valuation and returns the resu...
This class is responsible for managing a set of typed variables and all expressions using these varia...
void setIntegerValue(storm::expressions::Variable const &variable, int_fast64_t value) override
void setBooleanValue(storm::expressions::Variable const &variable, bool value) override
int_fast64_t asInt(Expression const &expression) const override
void setRationalValue(storm::expressions::Variable const &variable, double value) override
double asRational(Expression const &expression) const override
A simple implementation of the valuation interface.
virtual void setIntegerValue(Variable const &integerVariable, int_fast64_t value) override
Sets the value of the given integer variable to the provided value.
virtual void setBooleanValue(Variable const &booleanVariable, bool value) override
Sets the value of the given boolean variable to the provided value.
virtual void setRationalValue(Variable const &rationalVariable, double value) override
Sets the value of the given boolean variable to the provided value.
void setIdentifierMapping(qi::symbols< char, storm::expressions::Expression > const *identifiers_)
Sets an identifier mapping that is used to determine valid variables in the expression.
storm::expressions::Expression createPowerModuloLogarithmExpression(storm::expressions::Expression const &e1, storm::expressions::OperatorType const &operatorType, storm::expressions::Expression const &e2, bool &pass) const
Expression ite(Expression const &condition, Expression const &thenExpression, Expression const &elseExpression)