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.

70 lines
2.7 KiB

  1. from . import core
  2. from .core import *
  3. from . import storage
  4. from .storage import *
  5. from .version import __version__
  6. core._set_up("")
  7. def build_model(program, properties = None):
  8. if properties:
  9. formulae = [prop.raw_formula for prop in properties]
  10. else:
  11. formulae = []
  12. intermediate = core._build_sparse_model_from_prism_program(program, formulae)
  13. assert not intermediate.supports_parameters
  14. if intermediate.model_type == ModelType.DTMC:
  15. return intermediate._as_dtmc()
  16. elif intermediate.model_type == ModelType.MDP:
  17. return intermediate._as_mdp()
  18. else:
  19. raise RuntimeError("Not supported non-parametric model constructed")
  20. def build_parametric_model(program, properties = None):
  21. if properties:
  22. formulae = [prop.raw_formula for prop in properties]
  23. else:
  24. formulae = []
  25. intermediate = core._build_sparse_parametric_model_from_prism_program(program, formulae)
  26. assert intermediate.supports_parameters
  27. if intermediate.model_type == ModelType.DTMC:
  28. return intermediate._as_pdtmc()
  29. elif intermediate.model_type == ModelType.MDP:
  30. return intermediate._as_pmdp()
  31. else:
  32. raise RuntimeError("Not supported parametric model constructed")
  33. def perform_bisimulation(model, property, bisimulation_type):
  34. if model.supports_parameters:
  35. return core._perform_parametric_bisimulation(model, property.raw_formula, bisimulation_type)
  36. else:
  37. return core._perform_bisimulation(model, property.raw_formula, bisimulation_type)
  38. def model_checking(model, property):
  39. if model.supports_parameters:
  40. return core._parametric_model_checking(model, property.raw_formula)
  41. else:
  42. return core._model_checking(model, property.raw_formula)
  43. def compute_prob01_states(model, phi_states, psi_states):
  44. if model.model_type != ModelType.DTMC:
  45. raise ValueError("Prob 01 is only defined for DTMCs -- model must be a DTMC")
  46. if model.supports_parameters:
  47. return core._compute_prob01states_rationalfunc(model, phi_states, psi_states)
  48. else:
  49. return core._compute_prob01states_double(model, phi_states, psi_states)
  50. def compute_prob01min_states(model, phi_states, psi_states):
  51. if model.supports_parameters:
  52. return core._compute_prob01states_min_rationalfunc(model, phi_states, psi_states)
  53. else:
  54. return core._compute_prob01states_min_double(model, phi_states, psi_states)
  55. def compute_prob01max_states(model, phi_states, psi_states):
  56. if model.supports_parameters:
  57. return core._compute_prob01states_max_rationalfunc(model, phi_states, psi_states)
  58. else:
  59. return core._compute_prob01states_max_double(model, phi_states, psi_states)