Browse Source

Check in SMT checker that only one BE is constantly failed

tempestpy_adaptions
Alexander Bork 6 years ago
parent
commit
b3cf06d6dd
  1. 33
      src/storm-dft/modelchecker/dft/DFTASFChecker.cpp

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

@ -29,8 +29,9 @@ namespace storm {
void DFTASFChecker::convert() { void DFTASFChecker::convert() {
std::vector<uint64_t> beVariables; std::vector<uint64_t> beVariables;
std::vector<uint64_t> failedBeVariables;
uint64_t failedBeVariables;
std::vector<uint64_t> failsafeBeVariables; std::vector<uint64_t> failsafeBeVariables;
bool failedBeIsSet = false;
notFailed = dft.nrBasicElements() + 1; // Value indicating the element is not failed notFailed = dft.nrBasicElements() + 1; // Value indicating the element is not failed
// Initialize variables // Initialize variables
@ -49,7 +50,10 @@ namespace storm {
// Constant BEs are initially either failed or failsafe, treat them differently // Constant BEs are initially either failed or failsafe, treat them differently
auto be = std::static_pointer_cast<storm::storage::BEConst<double> const>(element); auto be = std::static_pointer_cast<storm::storage::BEConst<double> const>(element);
if (be->failed()) { if (be->failed()) {
failedBeVariables.push_back(varNames.size() - 1);
STORM_LOG_THROW(!failedBeIsSet, storm::exceptions::NotSupportedException,
"DFTs containing more than one constantly failed BE are not supported");
failedBeVariables = varNames.size() - 1;
failedBeIsSet = true;
} else { } else {
failsafeBeVariables.push_back(varNames.size() - 1); failsafeBeVariables.push_back(varNames.size() - 1);
} }
@ -94,13 +98,13 @@ namespace storm {
} }
// Constantly failed BEs fail before other types // Constantly failed BEs fail before other types
for (auto const &beV : failedBeVariables) {
constraints.push_back(std::make_shared<BetweenValues>(beV, 1, failedBeVariables.size()));
if (failedBeIsSet) {
constraints.push_back(std::make_shared<IsConstantValue>(failedBeVariables, 0));
} }
std::vector<uint64_t> allBeVariables; std::vector<uint64_t> allBeVariables;
allBeVariables.insert(std::end(allBeVariables), std::begin(beVariables), std::end(beVariables)); allBeVariables.insert(std::end(allBeVariables), std::begin(beVariables), std::end(beVariables));
allBeVariables.insert(std::end(allBeVariables), std::begin(failedBeVariables), std::end(failedBeVariables));
allBeVariables.insert(std::end(allBeVariables), std::begin(failsafeBeVariables), allBeVariables.insert(std::end(allBeVariables), std::begin(failsafeBeVariables),
std::end(failsafeBeVariables)); std::end(failsafeBeVariables));
@ -676,6 +680,8 @@ namespace storm {
std::shared_ptr<storm::expressions::ExpressionManager> manager = solver->getManager().getSharedPointer(); std::shared_ptr<storm::expressions::ExpressionManager> manager = solver->getManager().getSharedPointer();
solver->add(countConstr->toExpression(varNames, manager)); solver->add(countConstr->toExpression(varNames, manager));
solver->add(timepointConstr->toExpression(varNames, manager)); solver->add(timepointConstr->toExpression(varNames, manager));
STORM_PRINT(countConstr->toSmtlib2(varNames) << std::endl);
STORM_PRINT(timepointConstr->toSmtlib2(varNames) << std::endl);
storm::solver::SmtSolver::CheckResult res = solver->check(); storm::solver::SmtSolver::CheckResult res = solver->check();
solver->pop(); solver->pop();
return res; return res;
@ -683,7 +689,6 @@ namespace storm {
storm::solver::SmtSolver::CheckResult storm::solver::SmtSolver::CheckResult
DFTASFChecker::checkDependencyConflict(uint64_t dep1Index, uint64_t dep2Index, uint64_t timeout) { DFTASFChecker::checkDependencyConflict(uint64_t dep1Index, uint64_t dep2Index, uint64_t timeout) {
//TODO make constraints easier?
std::vector<std::shared_ptr<SmtConstraint>> andConstr; std::vector<std::shared_ptr<SmtConstraint>> andConstr;
std::vector<std::shared_ptr<SmtConstraint>> orConstr; std::vector<std::shared_ptr<SmtConstraint>> orConstr;
STORM_LOG_DEBUG( STORM_LOG_DEBUG(
@ -731,6 +736,8 @@ namespace storm {
uint64_t DFTASFChecker::correctLowerBound(uint64_t bound, uint_fast64_t timeout) { uint64_t DFTASFChecker::correctLowerBound(uint64_t bound, uint_fast64_t timeout) {
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 (experimentalMode)
STORM_LOG_WARN("DFT-SMT-Checker now runs in experimental mode, bound correction is prone to errors!");
STORM_LOG_DEBUG("Lower bound correction - try to correct bound " << std::to_string(bound)); STORM_LOG_DEBUG("Lower bound correction - try to correct bound " << std::to_string(bound));
uint64_t boundCandidate = bound; uint64_t boundCandidate = bound;
uint64_t nrDepEvents = 0; uint64_t nrDepEvents = 0;
@ -747,7 +754,7 @@ namespace storm {
} }
} }
// Only need to check as long as bound candidate + nr of non-Markovians to check is smaller than number of dependent events // Only need to check as long as bound candidate + nr of non-Markovians to check is smaller than number of dependent events
while (nrNonMarkovian <= nrDepEvents && boundCandidate > 0) {
while (nrNonMarkovian <= nrDepEvents && boundCandidate >= 0) {
STORM_LOG_TRACE( STORM_LOG_TRACE(
"Lower bound correction - check possible bound " << std::to_string(boundCandidate) << " with " "Lower bound correction - check possible bound " << std::to_string(boundCandidate) << " with "
<< std::to_string(nrNonMarkovian) << std::to_string(nrNonMarkovian)
@ -761,6 +768,11 @@ namespace storm {
/* If SAT, there is a sequence where only boundCandidate-many BEs fail directly and rest is nonMarkovian. /* If SAT, there is a sequence where only boundCandidate-many BEs fail directly and rest is nonMarkovian.
* Bound candidate is vaild, therefore check the next one */ * Bound candidate is vaild, therefore check the next one */
STORM_LOG_TRACE("Lower bound correction - SAT"); STORM_LOG_TRACE("Lower bound correction - SAT");
// Prevent integer underflow
if (boundCandidate == 0) {
STORM_LOG_DEBUG("Lower bound correction - corrected bound to 0");
return 0;
}
--boundCandidate; --boundCandidate;
break; break;
case storm::solver::SmtSolver::CheckResult::Unknown: case storm::solver::SmtSolver::CheckResult::Unknown:
@ -781,9 +793,13 @@ namespace storm {
uint64_t DFTASFChecker::correctUpperBound(uint64_t bound, uint_fast64_t timeout) { uint64_t DFTASFChecker::correctUpperBound(uint64_t bound, uint_fast64_t timeout) {
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 (experimentalMode)
STORM_LOG_WARN("DFT-SMT-Checker now runs in experimental mode, bound correction is prone to errors!");
STORM_LOG_DEBUG("Upper bound correction - try to correct bound " << std::to_string(bound)); STORM_LOG_DEBUG("Upper bound correction - try to correct bound " << std::to_string(bound));
while (bound > 1) {
while (bound > 0) {
STORM_LOG_TRACE("Upper bound correction - check possible bound " << std::to_string(bound));
setSolverTimeout(timeout * 1000); setSolverTimeout(timeout * 1000);
storm::solver::SmtSolver::CheckResult tmp_res = storm::solver::SmtSolver::CheckResult tmp_res =
checkFailsAtTimepointWithOnlyMarkovianState(bound); checkFailsAtTimepointWithOnlyMarkovianState(bound);
@ -796,6 +812,7 @@ namespace storm {
STORM_LOG_DEBUG("Upper bound correction - Solver returned 'Unknown', corrected to "); STORM_LOG_DEBUG("Upper bound correction - Solver returned 'Unknown', corrected to ");
return bound; return bound;
default: default:
STORM_LOG_TRACE("Upper bound correction - UNSAT");
--bound; --bound;
break; break;

Loading…
Cancel
Save