diff --git a/src/storm/storage/expressions/Expression.cpp b/src/storm/storage/expressions/Expression.cpp index 97e7046ab..7f204d0c1 100644 --- a/src/storm/storage/expressions/Expression.cpp +++ b/src/storm/storage/expressions/Expression.cpp @@ -59,6 +59,10 @@ namespace storm { return this->getBaseExpression().evaluateAsDouble(valuation); } + storm::RationalNumber Expression::evaluateAsRational() const { + return this->getBaseExpression().evaluateAsRational(); + } + Expression Expression::simplify() const { return Expression(this->getBaseExpression().simplify()); } diff --git a/src/storm/storage/expressions/Expression.h b/src/storm/storage/expressions/Expression.h index 874a1ecda..d694017a7 100644 --- a/src/storm/storage/expressions/Expression.h +++ b/src/storm/storage/expressions/Expression.h @@ -134,6 +134,15 @@ namespace storm { * @return The double value of the expression under the given valuation. */ double evaluateAsDouble(Valuation const* valuation = nullptr) const; + + /*! + * Evaluates the expression and returns the resulting rational number. + * If the return type of the expression is not a rational an exception is thrown. + * + * @param valuation The valuation of unknowns under which to evaluate the expression. + * @return The double value of the expression under the given valuation. + */ + storm::RationalNumber evaluateAsRational() const; /*! * Simplifies the expression according to some basic rules.