refine_plan.models.policy
Class for deterministic memoryless policies and time-dependent policies.
Author: Charlie Street Owner: Charlie Street
Classes
Data class for deterministic memoryless policies. |
|
Data class for time dependent policies. |
Module Contents
- class refine_plan.models.policy.Policy(state_action_dict, value_dict=None, policy_file=None)
Bases:
objectData class for deterministic memoryless policies.
- _state_action_dict
A dictionary from states to actions
- _value_dict
A dictionary from states to values under that policy
- get_action(state)
Return the policy action for a given state.
- Parameters:
state – The state we want an action for
- Returns:
The policy action
- get_value(state)
Return the value at a given state.
- Parameters:
state – The state we want to retrieve the value for
- Returns:
The value at state
- Raises:
no_value_dict_exception – Raised if there is no value dictionary
- write_policy(out_file)
Write a policy with all state factor information to a YAML file.
- Parameters:
out_file – The yaml file to write to
- to_scxml(output_file, model_name, initial_state, name='policy')
Write the policy out to SCXML for verification.
- Parameters:
output_file – The file to write out to
model_name – The name of the model actions are executed on
initial_state – The initial state
name – The name for the policy in SCXML
- class refine_plan.models.policy.TimeDependentPolicy(state_action_dicts, value_dicts=None, policy_file=None)
Bases:
PolicyData class for time dependent policies.
In _state_action_dicts and _value_dicts, the list index refers to the timestep.
- _state_action_dicts
A list of dictionaries from states to actions
- _value_dicts
A list of dictionaries from states to values under that policy
- get_action(state, time)
Return the policy action for a given state and time.
- Parameters:
state – The state we want an action for
time – The current timestep
- Returns:
The policy action
- get_value(state, time)
Return the value at a given state and time.
- Parameters:
state – The state we want to retrieve the value for
time – The current timestep
- Returns:
The value at state at time
- Raises:
no_value_dict_exception – Raised if there is no value dictionary
- write_policy(out_file)
Write a policy with all state factor information to a YAML file.
- Parameters:
out_file – The yaml file to write to
- abstractmethod to_scxml(output_file, model_name, initial_state, name='policy')
Write the policy out to SCXML for verification.
- Parameters:
output_file – The file to write out to
model_name – The name of the model actions are executed on
initial_state – The initial state
name – The name for the policy in SCXML