stormvogel.model.choices ======================== .. py:module:: stormvogel.model.choices Attributes ---------- .. autoapisummary:: stormvogel.model.choices.ChoicesShorthand Classes ------- .. autoapisummary:: stormvogel.model.choices.Choices Functions --------- .. autoapisummary:: stormvogel.model.choices.choices_from_shorthand Module Contents --------------- .. py:data:: ChoicesShorthand .. py:class:: Choices[ValueType: stormvogel.model.value.Value](choices: dict[stormvogel.model.action.Action, stormvogel.model.distribution.Distribution[ValueType, State[ValueType]]]) Represent a choice, which maps actions to branches. An :class:`EmptyAction` may be used for a non-action choice. A single ``Choices`` instance might correspond to multiple 'arrows'. :param choices: The choice dictionary. For each available action, a branch containing the transitions. .. py:attribute:: _choices :type: dict[stormvogel.model.action.Action, stormvogel.model.distribution.Distribution[ValueType, State[ValueType]]] .. py:property:: actions :type: list[stormvogel.model.action.Action] Return the actions for the choices. .. py:method:: __str__() .. py:method:: has_empty_action() -> bool .. py:method:: is_stochastic(epsilon=1e-06) -> bool Check whether the probabilities in the branches sum to 1. :param epsilon: Tolerance for floating-point comparison. :returns: ``True`` if all branches are stochastic within *epsilon*. .. py:method:: has_zero_transition() -> bool Check whether any of the branches contains a zero-probability transition. :returns: ``True`` if a zero-probability transition exists. .. py:method:: add(other_choices: Self | ChoicesShorthand) Add another :class:`Choices` to this one in-place. :param other: The choices to merge in. :raises RuntimeError: If the two choices have incompatible or overlapping actions. .. py:method:: __add__(other: Self | ChoicesShorthand) -> Choices[ValueType] .. py:method:: __iter__() .. py:method:: __len__() -> int .. py:method:: __setitem__(key, value) .. py:method:: __getitem__(item) .. py:method:: __delitem__(key) .. py:function:: choices_from_shorthand(shorthand: ChoicesShorthand) -> Choices[stormvogel.model.value.Value] Create a :class:`Choices` object from a :data:`ChoicesShorthand`. Two shorthand modes are supported: - A list of ``(probability, target_state)`` tuples (implies the default action when in an MDP). - A list of ``(action, target_state)`` tuples (implies probability 1). - A dict mapping actions to lists of ``(probability, target_state)`` tuples. :param shorthand: The shorthand representation to convert. :returns: A new :class:`Choices` instance.