Browse Source

make sure examples run through again

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

6
examples/01-getting-started.py

@ -4,10 +4,14 @@ import stormpy.core
import stormpy.examples
import stormpy.examples.files
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))
print("Labels: {}".format(model.labeling.get_labels()))
if __name__ == 'main':
example_getting_started_01()

10
examples/02-getting-started.py

@ -4,6 +4,7 @@ import stormpy.core
import stormpy.examples
import stormpy.examples.files
def example_getting_started_02():
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
@ -11,14 +12,14 @@ 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))
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))
print("Labels in the model: {}".format(model_for_formula.labeling.get_labels()))
formula_str_2 = "P=? [F s=7 & d=2]"
@ -26,4 +27,7 @@ properties_2 = stormpy.parse_properties_for_prism_program(formula_str_2, prism_p
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))
print("Labels in the model: {}".format(model_for_formula_2.labeling.get_labels()))
if __name__ == 'main':
example_getting_started_02()

4
examples/03-getting-started.py

@ -4,6 +4,7 @@ import stormpy.core
import stormpy.examples
import stormpy.examples.files
def example_getting_started_03():
path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path)
@ -16,3 +17,6 @@ print(result)
assert result.result_for_all_states
for x in result.get_values():
print(x)
if __name__ == 'main':
example_getting_started_03()

8
examples/04-getting-started.py

@ -1,5 +1,6 @@
import stormpy
import stormpy.core
import stormpy.pars
import pycarl
import pycarl.core
@ -7,6 +8,7 @@ import pycarl.core
import stormpy.examples
import stormpy.examples.files
def example_getting_started_04():
path = stormpy.examples.files.prism_pdtmc_die
prism_program = stormpy.parse_prism_program(path)
@ -16,12 +18,14 @@ properties = stormpy.parse_properties_for_prism_program(formula_str, prism_progr
model = stormpy.build_parametric_model(prism_program, properties)
print("Model supports parameters: {}".format(model.supports_parameters))
instantiator = stormpy.PdtmcInstantiator(model)
instantiator = stormpy.pars.PDtmcInstantiator(model)
point = dict()
parameters = model.collect_probability_parameters()
for x in parameters:
print(x.name)
point[x] = 0.4
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