diff --git a/src/storm-dft-cli/storm-dft.cpp b/src/storm-dft-cli/storm-dft.cpp index f6a7d3863..c59da090a 100644 --- a/src/storm-dft-cli/storm-dft.cpp +++ b/src/storm-dft-cli/storm-dft.cpp @@ -76,8 +76,7 @@ void processOptions() { if (faultTreeSettings.solveWithSMT()) { // Solve with SMT STORM_LOG_DEBUG("Running DFT analysis with use of SMT"); - storm::api::exportDFTToSMT(*dft, "test.smt2"); - STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Only exported to SMT file 'test.smt2' but analysis is not supported."); + storm::api::analyzeDFTSMT(*dft, true); return; } #endif diff --git a/src/storm-dft/api/storm-dft.cpp b/src/storm-dft/api/storm-dft.cpp index bae04d1e0..2da0b5b2c 100644 --- a/src/storm-dft/api/storm-dft.cpp +++ b/src/storm-dft/api/storm-dft.cpp @@ -42,6 +42,34 @@ namespace storm { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Export to SMT does not support this data type."); } + template<> + std::vector + analyzeDFTSMT(storm::storage::DFT const &dft, bool printOutput) { + storm::modelchecker::DFTASFChecker smtChecker(dft); + smtChecker.convert(); + std::vector results = smtChecker.toSolver(); + + if (printOutput) { + for (size_t i = 0; i < results.size(); ++i) { + std::string tmp = "unknonwn"; + if (results.at(i) == storm::solver::SmtSolver::CheckResult::Sat) { + tmp = "SAT"; + } else if (results.at(i) == storm::solver::SmtSolver::CheckResult::Unsat) { + tmp = "UNSAT"; + } + std::cout << "Query " << std::to_string(i) << " : " << tmp << std::endl; + } + } + return results; + } + + template<> + std::vector + analyzeDFTSMT(storm::storage::DFT const &dft, bool printOutput) { + STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, + "Analysis by SMT not supported for this data type."); + } + template<> std::pair, uint64_t> transformToGSPN(storm::storage::DFT const& dft) { storm::settings::modules::FaultTreeSettings const& ftSettings = storm::settings::getModule(); diff --git a/src/storm-dft/api/storm-dft.h b/src/storm-dft/api/storm-dft.h index 8b4f0ae9c..2c060cd64 100644 --- a/src/storm-dft/api/storm-dft.h +++ b/src/storm-dft/api/storm-dft.h @@ -112,6 +112,17 @@ namespace storm { return results; } + /*! + * Analyze the DFT using the SMT encoding + * + * @param dft DFT. + * + * @return Result result vector + */ + template + std::vector + analyzeDFTSMT(storm::storage::DFT const &dft, bool printOutput); + /*! * Export DFT to JSON file. * diff --git a/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp b/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp index 7852426e8..8436fd215 100644 --- a/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp +++ b/src/storm-dft/modelchecker/dft/DFTASFChecker.cpp @@ -14,7 +14,7 @@ namespace storm { namespace modelchecker { - DFTASFChecker::DFTASFChecker(storm::storage::DFT const& dft) : dft(dft) { + DFTASFChecker::DFTASFChecker(storm::storage::DFT const &dft) : dft(dft) { // Intentionally left empty. } diff --git a/src/storm-dft/modelchecker/dft/DFTASFChecker.h b/src/storm-dft/modelchecker/dft/DFTASFChecker.h index 0f152e6fa..097ca0732 100644 --- a/src/storm-dft/modelchecker/dft/DFTASFChecker.h +++ b/src/storm-dft/modelchecker/dft/DFTASFChecker.h @@ -24,8 +24,8 @@ namespace storm { uint64_t spareIndex; uint64_t childIndex; }; - - + + class DFTASFChecker { using ValueType = double; public: