Browse Source

fixing two issues related to complex model building and in particular integer vs rational division

tempestpy_adaptions
dehnert 6 years ago
parent
commit
c6204254a3
  1. 5
      src/storm/adapters/Z3ExpressionAdapter.cpp
  2. 2
      src/storm/storage/expressions/BinaryNumericalFunctionExpression.cpp
  3. 2
      src/storm/storage/expressions/ToRationalNumberVisitor.cpp

5
src/storm/adapters/Z3ExpressionAdapter.cpp

@ -227,6 +227,9 @@ namespace storm {
result = leftResult * rightResult;
break;
case storm::expressions::BinaryNumericalFunctionExpression::OperatorType::Divide:
if (leftResult.is_int() && rightResult.is_int()) {
leftResult = z3::expr(context, Z3_mk_int2real(context, leftResult));
}
result = leftResult / rightResult;
break;
case storm::expressions::BinaryNumericalFunctionExpression::OperatorType::Min:
@ -363,7 +366,7 @@ namespace storm {
case storm::expressions::UnaryNumericalFunctionExpression::OperatorType::Ceil:{
storm::expressions::Variable freshAuxiliaryVariable = manager.declareFreshVariable(manager.getIntegerType(), true);
z3::expr ceilVariable = context.int_const(freshAuxiliaryVariable.getName().c_str());
additionalAssertions.push_back(z3::expr(context, Z3_mk_int2real(context, ceilVariable)) - 1 <= result && result < z3::expr(context, Z3_mk_int2real(context, ceilVariable)));
additionalAssertions.push_back(z3::expr(context, Z3_mk_int2real(context, ceilVariable)) - 1 < result && result <= z3::expr(context, Z3_mk_int2real(context, ceilVariable)));
result = ceilVariable;
break;
}

2
src/storm/storage/expressions/BinaryNumericalFunctionExpression.cpp

@ -111,7 +111,7 @@ namespace storm {
case OperatorType::Divide: newValue = firstOperandEvaluation / secondOperandEvaluation; break;
case OperatorType::Power: {
if (carl::isInteger(secondOperandEvaluation)) {
std::size_t exponent = carl::toInt<carl::uint>(secondOperandEvaluation);
std::size_t exponent = carl::toInt<carl::sint>(secondOperandEvaluation);
newValue = carl::pow(firstOperandEvaluation, exponent);
}
break;

2
src/storm/storage/expressions/ToRationalNumberVisitor.cpp

@ -76,7 +76,7 @@ namespace storm {
break;
case BinaryNumericalFunctionExpression::OperatorType::Power:
STORM_LOG_THROW(storm::utility::isInteger(secondOperandAsRationalNumber), storm::exceptions::InvalidArgumentException, "Exponent of power operator must be a positive integer.");
exponentAsInteger = storm::utility::convertNumber<carl::uint>(secondOperandAsRationalNumber);
exponentAsInteger = storm::utility::convertNumber<carl::sint>(secondOperandAsRationalNumber);
result = storm::utility::pow(firstOperandAsRationalNumber, exponentAsInteger);
return result;
break;
Loading…
Cancel
Save