You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

3 months ago
  1. import stormpy
  2. import stormpy.core
  3. import pycarl
  4. import pycarl.core
  5. import stormpy.examples
  6. import stormpy.examples.files
  7. import stormpy._config as config
  8. def example_parametric_models_01():
  9. # Check support for parameters
  10. if not config.storm_with_pars:
  11. print("Support parameters is missing. Try building storm-pars.")
  12. return
  13. import stormpy.pars
  14. path = stormpy.examples.files.prism_pdtmc_die
  15. prism_program = stormpy.parse_prism_program(path)
  16. formula_str = "P=? [F s=7 & d=2]"
  17. properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
  18. model = stormpy.build_parametric_model(prism_program, properties)
  19. print("Model supports parameters: {}".format(model.supports_parameters))
  20. parameters = model.collect_probability_parameters()
  21. assert len(parameters) == 2
  22. instantiator = stormpy.pars.PDtmcInstantiator(model)
  23. point = dict()
  24. for x in parameters:
  25. print(x.name)
  26. point[x] = stormpy.RationalRF(0.4)
  27. instantiated_model = instantiator.instantiate(point)
  28. result = stormpy.model_checking(instantiated_model, properties[0])
  29. print(result)
  30. if __name__ == '__main__':
  31. example_parametric_models_01()