14 std::shared_ptr<BaseExpression const>
const& firstOperand,
15 std::shared_ptr<BaseExpression const>
const& secondOperand,
RelationType relationType)
16 :
BinaryExpression(manager, type, firstOperand, secondOperand), relationType(relationType) {
48 double firstOperandEvaluated = this->
getFirstOperand()->evaluateAsDouble(valuation);
49 double secondOperandEvaluated = this->
getSecondOperand()->evaluateAsDouble(valuation);
53 result = firstOperandEvaluated == secondOperandEvaluated;
56 result = firstOperandEvaluated != secondOperandEvaluated;
59 result = firstOperandEvaluated > secondOperandEvaluated;
62 result = firstOperandEvaluated >= secondOperandEvaluated;
65 result = firstOperandEvaluated < secondOperandEvaluated;
68 result = firstOperandEvaluated <= secondOperandEvaluated;
75 std::shared_ptr<BaseExpression const> firstOperandSimplified = this->
getFirstOperand()->simplify();
76 std::shared_ptr<BaseExpression const> secondOperandSimplified = this->
getSecondOperand()->simplify();
78 if (firstOperandSimplified->isLiteral() && secondOperandSimplified->isLiteral()) {
79 storm::RationalNumber firstOperandEvaluation;
80 storm::RationalNumber secondOperandEvaluation;
82 if (firstOperandSimplified->hasIntegerType()) {
85 firstOperandEvaluation = firstOperandSimplified->evaluateAsRational();
87 if (secondOperandSimplified->hasIntegerType()) {
90 secondOperandEvaluation = secondOperandSimplified->evaluateAsRational();
93 bool truthValue =
false;
96 truthValue = firstOperandEvaluation == secondOperandEvaluation;
99 truthValue = firstOperandEvaluation != secondOperandEvaluation;
102 truthValue = firstOperandEvaluation > secondOperandEvaluation;
105 truthValue = firstOperandEvaluation >= secondOperandEvaluation;
108 truthValue = firstOperandEvaluation < secondOperandEvaluation;
111 truthValue = firstOperandEvaluation <= secondOperandEvaluation;
117 if (firstOperandSimplified.get() == this->getFirstOperand().get() && secondOperandSimplified.get() == this->getSecondOperand().get()) {
118 return this->shared_from_this();
120 return std::shared_ptr<BaseExpression>(
126 return visitor.
visit(*
this, data);
134 return this->relationType;
bool hasBooleanType() const
Retrieves whether the expression has a boolean type.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
Type const & getType() const
Retrieves the type of the expression.
std::shared_ptr< BaseExpression const > const & getSecondOperand() const
Retrieves the second operand of the expression.
std::shared_ptr< BaseExpression const > const & getFirstOperand() const
Retrieves the first operand of the expression.
BinaryExpression(ExpressionManager const &manager, Type const &type, std::shared_ptr< BaseExpression const > const &firstOperand, std::shared_ptr< BaseExpression const > const &secondOperand)
Constructs a binary expression with the given return type and operands.
RelationType getRelationType() const
Retrieves the relation associated with the expression.
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const override
Accepts the given visitor by calling its visit method.
virtual void printToStream(std::ostream &stream) const override
Prints the expression to the given stream.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
virtual bool isBinaryRelationExpression() const override
BinaryRelationExpression(ExpressionManager const &manager, Type const &type, std::shared_ptr< BaseExpression const > const &firstOperand, std::shared_ptr< BaseExpression const > const &secondOperand, RelationType relationType)
Creates a binary relation expression with the given return type, operands and relation type.
virtual std::shared_ptr< BaseExpression const > simplify() const override
Simplifies the expression according to some simple rules.
virtual bool evaluateAsBool(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
This class is responsible for managing a set of typed variables and all expressions using these varia...
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data)=0
The base class of all valuations of variables.
#define STORM_LOG_THROW(cond, exception, message)
RelationType
An enum type specifying the different relations applicable.
TargetType convertNumber(SourceType const &number)