10TEST(ExpressionEvaluation, NaiveEvaluation) {
16 ASSERT_NO_THROW(x = manager->declareBooleanVariable(
"x"));
17 ASSERT_NO_THROW(y = manager->declareIntegerVariable(
"y"));
18 ASSERT_NO_THROW(z = manager->declareRationalVariable(
"z"));
26 for (int_fast64_t i = 0; i < 1000; ++i) {
32 for (int_fast64_t i = 0; i < 1000; ++i) {
33 double zValue = i /
static_cast<double>(10);
39TEST(ExpressionEvaluation, ExprTkEvaluation) {
45 ASSERT_NO_THROW(x = manager->declareBooleanVariable(
"x"));
46 ASSERT_NO_THROW(y = manager->declareIntegerVariable(
"y"));
47 ASSERT_NO_THROW(z = manager->declareRationalVariable(
"z"));
54 for (int_fast64_t i = 0; i < 1000; ++i) {
56 EXPECT_NEAR(8.5 + i, eval.
asRational(iteExpression), 1e-6);
60 for (int_fast64_t i = 0; i < 1000; ++i) {
61 double zValue = i /
static_cast<double>(10);
63 EXPECT_NEAR(3 * zValue, eval.
asRational(iteExpression), 1e-6);
67TEST(ExpressionEvaluation, NegativeModulo) {
71 std::unordered_map<std::string, storm::expressions::Expression> mapping;
80 auto positiveModulo = [](
int a,
int b) {
return a >= 0 ? a % b : (a % b) + b; };
82 int expectedInt = positiveModulo(-1, 4);
83 double expectedDouble(expectedInt);
86 int result1 = evaluator.
asInt(expr);
91 EXPECT_EQ(result1, expectedInt);
92 EXPECT_EQ(result2, expectedInt);
93 EXPECT_NEAR(result3, expectedDouble, 1e-6);
94 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)