stormvogel.model.choices¶
Attributes¶
Classes¶
Represent a choice, which maps actions to branches. |
Functions¶
Create a |
Module Contents¶
- stormvogel.model.choices.ChoicesShorthand¶
- class stormvogel.model.choices.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
EmptyActionmay be used for a non-action choice. A singleChoicesinstance might correspond to multiple ‘arrows’.- Parameters:
choices – The choice dictionary. For each available action, a branch containing the transitions.
- _choices: dict[stormvogel.model.action.Action, stormvogel.model.distribution.Distribution[ValueType, State[ValueType]]]¶
- property actions: list[stormvogel.model.action.Action]¶
Return the actions for the choices.
- __str__()¶
- has_empty_action() bool¶
- is_stochastic(epsilon=1e-06) bool¶
Check whether the probabilities in the branches sum to 1.
- Parameters:
epsilon – Tolerance for floating-point comparison.
- Returns:
Trueif all branches are stochastic within epsilon.
- has_zero_transition() bool¶
Check whether any of the branches contains a zero-probability transition.
- Returns:
Trueif a zero-probability transition exists.
- add(other_choices: Self | ChoicesShorthand)¶
Add another
Choicesto this one in-place.- Parameters:
other – The choices to merge in.
- Raises:
RuntimeError – If the two choices have incompatible or overlapping actions.
- __iter__()¶
- __len__() int¶
- __setitem__(key, value)¶
- __getitem__(item)¶
- __delitem__(key)¶
- stormvogel.model.choices.choices_from_shorthand(shorthand: ChoicesShorthand) Choices[stormvogel.model.value.Value]¶
Create a
Choicesobject from aChoicesShorthand.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.
- Parameters:
shorthand – The shorthand representation to convert.
- Returns:
A new
Choicesinstance.