Browse Source

MathSAT tests now running fine again.

Former-commit-id: 35083ea120
tempestpy_adaptions
dehnert 10 years ago
parent
commit
d6a299e799
  1. 6
      src/solver/MathsatSmtSolver.cpp
  2. 2
      src/storage/expressions/Expression.cpp
  3. 5
      src/storage/expressions/Type.cpp
  4. 2
      src/storage/expressions/Variable.cpp
  5. 2
      src/storage/expressions/Variable.h
  6. 2
      test/functional/adapter/MathsatExpressionAdapterTest.cpp
  7. 2
      test/functional/adapter/Z3ExpressionAdapterTest.cpp
  8. 4
      test/functional/solver/MathSatSmtSolverTest.cpp

6
src/solver/MathsatSmtSolver.cpp

@ -46,7 +46,7 @@ namespace storm {
}
int_fast64_t MathsatSmtSolver::MathsatModelReference::getIntegerValue(storm::expressions::Variable const& variable) const {
STORM_LOG_ASSERT(variable.hasBooleanType(), "Variable is non-boolean type.");
STORM_LOG_ASSERT(variable.hasIntegerType(), "Variable is non-boolean type.");
msat_term msatVariable = expressionAdapter.translateExpression(variable);
msat_term msatValue = msat_get_model_value(env, msatVariable);
STORM_LOG_ASSERT(!MSAT_ERROR_TERM(msatValue), "Unable to retrieve value of variable in model. This could be caused by calls to the solver between checking for satisfiability and model retrieval.");
@ -55,7 +55,7 @@ namespace storm {
}
double MathsatSmtSolver::MathsatModelReference::getRationalValue(storm::expressions::Variable const& variable) const {
STORM_LOG_ASSERT(variable.hasBooleanType(), "Variable is non-boolean type.");
STORM_LOG_ASSERT(variable.hasRationalType(), "Variable is non-boolean type.");
msat_term msatVariable = expressionAdapter.translateExpression(variable);
msat_term msatValue = msat_get_model_value(env, msatVariable);
STORM_LOG_ASSERT(!MSAT_ERROR_TERM(msatValue), "Unable to retrieve value of variable in model. This could be caused by calls to the solver between checking for satisfiability and model retrieval.");
@ -254,7 +254,7 @@ namespace storm {
if (stormVariable.hasBooleanType()) {
stormModel.setBooleanValue(stormVariable, variableInterpretation.isTrue());
} else if (stormVariable.hasIntegralType()) {
} else if (stormVariable.hasIntegerType()) {
stormModel.setIntegerValue(stormVariable, variableInterpretation.evaluateAsInt());
} else if (stormVariable.hasRationalType()) {
stormModel.setRationalValue(stormVariable, variableInterpretation.evaluateAsDouble());

2
src/storage/expressions/Expression.cpp

@ -151,7 +151,7 @@ namespace storm {
}
std::ostream& operator<<(std::ostream& stream, Expression const& expression) {
stream << expression.getBaseExpression() << "[" << &expression.getManager() << "]";
stream << expression.getBaseExpression();
return stream;
}

5
src/storage/expressions/Type.cpp

@ -182,10 +182,7 @@ namespace storm {
Type Type::numericalComparison(Type const& other) const {
STORM_LOG_ASSERT(this->isNumericalType() && other.isNumericalType(), "Operator requires numerical operands.");
if (this->isRationalType() || other.isRationalType()) {
return this->getManager().getRationalType();
}
return this->getManager().getIntegerType();
return this->getManager().getBooleanType();
}
Type Type::ite(Type const& thenType, Type const& elseType) const {

2
src/storage/expressions/Variable.cpp

@ -43,7 +43,7 @@ namespace storm {
return this->getType().isBooleanType();
}
bool Variable::hasIntegralType() const {
bool Variable::hasIntegerType() const {
return this->getType().isIntegralType();
}

2
src/storage/expressions/Variable.h

@ -103,7 +103,7 @@ namespace storm {
*
* @return True iff the variable if of integral type.
*/
bool hasIntegralType() const;
bool hasIntegerType() const;
/*!
* Checks whether the variable is of rational type.

2
test/functional/adapter/MathsatExpressionAdapterTest.cpp

@ -129,7 +129,7 @@ TEST(MathsatExpressionAdapter, StormToMathsatFloorCeil) {
storm::adapters::MathsatExpressionAdapter adapter(*manager, env);
storm::expressions::Variable d = manager->declareRationalVariable("d");
storm::expressions::Variable i = manager->declareIntegerVariable("d");
storm::expressions::Variable i = manager->declareIntegerVariable("i");
storm::expressions::Expression exprFloor = storm::expressions::floor(d) == i && d > manager->rational(4.1) && d < manager->rational(4.991);
msat_decl iDecl = msat_declare_function(env, "i", msat_get_integer_type(env));

2
test/functional/adapter/Z3ExpressionAdapterTest.cpp

@ -111,7 +111,7 @@ TEST(Z3ExpressionAdapter, StormToZ3FloorCeil) {
storm::adapters::Z3ExpressionAdapter adapter(*manager, ctx);
storm::expressions::Variable d = manager->declareRationalVariable("d");
storm::expressions::Variable i = manager->declareIntegerVariable("d");
storm::expressions::Variable i = manager->declareIntegerVariable("i");
storm::expressions::Expression exprFloor = storm::expressions::floor(d) == i && d > manager->rational(4.1) && d < manager->rational(4.991);
z3::expr z3Floor = ctx.int_val(4) == ctx.int_const("i");

4
test/functional/solver/MathSatSmtSolverTest.cpp

@ -24,7 +24,7 @@ TEST(MathsatSmtSolver, CheckSat) {
storm::expressions::Variable b = manager->declareIntegerVariable("b");
storm::expressions::Variable c = manager->declareIntegerVariable("c");
storm::expressions::Expression exprFormula = a >= manager->integer(0) && a < manager->integer(5) && b > manager->integer(7) && c == (a * b) && b + a > c;
storm::expressions::Expression exprFormula = a >= manager->integer(0) && a < manager->integer(5) && b > manager->integer(7) && c == (a + b - manager->integer(1)) && b + a > c;
ASSERT_NO_THROW(s.add(exprFormula));
ASSERT_NO_THROW(result = s.check());
@ -240,7 +240,7 @@ TEST(MathsatSmtSolver, InterpolationTest) {
storm::solver::MathsatSmtSolver s2(*manager);
ASSERT_NO_THROW(s2.add(storm::expressions::implies(!(exprFormula && exprFormula2), interpol)));
ASSERT_NO_THROW(s2.add(!storm::expressions::implies(exprFormula && exprFormula2, interpol)));
ASSERT_NO_THROW(result = s2.check());
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::Unsat);

Loading…
Cancel
Save