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.

32 lines
1015 B

  1. from . import storage
  2. from .storage import *
  3. class ModelInstantiator:
  4. """
  5. Class for instantiating models.
  6. """
  7. def __init__(self, model):
  8. """
  9. Constructor.
  10. :param model: Model.
  11. """
  12. if model.model_type == ModelType.MDP:
  13. self._instantiator = PmdpInstantiator(model)
  14. elif model.model_type == ModelType.DTMC:
  15. self._instantiator = PdtmcInstantiator(model)
  16. elif model.model_type == ModelType.CTMC:
  17. self._instantiator = PctmcInstantiator(model)
  18. elif model.model_type == ModelType.MA:
  19. self._instantiator = PmaInstantiator(model)
  20. else:
  21. raise ValueError("Model type {} not supported".format(model.model_type))
  22. def instantiate(self, valuation):
  23. """
  24. Instantiate model with given valuation.
  25. :param valuation: Valuation from parameter to value.
  26. :return: Instantiated model.
  27. """
  28. return self._instantiator.instantiate(valuation)