stormvogel.model.reward_model¶
Reward model.
Classes¶
Represent a reward model supporting state rewards and transition rewards. |
Module Contents¶
- class stormvogel.model.reward_model.RewardModel[ValueType: stormvogel.model.value.Value]¶
Represent a reward model supporting state rewards and transition rewards.
- Parameters:
name – Name of the reward model.
model – The model this reward model belongs to.
rewards – Mapping from states to their state reward values.
transition_rewards – Sparse mapping from (source, action, target) triples to reward values collected on that specific transition.
- name: str¶
- rewards: dict[stormvogel.model.state.State, ValueType]¶
- transition_rewards: dict[tuple[stormvogel.model.state.State, stormvogel.model.action.Action, stormvogel.model.state.State], ValueType]¶
- set_from_rewards_vector(vector: list[ValueType], state_action: bool = False) None¶
Set the rewards of this model according to a (stormpy) rewards vector.
- Parameters:
vector – The reward values.
state_action – If
True, the vector has one entry per (state, action) pair; only the first entry for each state is used.
- get_state_reward(state: stormvogel.model.state.State) ValueType | None¶
Get the reward at the given state.
- Parameters:
state – The state to look up.
- Returns:
The reward value, or
Noneif no reward is present.
- set_state_reward(state: stormvogel.model.state.State, value: ValueType)¶
Set the reward at the given state.
- Parameters:
state – The state to set the reward for.
value – The reward value to assign.
- set_unset_rewards(value: ValueType)¶
Fill up rewards that were not set yet with the specified value.
- Parameters:
value – The default reward value to assign to unset states.
- has_transition_rewards() bool¶
Return True if any nonzero transition reward is present.
- set_transition_reward(s: stormvogel.model.state.State, a: stormvogel.model.action.Action, s_next: stormvogel.model.state.State, value: ValueType) None¶
Set the reward collected when transitioning from s via a to s_next.
- get_transition_reward(s: stormvogel.model.state.State, a: stormvogel.model.action.Action, s_next: stormvogel.model.state.State) ValueType¶
Return the transition reward for (s, a, s_next), or 0 if absent.
- __iter__()¶
- get_reward_vector() list[float]¶
Return a list of all rewards ordered appropriately.
- Returns:
A flat list of reward values as floats.