From 4d1dfdc75c75720f639166d90ce3df3744539d62 Mon Sep 17 00:00:00 2001 From: Jip Spel Date: Tue, 25 Sep 2018 11:10:05 +0200 Subject: [PATCH] Fix problem with exponent and denominator --- src/storm/storage/expressions/ValueTypeToExpression.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/storm/storage/expressions/ValueTypeToExpression.cpp b/src/storm/storage/expressions/ValueTypeToExpression.cpp index 3495d7f35..9a676cd41 100644 --- a/src/storm/storage/expressions/ValueTypeToExpression.cpp +++ b/src/storm/storage/expressions/ValueTypeToExpression.cpp @@ -19,6 +19,7 @@ namespace storm { template Expression ValueTypeToExpression::toExpression(ValueType function) { + function.simplify(); auto varsFunction = function.gatherVariables(); for (auto var : varsFunction) { auto varsManager = manager->getVariables(); @@ -36,7 +37,7 @@ namespace storm { STORM_LOG_DEBUG("Expecting the denominator to be constant"); } - storm::expressions::Expression denominatorVal = manager->integer(std::stoi(storm::utility::to_string(denominator.constantPart()))); + storm::expressions::Expression denominatorVal = manager->rational(std::stod(storm::utility::to_string(denominator.constantPart()))); storm::expressions::Expression result; if (function.isConstant()) { result = manager->integer(std::stoi(storm::utility::to_string(function.constantPart()))); @@ -46,12 +47,12 @@ namespace storm { for (auto itr = nominator.begin(); itr != nominator.end(); ++itr) { varsFunction.clear(); (*itr).gatherVariables(varsFunction); + // TODO: improve transformation from coefficient to expression storm::expressions::Expression nominatorPartExpr = manager->integer( std::stoi(storm::utility::to_string((*itr).coeff()))); for (auto var : varsFunction) { - auto degree = nominator.degree(var); - nominatorPartExpr = nominatorPartExpr * (manager->getVariable(var.name())^manager->integer(degree)); + nominatorPartExpr = nominatorPartExpr * (manager->getVariable(var.name())^manager->integer((*itr).monomial()->exponentOfVariable(var))); } if (varsFunction.size() >= 1) { result = result + nominatorPartExpr;