stormvogel.model.state¶
A model state.
Classes¶
Represent a state in a Model. |
Module Contents¶
- class stormvogel.model.state.State[ValueType: stormvogel.model.value.Value]¶
Represent a state in a Model.
- Parameters:
model – The model this state belongs to.
state_id – The unique identifier of this state.
- state_id: uuid.UUID¶
- property labels: Iterable[str]¶
Return an iterator over the state’s labels.
- set_friendly_name(friendly_name: str | None) None¶
- property friendly_name: str | None¶
Returns the friendly name of this state.
- set_labels(labels: set[str])¶
Set the labels of this state, adding and removing as needed.
- Parameters:
labels – The complete set of labels this state should have.
- has_label(label: str)¶
Check whether this state has the given label.
- Parameters:
label – The label to check for.
- Returns:
Trueif the label is present.
- add_label(label: str)¶
Add a new label to this state.
- Parameters:
label – The label to add.
- property observation: stormvogel.model.observation.Observation | stormvogel.model.distribution.Distribution[ValueType, stormvogel.model.observation.Observation] | None¶
Return the observation associated with this state.
- Raises:
RuntimeError – If the model does not support observations.
- property choices: Choices[ValueType]¶
Return the choices for this state.
- Raises:
RuntimeError – If no choices exist for this state.
- property unique_branch: Distribution[ValueType, State[ValueType]]¶
Return the single branch of this state.
- Raises:
RuntimeError – If the state does not have exactly one choice.
- property unique_choice: tuple[Action, Distribution[ValueType, State[ValueType]]]¶
Return the single
(action, branch)pair of this state.- Raises:
RuntimeError – If the state does not have exactly one choice.
- set_choices(choices: stormvogel.model.choices.Choices | stormvogel.model.choices.ChoicesShorthand)¶
Set the choices for this state.
- Parameters:
choices – The choices to set.
- add_choices(choices: stormvogel.model.choices.Choices | stormvogel.model.choices.ChoicesShorthand)¶
Add choices to this state.
- Parameters:
choices – The choices to add.
- has_choices() bool¶
Check whether this state has choices.
- property nr_choices: int¶
The number of choices in this state.
- property valuations: dict[stormvogel.model.variable.Variable, Any]¶
The valuations of this state.
- add_valuation(variable: stormvogel.model.variable.Variable, value: Any)¶
Add a valuation to this state.
- Parameters:
variable – The variable name.
value – The value for the variable.
- get_valuation(variable: stormvogel.model.variable.Variable) Any¶
Return the valuation for the given variable.
- Parameters:
variable – The variable name.
- Returns:
The value associated with the variable.
- available_actions() list[stormvogel.model.action.Action]¶
Return the list of available actions in this state.
- get_branches(action: stormvogel.model.action.Action | None = None) stormvogel.model.distribution.Distribution[ValueType, State[ValueType]]¶
Get the branches of this state for a specific action.
- Parameters:
action – The action to get branches for.
- Returns:
The branches.
- Raises:
RuntimeError – If the requested action does not exist for this state.
- get_outgoing_transitions(action: stormvogel.model.action.Action | None = None) stormvogel.model.distribution.Distribution[ValueType, State[ValueType]] | None¶
Get the outgoing transitions of this state for a specific action.
- Parameters:
action – The action to get transitions for.
- Returns:
The distribution over successor states, or
Noneif not found.- Raises:
RuntimeError – If the model supports actions but none is provided.
- is_absorbing() bool¶
Check whether this state is absorbing (no nonzero transitions to other states).
- has_selfloop() bool¶
Check whether this state has a self-loop.
Returns
Trueif any action has a transition back to this state with positive probability. For interval models a transition counts as positive when its upper bound is non-zero; for parametric models when the expression is not syntactically zero.- Returns:
Trueif a self-loop exists,Falseotherwise.
- is_initial()¶
Check whether this state is the initial state.
- __repr__()¶
- __str__¶