Simulator

Action simulator combines simulator interface with action mappers.

Simulator takes a list of tasks at initialization, builds agent-readable representation for them, and provides interface to run simulation in a specified action tier.

phyre.ACTION_TIERS = ('ball', 'two_balls')

List of action tiers in phyre.

phyre.initialize_simulator(task_ids: Sequence[str], action_tier: str) → phyre.action_simulator.ActionSimulator

Initialize ActionSimulator for given tasks and tier.

class phyre.ActionSimulator(tasks: Union[Sequence[phyre.interface.task.ttypes.Task], Mapping[str, phyre.interface.task.ttypes.Task]], action_mapper, no_goals: bool = True)

Interface to query the simulator with actions within the tier.

property action_space_dim

Return dimension of the actions space.

build_discrete_action_space(max_actions, seed=1) → Sequence[Union[Sequence[float], numpy.ndarray]]

Build a mapping from the given number of action to the action space.

Parameters
  • max_actions – int, maximum number of discrete actions.

  • seed – int, random seed to generate the subspace.

Returns

tuple of actions of length max_actions.

Return type

discrete_actions

property goals

Represents goals for each task.

uint8 array with shape (task, 3). Each goal is encoded with three numbers: (obj_type1, obj_type2, rel). All three are less than MAX_GOAL. To be more precise, obj_types are less than MAX_OBJECT_TYPE and rel is less than MAX_RELATION.

property initial_scenes

Represents intial scene for each task before agent input.

uint8 array with shape (task, height, width).

sample(valid_only=True, rng=None) → Union[Sequence[float], numpy.ndarray]

Sample a random (valid) action from the action space.

simulate_single(task_index: int, action: Union[Sequence[float], numpy.ndarray], need_images: bool = True, stride: int = 60, stable: bool = False) → Tuple[phyre.action_simulator.SimulationStatus, Optional[numpy.ndarray]]

Runs simluation for the action.

Parameters
  • task_index – index of the task.

  • action – numpy array or list of self.action_space_dim floats in [0, 1].

  • need_images – whether simulation images are needed.

  • stride – int, defines the striding for the simulation images array. Higher striding will result in less images and less compute. Note, that this parameter doesn’t affect simulation FPS. Ignored if need_images is False.

  • stable – if True, will simulate a few actions in the neigborhood of the actions and return STABLY_SOLVED status iff all neigbour actions are either SOLVED or INVALID. Otherwise UNSTABLY_SOLVED is returned. SOLVED is never returned if stable is set.

Returns

  • If need_images is True, returns a pair (status, images).
    • If status is INVALID_INPUT images is None.

    • Otherwise images is an array contains intermediate observations.

  • If need_images is False: returns (status, None).

property task_ids

Tuple of task ids in simulator.

class phyre.SimulationStatus

Status that ActionSimulator returns given a task and an action.

is_invalid() → bool

whether the action is invalid for the task.

is_not_solved() → bool

Whether the action is valid, but doesn’t solve the task.

is_solved() → bool

Whether the action solved the task.

is_stably_solved() → bool

Whether the action is stable solution for the task.

This only applies if the simulation was called with stable flag.