Sebastian Junges
5 years ago
7 changed files with 67 additions and 0 deletions
-
30examples/building_models/03-building-models.py
-
2src/core/core.cpp
-
3src/mod_storage.cpp
-
4src/storage/model.cpp
-
1src/storage/prism.cpp
-
21src/storage/valuation.cpp
-
6src/storage/valuation.h
@ -0,0 +1,30 @@ |
|||||
|
import stormpy |
||||
|
import stormpy.core |
||||
|
|
||||
|
import stormpy.examples |
||||
|
import stormpy.examples.files |
||||
|
|
||||
|
|
||||
|
def example_building_models_01(): |
||||
|
path = stormpy.examples.files.prism_pdtmc_brp |
||||
|
prism_program = stormpy.parse_prism_program(path) |
||||
|
formula_str = "P=? [F s=5]" |
||||
|
properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program) |
||||
|
|
||||
|
options = stormpy.BuilderOptions([p.raw_formula for p in properties]) |
||||
|
options.set_build_state_valuations() |
||||
|
model = stormpy.build_sparse_parametric_model_with_options(prism_program, options) |
||||
|
eval2 = model.state_valuations.get_state(2) |
||||
|
integer_variables = [] |
||||
|
boolean_variables = [] |
||||
|
for module in prism_program.modules: |
||||
|
print("module {}".format(module.name)) |
||||
|
integer_variables += module.integer_variables |
||||
|
boolean_variables += module.boolean_variables |
||||
|
|
||||
|
print(",".join(["{}: {}".format(str(iv.name), eval2.get_integer_value(iv.expression_variable)) for iv in integer_variables])) |
||||
|
|
||||
|
|
||||
|
|
||||
|
if __name__ == '__main__': |
||||
|
example_building_models_01() |
@ -0,0 +1,21 @@ |
|||||
|
#include "valuation.h"
|
||||
|
#include "src/helpers.h"
|
||||
|
|
||||
|
#include "storm/storage/sparse/StateValuations.h"
|
||||
|
#include "storm/storage/expressions/SimpleValuation.h"
|
||||
|
#include "storm/storage/expressions/Variable.h"
|
||||
|
|
||||
|
// Define python bindings
|
||||
|
void define_statevaluation(py::module& m) { |
||||
|
|
||||
|
py::class_<storm::storage::sparse::StateValuations, std::shared_ptr<storm::storage::sparse::StateValuations>> statevaluation(m,"StateValuation", "Valuations for explicit states"); |
||||
|
statevaluation.def("get_state", &storm::storage::sparse::StateValuations::getStateValuation) |
||||
|
; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void define_simplevaluation(py::module& m) { |
||||
|
py::class_<storm::expressions::SimpleValuation, std::shared_ptr<storm::expressions::SimpleValuation>> simplevaluation(m, "SimpleValuation", "Valuations for storm variables"); |
||||
|
simplevaluation.def("get_boolean_value", &storm::expressions::SimpleValuation::getBooleanValue); |
||||
|
simplevaluation.def("get_integer_value", &storm::expressions::SimpleValuation::getIntegerValue); |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include "common.h" |
||||
|
|
||||
|
void define_statevaluation(py::module& m); |
||||
|
void define_simplevaluation(py::module& m); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue