From cde59bd4365945b9c2383c263e9866fb9cfddb74 Mon Sep 17 00:00:00 2001 From: TimQu Date: Fri, 31 Mar 2017 15:56:31 +0200 Subject: [PATCH] added Expression::evaluateAsRational --- src/storm/storage/expressions/Expression.cpp | 4 ++++ src/storm/storage/expressions/Expression.h | 9 +++++++++ 2 files changed, 13 insertions(+) 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.