concepts.pdsketch.simulator_interface.PDSketchSimulatorInterface#
- class PDSketchSimulatorInterface[source]#
Bases:
object
The base class for interaction with a (physical simulator). This class serves two purposes:
perform simulation for planners. Therefore, it requires actions to support restore operations.
perform simulation when executing a given plan. In this case, restore operations are not required.
Methods
Get the latest PDSketch state.
get_pd_state
(action_index)Get the PDSketch state at a given action index.
get_restore_function
(action_index)Get the restore function for a given action index.
register_action_controller
(name, ...)Register a controller function for a controller name.
restore
(target_action_index[, verbose])Restore the simulator to a given action index.
restore_context
([verbose])A context manager for restoring the simulator to the current action index.
run
(action_index, action_name, action_args)Run an action, and return the success flag and the new PDSketch state.
run_operator_applier
(action_index, action)Execute an action, and return the success flag and the new PDSketch state.
set_init_state
(state)Set the initial PDSketch state of the simulator.
Attributes
The last action index.
Registered controllers.
Mappings from action indices to PDSketch states.
Mappings from action indices to controller states.
- __init__(executor)[source]#
Initialize the simulator interface.
- Parameters:
executor (PDSketchExecutor) – the
PDSketchExecutor
instance for grounding action parameters.
- __new__(**kwargs)#
- get_pd_state(action_index)[source]#
Get the PDSketch state at a given action index. -1 is the initial state.
- register_action_controller(name, controller_function)[source]#
Register a controller function for a controller name.
- restore_context(verbose=False)[source]#
A context manager for restoring the simulator to the current action index.
- run(action_index, action_name, action_args, verbose=False)[source]#
Run an action, and return the success flag and the new PDSketch state. This function will also store the restore function corresponding to the action.
- Parameters:
- Returns:
a tuple of (success, new PDSketch state).
- Return type:
- run_operator_applier(action_index, action)[source]#
Execute an action, and return the success flag and the new PDSketch state. This function will not store the restore function corresponding to the action.
- Parameters:
action_index (int) – the action index.
action (OperatorApplier) – the action to execute.
- Returns:
a tuple of (success, new PDSketch state).
- Return type:
- set_init_state(state)[source]#
Set the initial PDSketch state of the simulator.
- Parameters:
state (State)
- property last_action_index#
The last action index.