stormvogel.model.choices

Attributes

Classes

Choices

Represent a choice, which maps actions to branches.

Functions

choices_from_shorthand(...)

Create a Choices object from a ChoicesShorthand.

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 EmptyAction may be used for a non-action choice. A single Choices instance 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:

True if all branches are stochastic within epsilon.

has_zero_transition() bool

Check whether any of the branches contains a zero-probability transition.

Returns:

True if a zero-probability transition exists.

add(other_choices: Self | ChoicesShorthand)

Add another Choices to this one in-place.

Parameters:

other – The choices to merge in.

Raises:

RuntimeError – If the two choices have incompatible or overlapping actions.

__add__(other: Self | ChoicesShorthand) Choices[ValueType]
__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 Choices object from a 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.

Parameters:

shorthand – The shorthand representation to convert.

Returns:

A new Choices instance.