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.

36 lines
1.6 KiB

  1. import stormpy
  2. import stormpy.examples
  3. import stormpy.examples.files
  4. class TestBuilding:
  5. def test_explicit_builder(self):
  6. path = stormpy.examples.files.prism_dtmc_die
  7. prism_program = stormpy.parse_prism_program(path)
  8. formula_str = "P=? [F s=7 & d=2]"
  9. properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
  10. # Fix variables in the program.
  11. module = prism_program.modules[0]
  12. s_var = module.get_integer_variable("s").expression_variable
  13. d_var = module.get_integer_variable("d").expression_variable
  14. # Construct the model
  15. options = stormpy.BuilderOptions([p.raw_formula for p in properties])
  16. options.set_build_state_valuations()
  17. model_builder = stormpy.make_sparse_model_builder(prism_program, options)
  18. model = model_builder.build()
  19. # and export the model from building
  20. state_mapping = model_builder.export_lookup()
  21. #lookup 1
  22. state = { s_var : prism_program.expression_manager.create_integer(3), d_var : prism_program.expression_manager.create_integer(0)}
  23. id = state_mapping.lookup(state)
  24. assert model.state_valuations.get_integer_value(id, s_var) == 3
  25. assert model.state_valuations.get_integer_value(id, d_var) == 0
  26. #lookup 2
  27. state = { s_var : prism_program.expression_manager.create_integer(7), d_var : prism_program.expression_manager.create_integer(3)}
  28. id = state_mapping.lookup(state)
  29. assert model.state_valuations.get_integer_value(id, s_var) == 7
  30. assert model.state_valuations.get_integer_value(id, d_var) == 3