Browse Source

make sure examples run through again

refactoring
Sebastian Junges 8 years ago
parent
commit
201aaa115d
  1. 16
      examples/01-getting-started.py
  2. 40
      examples/02-getting-started.py
  3. 22
      examples/03-getting-started.py
  4. 30
      examples/04-getting-started.py
  5. 1
      lib/stormpy/__init__.py

16
examples/01-getting-started.py

@ -4,10 +4,14 @@ import stormpy.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
def example_getting_started_01():
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))
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.labeling.get_labels()))
if __name__ == 'main':
example_getting_started_01()

40
examples/02-getting-started.py

@ -4,26 +4,30 @@ import stormpy.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
def example_getting_started_02():
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))
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.labeling.get_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 = "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.labeling.get_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))
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.labeling.get_labels()))
if __name__ == 'main':
example_getting_started_02()

22
examples/03-getting-started.py

@ -4,15 +4,19 @@ import stormpy.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
def example_getting_started_03():
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():
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)
if __name__ == 'main':
example_getting_started_03()

30
examples/04-getting-started.py

@ -1,5 +1,6 @@
import stormpy
import stormpy.core
import stormpy.pars
import pycarl
import pycarl.core
@ -7,21 +8,24 @@ import pycarl.core
import stormpy.examples
import stormpy.examples.files
path = stormpy.examples.files.prism_pdtmc_die
prism_program = stormpy.parse_prism_program(path)
def example_getting_started_04():
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))
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:
instantiator = stormpy.pars.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])
point[x] = stormpy.RationalRF(0.4)
instantiated_model = instantiator.instantiate(point)
result = stormpy.model_checking(instantiated_model, properties[0])
if __name__ == 'main':
example_getting_started_04()

1
lib/stormpy/__init__.py

@ -4,6 +4,7 @@ from . import storage
from .storage import *
from .version import __version__
from ._config import *
from .logic import *
from pycarl import Variable # needed for building parametric models

Loading…
Cancel
Save