Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
TranscendentalNumberLiteralExpression.cpp
Go to the documentation of this file.
2
6
8
9namespace storm {
10namespace expressions {
12 : BaseExpression(manager, manager.getTranscendentalNumberType()), value(value) {
13 // Intentionally left empty.
14}
15
17 switch (value) {
19 return M_PI;
20 break;
22 return std::exp(1.0);
23 break;
24 default:
25 STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Unexpected constant value.");
26 break;
27 }
28}
29
31 return true;
32}
33
34void TranscendentalNumberLiteralExpression::gatherVariables(std::set<storm::expressions::Variable>&) const {
35 // A constant value is not supposed to have any variable
36 return;
37}
38
39std::shared_ptr<BaseExpression const> TranscendentalNumberLiteralExpression::simplify() const {
40 // No further simplification for constant values
41 return this->shared_from_this();
42}
43
44boost::any TranscendentalNumberLiteralExpression::accept(ExpressionVisitor& visitor, boost::any const& data) const {
45 auto janiVisitor = dynamic_cast<JaniExpressionVisitor*>(&visitor);
46 STORM_LOG_ASSERT(janiVisitor != nullptr, "Visitor of jani expression should be of type JaniVisitor.");
47 STORM_LOG_THROW(janiVisitor != nullptr, storm::exceptions::UnexpectedException, "Visitor of jani expression should be of type JaniVisitor.");
48 return janiVisitor->visit(*this, data);
49}
50
54
56 switch (value) {
58 return "π";
60 return "e";
61 default:
62 STORM_LOG_THROW(false, storm::exceptions::UnexpectedException, "Unexpected constant value.");
63 }
64 return "";
65}
66
68 stream << asString();
69}
70} // namespace expressions
71} // namespace storm
The base class of all expression classes.
This class is responsible for managing a set of typed variables and all expressions using these varia...
virtual double evaluateAsDouble(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
TranscendentalNumber const & getTranscendentalNumber() const
Getter for the constant value stored by the object.
std::string asString() const
Get the Transcendental number as string, like in the Jani file (single character)
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const override
Accepts the given visitor by calling its visit method.
virtual std::shared_ptr< BaseExpression const > simplify() const override
Simplifies the expression according to some simple rules.
TranscendentalNumberLiteralExpression(ExpressionManager const &manager, TranscendentalNumber const &value)
Creates a unary expression with the given return type and operand.
virtual void gatherVariables(std::set< storm::expressions::Variable > &variables) const override
Retrieves the set of all variables that appear in the expression.
virtual void printToStream(std::ostream &stream) const override
Prints the expression to the given stream.
TranscendentalNumber
Enum class to represent the supported TranscendentalNumbers.
virtual bool isLiteral() const override
Retrieves whether the expression is a literal.
The base class of all valuations of variables.
Definition Valuation.h:16
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18