Browse Source
Started on making MathSatSmtSolver work properly.
Started on making MathSatSmtSolver work properly.
Former-commit-id: c370658b26
tempestpy_adaptions
dehnert
10 years ago
5 changed files with 118 additions and 7 deletions
-
31src/adapters/MathSatExpressionAdapter.h
-
15src/exceptions/UnexpectedException.h
-
7src/solver/MathSatSmtSolver.cpp
-
58test/functional/solver/MathSatSmtSolverTest.cpp
-
14test/functional/solver/Z3SmtSolverTest.cpp
@ -0,0 +1,15 @@ |
|||||
|
#ifndef STORM_EXCEPTIONS_UNEXPECTEDEXCEPTION_H_ |
||||
|
#define STORM_EXCEPTIONS_UNEXPECTEDEXCEPTION_H_ |
||||
|
|
||||
|
#include "src/exceptions/BaseException.h" |
||||
|
#include "src/exceptions/ExceptionMacros.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace exceptions { |
||||
|
|
||||
|
STORM_NEW_EXCEPTION(UnexpectedException) |
||||
|
|
||||
|
} // namespace exceptions |
||||
|
} // namespace storm |
||||
|
|
||||
|
#endif /* STORM_EXCEPTIONS_UNEXPECTEDEXCEPTION_H_ */ |
@ -0,0 +1,58 @@ |
|||||
|
#include "gtest/gtest.h"
|
||||
|
#include "storm-config.h"
|
||||
|
|
||||
|
#ifdef STORM_HAVE_MSAT
|
||||
|
#include "src/solver/MathSatSmtSolver.h"
|
||||
|
|
||||
|
TEST(MathSatSmtSolver, CheckSat) { |
||||
|
storm::solver::MathSatSmtSolver s; |
||||
|
storm::solver::SmtSolver::CheckResult result = storm::solver::SmtSolver::CheckResult::UNKNOWN; |
||||
|
|
||||
|
storm::expressions::Expression exprDeMorgan = !(storm::expressions::Expression::createBooleanVariable("x") && storm::expressions::Expression::createBooleanVariable("y")).iff((!storm::expressions::Expression::createBooleanVariable("x") || !storm::expressions::Expression::createBooleanVariable("y"))); |
||||
|
|
||||
|
ASSERT_NO_THROW(s.assertExpression(exprDeMorgan)); |
||||
|
ASSERT_NO_THROW(result = s.check()); |
||||
|
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::SAT); |
||||
|
ASSERT_NO_THROW(s.reset()); |
||||
|
|
||||
|
storm::expressions::Expression a = storm::expressions::Expression::createIntegerVariable("a"); |
||||
|
storm::expressions::Expression b = storm::expressions::Expression::createIntegerVariable("b"); |
||||
|
storm::expressions::Expression c = storm::expressions::Expression::createIntegerVariable("c"); |
||||
|
storm::expressions::Expression exprFormula = a >= storm::expressions::Expression::createIntegerLiteral(0) |
||||
|
&& a < storm::expressions::Expression::createIntegerLiteral(5) |
||||
|
&& b > storm::expressions::Expression::createIntegerLiteral(7) |
||||
|
&& c == (a * b) |
||||
|
&& b + a > c; |
||||
|
|
||||
|
ASSERT_NO_THROW(s.assertExpression(exprFormula)); |
||||
|
ASSERT_NO_THROW(result = s.check()); |
||||
|
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::SAT); |
||||
|
ASSERT_NO_THROW(s.reset()); |
||||
|
} |
||||
|
|
||||
|
TEST(MathSatSmtSolver, CheckUnsat) { |
||||
|
storm::solver::MathSatSmtSolver s; |
||||
|
storm::solver::SmtSolver::CheckResult result = storm::solver::SmtSolver::CheckResult::UNKNOWN; |
||||
|
|
||||
|
storm::expressions::Expression exprDeMorgan = !(storm::expressions::Expression::createBooleanVariable("x") && storm::expressions::Expression::createBooleanVariable("y")).iff( (!storm::expressions::Expression::createBooleanVariable("x") || !storm::expressions::Expression::createBooleanVariable("y"))); |
||||
|
|
||||
|
ASSERT_NO_THROW(s.assertExpression(!exprDeMorgan)); |
||||
|
ASSERT_NO_THROW(result = s.check()); |
||||
|
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::UNSAT); |
||||
|
ASSERT_NO_THROW(s.reset()); |
||||
|
|
||||
|
storm::expressions::Expression a = storm::expressions::Expression::createIntegerVariable("a"); |
||||
|
storm::expressions::Expression b = storm::expressions::Expression::createIntegerVariable("b"); |
||||
|
storm::expressions::Expression c = storm::expressions::Expression::createIntegerVariable("c"); |
||||
|
storm::expressions::Expression exprFormula = a >= storm::expressions::Expression::createIntegerLiteral(2) |
||||
|
&& a < storm::expressions::Expression::createIntegerLiteral(5) |
||||
|
&& b > storm::expressions::Expression::createIntegerLiteral(7) |
||||
|
&& c == (a + b + storm::expressions::Expression::createIntegerLiteral(1)) |
||||
|
&& b + a > c; |
||||
|
|
||||
|
ASSERT_NO_THROW(s.assertExpression(exprFormula)); |
||||
|
ASSERT_NO_THROW(result = s.check()); |
||||
|
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::UNSAT); |
||||
|
} |
||||
|
|
||||
|
#endif
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue