Storm
A Modern Probabilistic Model Checker
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InstantaneousRewardFormula.cpp
Go to the documentation of this file.
2#include <boost/any.hpp>
3#include <ostream>
4
6
10
11namespace storm {
12namespace logic {
14 : timeBoundType(timeBoundType), bound(bound) {
15 // Intentionally left empty.
16}
17
21
23 return true;
24}
25
26boost::any InstantaneousRewardFormula::accept(FormulaVisitor const& visitor, boost::any const& data) const {
27 return visitor.visit(*this, data);
28}
29
31 return timeBoundType;
32}
33
35 return timeBoundType == TimeBoundType::Steps;
36}
37
39 return timeBoundType == TimeBoundType::Time;
40}
41
43 return bound.hasIntegerType();
44}
45
49
50template<>
52 checkNoVariablesInBound(bound);
53 double value = bound.evaluateAsDouble();
54 STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number.");
55 return value;
56}
57
58template<>
60 checkNoVariablesInBound(bound);
61 int64_t value = bound.evaluateAsInt();
62 STORM_LOG_THROW(value >= 0, storm::exceptions::InvalidPropertyException, "Time-bound must not evaluate to negative number.");
63 return value;
64}
65
66void InstantaneousRewardFormula::gatherUsedVariables(std::set<storm::expressions::Variable>& usedVariables) const {
67 this->getBound().gatherVariables(usedVariables);
68}
69
70void InstantaneousRewardFormula::checkNoVariablesInBound(storm::expressions::Expression const& bound) {
71 STORM_LOG_THROW(!bound.containsVariables(), storm::exceptions::InvalidOperationException,
72 "Cannot evaluate time-instant '" << bound << "' as it contains undefined constants.");
73}
74
75std::ostream& InstantaneousRewardFormula::writeToStream(std::ostream& out, bool /* allowParentheses */) const {
76 // No parentheses necessary.
77 out << "I=" << this->getBound();
78 return out;
79}
80} // namespace logic
81} // namespace storm
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...
bool containsVariables() const
Retrieves whether the expression contains a variable.
bool hasIntegerType() const
Retrieves whether the expression has an integral return type.
void gatherVariables(std::set< storm::expressions::Variable > &variables) const
Retrieves the set of all variables that appear in the expression.
virtual boost::any visit(AtomicExpressionFormula const &f, boost::any const &data) const =0
virtual void gatherUsedVariables(std::set< storm::expressions::Variable > &usedVariables) const override
virtual boost::any accept(FormulaVisitor const &visitor, boost::any const &data) const override
virtual bool isInstantaneousRewardFormula() const override
virtual std::ostream & writeToStream(std::ostream &out, bool allowParentheses=false) const override
Writes the forumla to the given output stream.
InstantaneousRewardFormula(storm::expressions::Expression const &bound, TimeBoundType const &timeBoundType=TimeBoundType::Time)
storm::expressions::Expression const & getBound() const
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18