refine_plan.models.state_factor =============================== .. py:module:: refine_plan.models.state_factor .. autoapi-nested-parse:: Classes for representing state factors in Markov models. Author: Charlie Street Owner: Charlie Street Classes ------- .. autoapisummary:: refine_plan.models.state_factor.StateFactor refine_plan.models.state_factor.BoolStateFactor refine_plan.models.state_factor.IntStateFactor Module Contents --------------- .. py:class:: StateFactor(name, values) Bases: :py:obj:`object` Class representing a generic state factor. The state factor values are converted into list indexes when writing out in the PRISM language. .. attribute:: _name The name of the state factor .. attribute:: _values The valid values for that state factor .. attribute:: _hash_val A caching variable for the object's hash .. py:method:: get_value(idx) Get the state factor value at a given index. :param idx: The index :returns: The corresponding state factor value Throws: _bad_idx_exception: Thrown if an invalid index provided .. py:method:: get_idx(value) Get the index for a state factor value. :param value: The state factor value :returns: The corresponding index Throws: _bad_val_exception: Raised if an invalid state factor value is given .. py:method:: is_valid_value(value) Test if a value is valid for the state factor. :param value: The value to test :returns: True if in self._values, False otherwise .. py:method:: get_valid_values() Return the valid list of values for the state factor. :returns: The state factor values .. py:method:: get_name() Return the name of the state factor. :returns: The state factor name .. py:method:: to_prism_string(initial_value=None) Write the state factor out in PRISM format. :param initial_value: The initial value of that state factor, if applicable. :returns: The PRISM string for this state factor :raises bad_init_exception: Raised if initial_value is not valid value .. py:class:: BoolStateFactor(name) Bases: :py:obj:`StateFactor` A subclass of StateFactor which can only take values True and False. .. attribute:: Same as superclass. .. py:class:: IntStateFactor(name, min, max) Bases: :py:obj:`StateFactor` A subclass of StateFactor purely for integer state factors. Here, the values and indexes are the same thing. .. attribute:: Same as superclass. .. py:method:: get_value(idx) Identity function as indexes and values are the same here. :param idx: The index :returns: The corresponding state factor value Throws: _bad_idx_exception: Thrown if an invalid index provided .. py:method:: get_idx(value) Identity function as indexes and values are the same here. :param value: The state factor value :returns: The corresponding index Throws: _bad_val_exception: Raised if an invalid state factor value is given