dair_pll.system

System abstract type definition.

This file contains the fundamental System interface for dynamical systems. Systems are defined by their underlying dynamics; integration scheme; and an initial condition sampler for both states and hidden states/carry.

Unlike Integrator, System requires a temporal sequence of initial condition states; this is done to accommodate systems with hidden states that behave differently when “preloaded” with an initialization trajectory, such as a UKF estimator or an RNN.

System is used to interface with external simulators, e.g. Drake and MuJoCo.

class dair_pll.system.MeshSummary(vertices=tensor([], dtype=torch.float32), faces=tensor([], dtype=torch.float32))[source]

Bases: object

dataclasses.dataclass() for mesh visualization.

vertices: torch.Tensor = tensor([], dtype=torch.float32)

Vertices in mesh, (n_vert, 3).

faces: torch.Tensor = tensor([], dtype=torch.float32)

3-tuple indices of vertices that form faces, (n_face, 3).

class dair_pll.system.SystemSummary(scalars=<factory>, videos=<factory>, meshes=<factory>)[source]

Bases: object

dataclasses.dataclass() for reporting information about the progress of a training run.

scalars: typing.Dict[str, float]
videos: typing.Dict[str, typing.Tuple[numpy.ndarray, int]]
meshes: typing.Dict[str, dair_pll.system.MeshSummary]
class dair_pll.system.System(space, integrator, max_batch_dim=None)[source]

Bases: ABC, Module

Class for encapsulating a dynamical system.

Primarily implemented as a thin shell of Integrator with various sampling interfaces defined.

A major difference from the Integrator interface is that System accepts a sequence of states, along with a single carry/hidden state, as an initial condition to accommodate proper initialization of some types of recurrent dynamics.

Inits System with prescribed integration properties.

Parameters:
  • space (StateSpace) – State space of underlying dynamics

  • integrator (Integrator) – Integrator of underlying dynamics

  • max_batch_dim (Optional[int]) – Maximum number of batch dimensions supported by

  • integrator.

space: dair_pll.state_space.StateSpace
integrator: dair_pll.integrator.Integrator
state_sampler: dair_pll.state_space.StateSpaceSampler
carry_callback: typing.Optional[typing.Callable[[], Tensor]]
max_batch_dim: typing.Optional[int]
sample_trajectory(length)[source]

Sample

Parameters:

length (int) – duration of trajectory in number of time steps

Return type:

Tuple[Tensor, Tensor]

Returns:

(length, space.nx) state trajectory (length, ?) carry trajectory

simulate(x_0, carry_0, steps=1)[source]

Simulate forward in time from initial condition.

Parameters:
  • x_0 (Tensor) – (*, T_0, space.n_x) initial state sequence

  • carry_0 (Tensor) – (*, ?) initial hidden state

  • steps (int) – number of steps to take beyond initial condition

Return type:

Tuple[Tensor, Tensor]

Returns:

(*, steps + 1, space.n_x) state trajectory (*, steps + 1, ?) hidden state trajectory

sample_initial_condition()[source]

Queries state and hidden state samplers for initial condition.

Return type:

Tuple[Tensor, Tensor]

set_state_sampler(sampler)[source]

Setter for state initial condition sampler.

Return type:

None

set_carry_sampler(callback)[source]

Setter for hidden state initial condition sampler.

Return type:

None

preprocess_initial_condition(x_0, carry_0)[source]

Preprocesses initial condition state sequence into single state initial condition for integration.

For example, an RNN would use the state sequence to “preload” hidden states in the RNN, where carry_0 would provide an initial hidden state, and the output would be the hidden state after the RNN receives the state sequence.

Parameters:
  • x_0 (Tensor) – (*, T_0, space.n_x) initial state sequence.

  • carry_0 (Tensor) – (*, ?) initial hidden state.

Return type:

Tuple[Tensor, Tensor]

Returns:

(*, space.n_x) processed initial state. (*, ?) processed initial hidden state.

summary(statistics)[source]

Summarizes the current behavior and properties of the system.

Parameters:

statistics (Dict) – dictionary of training statistics

Return type:

SystemSummary

Returns:

Summary of system.