Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ExpressionEvaluator.h
Go to the documentation of this file.
1#pragma once
2
3#include <unordered_map>
4
11
12namespace storm {
13namespace expressions {
14template<typename RationalType>
15class ExpressionEvaluator;
16
17template<>
22
23template<typename RationalType>
25 public:
27
28 void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
29 void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
30 void setRationalValue(storm::expressions::Variable const& variable, double value) override;
31
32 protected:
33 // A mapping of variables to their expressions.
34 std::unordered_map<storm::expressions::Variable, storm::expressions::Expression> variableToExpressionMap;
35};
36
37template<>
38class ExpressionEvaluator<RationalNumber> : public ExprtkExpressionEvaluatorBase<RationalNumber> {
39 public:
41
42 void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
43 void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
44 void setRationalValue(storm::expressions::Variable const& variable, double value) override;
45
46 // Sets a rational value from a RationalNumber.
47 // Note: If an expression contains the given variable and is evaluated to int or bool, the value is internally considered as a double.
48 void setRationalValue(storm::expressions::Variable const& variable, storm::RationalNumber const& value);
49
50 RationalNumber asRational(Expression const& expression) const override;
51
52 private:
53 // A visitor that can be used to translate expressions to rational numbers.
54 mutable ToRationalNumberVisitor<RationalNumber> rationalNumberVisitor;
55};
56
57template<>
59 public:
61
62 void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
63 void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
64 void setRationalValue(storm::expressions::Variable const& variable, double value) override;
65
66 // Sets a rational value from a RationalFunction. The function needs to be constant.
67 // Note: If an expression contains the given variable and is evaluated to int or bool, the value is internally considered as a double.
69
70 RationalFunction asRational(Expression const& expression) const override;
71
72 private:
73 // A visitor that can be used to translate expressions to rational functions.
74 mutable ToRationalFunctionVisitor<RationalFunction> rationalFunctionVisitor;
75};
76} // namespace expressions
77} // namespace storm
RationalFunction asRational(Expression const &expression) const override
ExpressionEvaluator(storm::expressions::ExpressionManager const &manager)
void setRationalValue(storm::expressions::Variable const &variable, double value) override
void setRationalValue(storm::expressions::Variable const &variable, storm::RationalFunction const &value)
void setBooleanValue(storm::expressions::Variable const &variable, bool value) override
void setIntegerValue(storm::expressions::Variable const &variable, int_fast64_t value) override
void setBooleanValue(storm::expressions::Variable const &variable, bool value) override
void setIntegerValue(storm::expressions::Variable const &variable, int_fast64_t value) override
void setRationalValue(storm::expressions::Variable const &variable, double value) override
RationalNumber asRational(Expression const &expression) const override
void setRationalValue(storm::expressions::Variable const &variable, storm::RationalNumber const &value)
ExpressionEvaluator(storm::expressions::ExpressionManager const &manager)
void setRationalValue(storm::expressions::Variable const &variable, double value) override
void setBooleanValue(storm::expressions::Variable const &variable, bool value) override
std::unordered_map< storm::expressions::Variable, storm::expressions::Expression > variableToExpressionMap
void setIntegerValue(storm::expressions::Variable const &variable, int_fast64_t value) override
This class is responsible for managing a set of typed variables and all expressions using these varia...