dynadojo.wrappers.SystemChecker#

class dynadojo.wrappers.SystemChecker#

Bases: object

Wrapper class for systems that ensures proper input and output handling.

Methods

__init__(system)

Initialize the SystemChecker object.

calc_control_cost(control)

Wraps calc_control_cost.

calc_error(x, y)

Checks that calc_error is called with properly-shaped x and y.

make_data(init_conds[, control, timesteps, ...])

Checks that trajectories tensor has the proper shape.

make_init_conds(n[, in_dist])

Verifies initial condition matrix is the right shape.

Attributes

embed_dim

The embedded dimension of the underlying system.

latent_dim

The latent dimension of the underlying system.

seed

The seed for the underlying system.

__init__(system)#

Initialize the SystemChecker object.

Parameters:

system (AbstractSystem) – The underlying system.

Example

>>> from dynadojo.systems.lds import LDSystem
>>> SystemChecker(LDSystem())
<SystemChecker<LDSystem>>
calc_control_cost(control)#

Wraps calc_control_cost.

Parameters:

control (np.ndarray) – (n, timesteps, embed_dim) control tensor

Returns:

(n,) control costs vector

Return type:

np.ndarray

calc_error(x, y)#

Checks that calc_error is called with properly-shaped x and y.

Parameters:
  • x (np.ndarray) – (n, timesteps, embed_dim) trajectories tensor

  • y (np.ndarray) – (n, timesteps, embed_dim) trajectories tensor

Returns:

Error between x and y.

Return type:

float

property embed_dim#

The embedded dimension of the underlying system.

property latent_dim#

The latent dimension of the underlying system.

make_data(init_conds, control=None, timesteps=1, noisy=False)#

Checks that trajectories tensor has the proper shape.

Parameters:
  • init_conds (np.ndarray) – (n, embed_dim) initial conditions matrix

  • control (np.ndarray) – (n, embed_dim) initial conditions matrix

  • timesteps (int) – timesteps per training trajectory (per action horizon)

  • noisy (bool) – If True, add noise to trajectories. Defaults to False. If False, no noise is added.

Returns:

(n, timesteps, embed_dim) trajectories tensor

Return type:

np.ndarray

make_init_conds(n, in_dist=True)#

Verifies initial condition matrix is the right shape.

Parameters:
  • n (int) – Number of initial conditions.

  • in_dist (bool) – If True, generate in-distribution initial conditions. Defaults to True. If False, generate out-of-distribution initial conditions.

Returns:

(n, embed_dim) Initial conditions matrix.

Return type:

np.ndarray

property seed#

The seed for the underlying system.