Browse Source

Reworked solver integration

tempestpy_adaptions
Alexander Bork 6 years ago
parent
commit
1976a41298
  1. 5
      src/storm-dft/api/storm-dft.cpp
  2. 26
      src/storm-dft/modelchecker/dft/DFTASFChecker.cpp
  3. 10
      src/storm-dft/modelchecker/dft/DFTASFChecker.h

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

@ -47,7 +47,10 @@ namespace storm {
analyzeDFTSMT(storm::storage::DFT<double> const &dft, bool printOutput) {
storm::modelchecker::DFTASFChecker smtChecker(dft);
smtChecker.convert();
std::vector<storm::solver::SmtSolver::CheckResult> results = smtChecker.toSolver();
smtChecker.toSolver();
std::vector<storm::solver::SmtSolver::CheckResult> results;
results.push_back(smtChecker.checkTleNeverFailedQuery());
if (printOutput) {
// TODO add suitable output function, maybe add query descriptions for better readability

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

@ -429,10 +429,12 @@ namespace storm {
storm::utility::closeFile(stream);
}
std::vector<storm::solver::SmtSolver::CheckResult> DFTASFChecker::toSolver() {
std::vector<storm::solver::SmtSolver::CheckResult> resultVector;
void DFTASFChecker::toSolver() {
// First convert the DFT
convert();
std::shared_ptr<storm::expressions::ExpressionManager> manager(new storm::expressions::ExpressionManager());
std::unique_ptr<storm::solver::SmtSolver> solver = storm::utility::solver::SmtSolverFactory().create(
solver = storm::utility::solver::SmtSolverFactory().create(
*manager);
//Add variables to manager
for (auto const &timeVarEntry : timePointVariables) {
@ -453,19 +455,23 @@ namespace storm {
for (auto const &constraint : constraints) {
solver->add(constraint->toExpression(varNames, manager));
}
// Set backtracking marker to check several properties without reconstructing DFT encoding
solver->push();
//TODO put different queries in separate functions for further modularization
}
storm::solver::SmtSolver::CheckResult DFTASFChecker::checkTleNeverFailedQuery() {
STORM_LOG_ERROR_COND(!solver, "SMT Solver was not initialized, call toSolver() before checking queries");
// Set backtracking marker to check several properties without reconstructing DFT encoding
solver->push();
// Constraint that toplevel element will not fail (part of constraint 13)
std::shared_ptr<SmtConstraint> tleNeverFailedConstr = std::make_shared<IsConstantValue>(
timePointVariables.at(dft.getTopLevelIndex()), notFailed);
solver->add(tleNeverFailedConstr->toExpression(varNames, manager));
resultVector.push_back(solver->check());
solver->add(tleNeverFailedConstr->toExpression(varNames,
std::make_shared<storm::expressions::ExpressionManager>(
solver->getManager())));
storm::solver::SmtSolver::CheckResult res = solver->check();
solver->pop();
return resultVector;
return res;
}
}
}

10
src/storm-dft/modelchecker/dft/DFTASFChecker.h

@ -37,7 +37,7 @@ namespace storm {
void convert();
void toFile(std::string const&);
std::vector<storm::solver::SmtSolver::CheckResult> toSolver();
void toSolver();
private:
uint64_t getClaimVariableIndex(uint64_t spareIndex, uint64_t childIndex) const;
@ -116,7 +116,15 @@ namespace storm {
*/
void addMarkovianConstraints();
/**
* Check if the TLE of the DFT never fails
*
* @return "Sat" if TLE never fails, "Unsat" if it does, otherwise "Unknown"
*/
storm::solver::SmtSolver::CheckResult checkTleNeverFailedQuery();
storm::storage::DFT<ValueType> const& dft;
std::shared_ptr<storm::solver::SmtSolver> solver = 0;
std::vector<std::string> varNames;
std::unordered_map<uint64_t, uint64_t> timePointVariables;
std::vector<std::shared_ptr<SmtConstraint>> constraints;

Loading…
Cancel
Save