Browse Source

Model checking results for all states

Former-commit-id: ae76c76543
tempestpy_adaptions
Mavo 9 years ago
committed by Matthias Volk
parent
commit
32dc776616
  1. 7
      stormpy/src/core/modelchecking.cpp
  2. 12
      stormpy/tests/core/test_modelchecking.py

7
stormpy/src/core/modelchecking.cpp

@ -40,6 +40,12 @@ double modelChecking(std::shared_ptr<storm::models::sparse::Model<double>> model
return checkResult->asExplicitQuantitativeCheckResult<double>()[*model->getInitialStates().begin()];
}
// Thin wrapper for model checking for all states
std::vector<double> modelCheckingAll(std::shared_ptr<storm::models::sparse::Model<double>> model, std::shared_ptr<storm::logic::Formula const> const& formula) {
std::unique_ptr<storm::modelchecker::CheckResult> checkResult = storm::verifySparseModel<double>(model, formula);
return checkResult->asExplicitQuantitativeCheckResult<double>().getValueVector();
}
// Thin wrapper for parametric model checking
std::shared_ptr<PmcResult> parametricModelChecking(std::shared_ptr<storm::models::sparse::Model<storm::RationalFunction>> model, std::shared_ptr<storm::logic::Formula const> const& formula) {
std::unique_ptr<storm::modelchecker::CheckResult> checkResult = storm::verifySparseModel<storm::RationalFunction>(model, formula);
@ -56,6 +62,7 @@ void define_modelchecking(py::module& m) {
// Model checking
m.def("_model_checking", &modelChecking, "Perform model checking", py::arg("model"), py::arg("formula"));
m.def("model_checking_all", &modelCheckingAll, "Perform model checking for all states", py::arg("model"), py::arg("formula"));
m.def("_parametric_model_checking", &parametricModelChecking, "Perform parametric model checking", py::arg("model"), py::arg("formula"));
// PmcResult

12
stormpy/tests/core/test_modelchecking.py

@ -2,7 +2,7 @@ import stormpy
import stormpy.logic
class TestModelChecking:
def test_state_elimination(self):
def test_model_checking_dtmc(self):
program = stormpy.parse_prism_program("../examples/dtmc/die/die.pm")
formulas = stormpy.parse_formulas_for_prism_program("P=? [ F \"one\" ]", program)
model = stormpy.build_model(program, formulas[0])
@ -11,6 +11,16 @@ class TestModelChecking:
result = stormpy.model_checking(model, formulas[0])
assert result == 0.16666666666666663
def test_model_checking_all_dtmc(self):
program = stormpy.parse_prism_program("../examples/dtmc/die/die.pm")
formulas = stormpy.parse_formulas_for_prism_program("P=? [ F \"one\" ]", program)
model = stormpy.build_model(program, formulas[0])
assert model.nr_states() == 13
assert model.nr_transitions() == 20
results = stormpy.model_checking_all(model, formulas[0])
results_orig = [0.16666666666666663, 0.3333333333333333, 0, 0.6666666666666666, 0, 0, 0, 1, 0, 0, 0, 0, 0]
assert results == results_orig
def test_parametric_state_elimination(self):
import pycarl
import pycarl.formula

Loading…
Cancel
Save