Browse Source

Added tests for SMT encoding

tempestpy_adaptions
Alexander Bork 6 years ago
parent
commit
a669c69fc9
  1. 8
      resources/examples/testfiles/dft/spareTwoModules.dft
  2. 2
      src/storm-dft/api/storm-dft.cpp
  3. 13
      src/storm-dft/modelchecker/dft/DFTASFChecker.cpp
  4. 22
      src/test/storm-dft/api/DftSmtTest.cpp

8
resources/examples/testfiles/dft/spareTwoModules.dft

@ -0,0 +1,8 @@
toplevel "A";
"A" or "B" "C";
"B" wsp "K" "J" "I";
"C" wsp "L" "J" "I";
"I" lambda=0.5 dorm=0.5;
"J" lambda=1 dorm=0.5;
"K" lambda=0.5 dorm=0.5;
"L" lambda=0.5 dorm=0.5;

2
src/storm-dft/api/storm-dft.cpp

@ -53,7 +53,7 @@ namespace storm {
uint64_t lower_bound = smtChecker.getLeastFailureBound(); uint64_t lower_bound = smtChecker.getLeastFailureBound();
uint64_t upper_bound = smtChecker.getAlwaysFailedBound(); uint64_t upper_bound = smtChecker.getAlwaysFailedBound();
if (printOutput) { if (printOutput) {
//TODO add suitable output function, maybe add query descriptions for better readability
// TODO add suitable output function, maybe add query descriptions for better readability
for (size_t i = 0; i < results.size(); ++i) { for (size_t i = 0; i < results.size(); ++i) {
std::string tmp = "unknown"; std::string tmp = "unknown";
if (results.at(i) == storm::solver::SmtSolver::CheckResult::Sat) { if (results.at(i) == storm::solver::SmtSolver::CheckResult::Sat) {

13
src/storm-dft/modelchecker/dft/DFTASFChecker.cpp

@ -119,8 +119,8 @@ namespace storm {
} }
} }
// Constraint (8)
addClaimingConstraints();
// Constraint (8) intentionally commented out for testing purposes
//addClaimingConstraints();
// Handle dependencies // Handle dependencies
addMarkovianConstraints(); addMarkovianConstraints();
@ -505,10 +505,8 @@ namespace storm {
} }
uint64_t DFTASFChecker::getLeastFailureBound(uint_fast64_t timeout) { uint64_t DFTASFChecker::getLeastFailureBound(uint_fast64_t timeout) {
STORM_LOG_TRACE("Compute lower bound for number of BE failures necessary for the DFT to fail");
STORM_LOG_ASSERT(solver, "SMT Solver was not initialized, call toSolver() before checking queries"); STORM_LOG_ASSERT(solver, "SMT Solver was not initialized, call toSolver() before checking queries");
if (checkTleNeverFailed() == storm::solver::SmtSolver::CheckResult::Sat) {
return notFailed;
}
uint64_t bound = 0; uint64_t bound = 0;
while (bound < notFailed) { while (bound < notFailed) {
setSolverTimeout(timeout * 1000); setSolverTimeout(timeout * 1000);
@ -518,7 +516,7 @@ namespace storm {
case storm::solver::SmtSolver::CheckResult::Sat: case storm::solver::SmtSolver::CheckResult::Sat:
return bound; return bound;
case storm::solver::SmtSolver::CheckResult::Unknown: case storm::solver::SmtSolver::CheckResult::Unknown:
STORM_LOG_DEBUG("Solver returned 'Unknown'");
STORM_LOG_DEBUG("Lower bound: Solver returned 'Unknown'");
return bound; return bound;
default: default:
++bound; ++bound;
@ -530,6 +528,7 @@ namespace storm {
} }
uint64_t DFTASFChecker::getAlwaysFailedBound(uint_fast64_t timeout) { uint64_t DFTASFChecker::getAlwaysFailedBound(uint_fast64_t timeout) {
STORM_LOG_TRACE("Compute bound for number of BE failures such that the DFT always fails");
STORM_LOG_ASSERT(solver, "SMT Solver was not initialized, call toSolver() before checking queries"); STORM_LOG_ASSERT(solver, "SMT Solver was not initialized, call toSolver() before checking queries");
if (checkTleNeverFailed() == storm::solver::SmtSolver::CheckResult::Sat) { if (checkTleNeverFailed() == storm::solver::SmtSolver::CheckResult::Sat) {
return notFailed; return notFailed;
@ -543,7 +542,7 @@ namespace storm {
case storm::solver::SmtSolver::CheckResult::Sat: case storm::solver::SmtSolver::CheckResult::Sat:
return bound; return bound;
case storm::solver::SmtSolver::CheckResult::Unknown: case storm::solver::SmtSolver::CheckResult::Unknown:
STORM_LOG_DEBUG("Solver returned 'Unknown'");
STORM_LOG_DEBUG("Upper bound: Solver returned 'Unknown'");
return bound; return bound;
default: default:
--bound; --bound;

22
src/test/storm-dft/api/DftSmtTest.cpp

@ -23,4 +23,26 @@ namespace {
smtChecker.toSolver(); smtChecker.toSolver();
EXPECT_EQ(smtChecker.checkTleNeverFailed(), storm::solver::SmtSolver::CheckResult::Sat); EXPECT_EQ(smtChecker.checkTleNeverFailed(), storm::solver::SmtSolver::CheckResult::Sat);
} }
TEST(DftSmtTest, SpareTest) {
std::shared_ptr<storm::storage::DFT<double>> dft =
storm::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spareTwoModules.dft");
EXPECT_TRUE(storm::api::isWellFormed(*dft));
storm::modelchecker::DFTASFChecker smtChecker(*dft);
smtChecker.convert();
smtChecker.toSolver();
EXPECT_EQ(smtChecker.checkTleFailsWithLeq(2), storm::solver::SmtSolver::CheckResult::Unsat);
EXPECT_EQ(smtChecker.checkTleFailsWithEq(3), storm::solver::SmtSolver::CheckResult::Sat);
}
TEST(DftSmtTest, BoundTest) {
std::shared_ptr<storm::storage::DFT<double>> dft =
storm::api::loadDFTGalileoFile<double>(STORM_TEST_RESOURCES_DIR "/dft/spare5.dft");
EXPECT_TRUE(storm::api::isWellFormed(*dft));
storm::modelchecker::DFTASFChecker smtChecker(*dft);
smtChecker.convert();
smtChecker.toSolver();
EXPECT_EQ(smtChecker.getLeastFailureBound(30), uint64_t(2));
EXPECT_EQ(smtChecker.getAlwaysFailedBound(30), uint64_t(4));
}
} }
Loading…
Cancel
Save