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.

61 lines
1.6 KiB

  1. ****************************
  2. Getting Started
  3. ****************************
  4. A Quick Tour through Stormpy
  5. ================================
  6. We start with a selection of high-level constructs in stormpy.
  7. In order to do this, we import stormpy::
  8. import stormpy
  9. import stormpy.core
  10. Building models
  11. -----------------------
  12. There are several ways to create a Markov chain.
  13. One of the easiest is to parse a description of such a Markov chain and to let storm build the chain.
  14. Here, we build a Markov chain from a prism program.
  15. Stormpy comes with a small set of examples, which we use here::
  16. import stormpy.examples
  17. import stormpy.examples.files
  18. With this, we can now import the path of our prism file::
  19. path = stormpy.examples.files.knuth_yao
  20. prism_program = stormpy.parse_prism_program(path)
  21. The `prism_program` can be translated into Markov chains::
  22. model = stormpy.build_model(program_program)
  23. print("Number of states: {}".format(model.nr_states))
  24. Building properties
  25. --------------------------
  26. Storm takes properties in the prism-property format. To express that one is interested in the reachability of any state where the prism program variable s is 7 and d is 2, one would formulate::
  27. P=? [F s=7 & d=2]
  28. Stormpy can be used to parse this. As the variables in the property refer to a program, the program has to be passed as an additional parameter::
  29. formula_str = "P=? [F s=7 & d=2]"
  30. properties = parse_properties_for_prism_program(formula_str, prism_program)
  31. Notice that properties is now a list of properties containing a single element.
  32. Checking properties
  33. ---------------------------