From 9791070a6ae6ca1c85a22bc904d5a599e3aee165 Mon Sep 17 00:00:00 2001 From: Mavo Date: Thu, 21 Jan 2016 09:19:26 +0100 Subject: [PATCH] Added PmcResult containing the model checking results Former-commit-id: 3cbaa9746f3b9c0be7e648b6224f9051ef132c2b --- src/python/storm-core.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/python/storm-core.cpp b/src/python/storm-core.cpp index f44df8caf..7a1a60153 100644 --- a/src/python/storm-core.cpp +++ b/src/python/storm-core.cpp @@ -8,17 +8,26 @@ #include "helpers.h" #include "boostPyExtension.h" - +class PmcResult { +public: + storm::RationalFunction resultFunction; + std::unordered_set> constraintsWellFormed; + std::unordered_set> constraintsGraphPreserving; +}; std::shared_ptr buildModel(storm::prism::Program const& program, std::shared_ptr const& formula) { return storm::buildSymbolicModel(program, std::vector>(1,formula)).model; } -std::unique_ptr performStateElimination(std::shared_ptr> model, std::shared_ptr const& formula) { +std::shared_ptr performStateElimination(std::shared_ptr> model, std::shared_ptr const& formula) { std::cout << "Perform state elimination" << std::endl; - std::unique_ptr result = storm::verifySparseModel(model, formula); - result->filter(storm::modelchecker::ExplicitQualitativeCheckResult(model->getInitialStates())); - std::cout << "Result: " << *result << std::endl; + std::unique_ptr checkResult = storm::verifySparseModel(model, formula); + std::shared_ptr result = std::make_shared(); + result->resultFunction = (checkResult->asExplicitQuantitativeCheckResult()[*model->getInitialStates().begin()]); + std::cout << "Result: " << result->resultFunction << std::endl; + storm::models::sparse::Dtmc::ConstraintCollector constraintCollector(*(model->template as>())); + result->constraintsWellFormed = constraintCollector.getWellformedConstraints(); + result->constraintsGraphPreserving = constraintCollector.getGraphPreservingConstraints(); return result; } @@ -27,8 +36,6 @@ void setupStormLib(std::string const& args) { storm::settings::SettingsManager::manager().setFromString(args); } - - BOOST_PYTHON_MODULE(_core) { using namespace boost::python; @@ -58,10 +65,14 @@ BOOST_PYTHON_MODULE(_core) //////////////////////////////////////////// - // Checkresult + // PmcResult //////////////////////////////////////////// - class_, boost::noncopyable>("CheckResult", no_init) + class_, boost::noncopyable>("PmcResult", "") + .add_property("result_function", &PmcResult::resultFunction) + .add_property("constraints_well_formed", &PmcResult::constraintsWellFormed) + .add_property("constraints_graph_preserving", &PmcResult::constraintsGraphPreserving) ; + register_ptr_to_python>(); //////////////////////////////////////////// @@ -111,5 +122,5 @@ BOOST_PYTHON_MODULE(_core) ; - def("perform_state_elimination", boost::python::converter::adapt_unique(performStateElimination)); + def("perform_state_elimination", performStateElimination); }