Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ExpressionEvaluator.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_EXPRESSIONS_EXPRESSIONEVALUATOR_H_
2#define STORM_STORAGE_EXPRESSIONS_EXPRESSIONEVALUATOR_H_
3
4#include <unordered_map>
5
12
13namespace storm {
14namespace expressions {
15template<typename RationalType>
16class ExpressionEvaluator;
17
18template<>
23
24template<typename RationalType>
26 public:
28
29 void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
30 void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
31 void setRationalValue(storm::expressions::Variable const& variable, double value) override;
32
33 protected:
34 // A mapping of variables to their expressions.
35 std::unordered_map<storm::expressions::Variable, storm::expressions::Expression> variableToExpressionMap;
36};
37
38#ifdef STORM_HAVE_CARL
39template<>
40class ExpressionEvaluator<RationalNumber> : public ExprtkExpressionEvaluatorBase<RationalNumber> {
41 public:
43
44 void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
45 void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
46 void setRationalValue(storm::expressions::Variable const& variable, double value) override;
47
48 // Sets a rational value from a RationalNumber.
49 // Note: If an expression contains the given variable and is evaluated to int or bool, the value is internally considered as a double.
50 void setRationalValue(storm::expressions::Variable const& variable, storm::RationalNumber const& value);
51
52 RationalNumber asRational(Expression const& expression) const override;
53
54 private:
55 // A visitor that can be used to translate expressions to rational numbers.
56 mutable ToRationalNumberVisitor<RationalNumber> rationalNumberVisitor;
57};
58
59template<>
60class ExpressionEvaluator<RationalFunction> : public ExprtkExpressionEvaluatorBase<RationalFunction> {
61 public:
62 ExpressionEvaluator(storm::expressions::ExpressionManager const& manager);
63
64 void setBooleanValue(storm::expressions::Variable const& variable, bool value) override;
65 void setIntegerValue(storm::expressions::Variable const& variable, int_fast64_t value) override;
66 void setRationalValue(storm::expressions::Variable const& variable, double value) override;
67
68 // Sets a rational value from a RationalFunction. The function needs to be constant.
69 // Note: If an expression contains the given variable and is evaluated to int or bool, the value is internally considered as a double.
70 void setRationalValue(storm::expressions::Variable const& variable, storm::RationalFunction const& value);
71
72 RationalFunction asRational(Expression const& expression) const override;
73
74 private:
75 // A visitor that can be used to translate expressions to rational functions.
76 mutable ToRationalFunctionVisitor<RationalFunction> rationalFunctionVisitor;
77};
78#endif
79} // namespace expressions
80} // namespace storm
81
82#endif /* STORM_STORAGE_EXPRESSIONS_EXPRESSIONEVALUATOR_H_ */
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...
LabParser.cpp.
Definition cli.cpp:18