Browse Source

examples to accompany our getting started guide

refactoring
Sebastian Junges 8 years ago
parent
commit
e025ddf8b5
  1. 13
      examples/01-getting-started.py
  2. 29
      examples/02-getting-started.py
  3. 18
      examples/03-getting-started.py
  4. 27
      examples/04-getting-started.py
  5. 0
      examples/05-getting-started.py

13
examples/01-getting-started.py

@ -0,0 +1,13 @@
import stormpy
import stormpy.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
model = stormpy.build_model(prism_program)
print("Number of states: {}".format(model.nr_states))
print("Number of transitions: {}".format(model.nr_transitions))
print("Labels: {}".format(model.labels))

29
examples/02-getting-started.py

@ -0,0 +1,29 @@
import stormpy
import stormpy.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
model = stormpy.build_model(prism_program)
print("Number of states: {}".format(model.nr_states))
print("Number of transitions: {}".format(model.nr_transitions))
print("Labels in the model: {}".format(model.labels))
formula_str = "P=? [F s=2]"
properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
model_for_formula = stormpy.build_model(prism_program, properties)
print("Number of states: {}".format(model_for_formula.nr_states))
print("Number of transitions: {}".format(model_for_formula.nr_transitions))
print("Labels in the model: {}".format(model_for_formula.labels))
formula_str_2 = "P=? [F s=7 & d=2]"
properties_2 = stormpy.parse_properties_for_prism_program(formula_str_2, prism_program)
model_for_formula_2 = stormpy.build_model(prism_program, properties_2)
print("Number of states: {}".format(model_for_formula_2.nr_states))
print("Number of transitions: {}".format(model_for_formula_2.nr_transitions))
print("Labels in the model: {}".format(model_for_formula_2.labels))

18
examples/03-getting-started.py

@ -0,0 +1,18 @@
import stormpy
import stormpy.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
formula_str = "P=? [F s=7 & d=2]"
properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
model = stormpy.build_model(prism_program, properties)
result = stormpy.model_checking(model, properties[0])
print(result)
assert result.result_for_all_states
for x in result.get_values():
print(x)

27
examples/04-getting-started.py

@ -0,0 +1,27 @@
import stormpy
import stormpy.core
import pycarl
import pycarl.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_pdtmc_die
prism_program = stormpy.parse_prism_program(path)
formula_str = "P=? [F s=7 & d=2]"
properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
model = stormpy.build_parametric_model(prism_program, properties)
print("Model supports parameters: {}".format(model.supports_parameters))
instantiator = stormpy.PdtmcInstantiator(model)
point = dict()
parameters = model.collect_probability_parameters()
for x in parameters:
print(x.name)
point[x] = 0.4
instantiated_model = instantiator.instantiate(point)
result = stormpy.model_checking(instantiated_model, properties[0])

0
examples/05-getting-started.py

Loading…
Cancel
Save