dynadojo.systems.utils.simple.SimpleSystem#

class dynadojo.systems.utils.simple.SimpleSystem#

Bases: AbstractSystem

An extension of AbstractSystem with some useful methods.

Methods

__init__([latent_dim, embed_dim, seed, ...])

Initialize the class.

calc_control_cost(control)

Calculates the L2 norm / dimension of every vector in the control

calc_dynamics(t, x)

Calculates the dynamics for the system.

calc_error(x, y)

Returns the MSE error normalized by the embedded dimension.

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

Uses the calc_dynamics() method to generate data.

make_init_conds(n[, in_dist])

Uniformly samples embedded-dimensional points from an inside or outside distribution

Attributes

controller

The controller matrix.

embed_dim

The embedded dimension for the system.

embedder

The embedder matrix.

latent_dim

The latent dimension for the system.

seed

The random seed for the system.

__init__(latent_dim=2, embed_dim=2, seed=None, embedder_sv_range=(0.1, 1), controller_sv_range=(0.1, 1), IND_range=(0, 10), OOD_range=(-10, 0), noise_scale=0.01, t_range=(0, 1))#

Initialize the class.

Parameters:
  • latent_dim (int, optional) – Dimension of the latent space.

  • embed_dim (int, optional) – Embedded dimension of the system.

  • seed (int or None, optional) – Seed for random number generation.

  • embedder_sv_range (tuple, optional) – The singular value range for the embedder matrix. Singular values are non-negative by convention. The singular values should exclude 0 to ensure the embedder is invertible.

  • controller_sv_range (tuple, optional) – The singular value range for the controller matrix.

  • IND_range (tuple, optional) – The in-distribution initial condition range.

  • OOD_Range (tuple) – The out-of-distribution initial condition range.

  • t_range (tuple, optional) – The interval over which to generate the solution trajectories. For example, if t_range = (0, 1) and make_data() were called with timesteps = 10, then the trajectory would be generated with 10 timesteps between 0 and 1.

  • noise_scale (float, optional) – Normal noise is added per timestep to a solution. Standard deviation (spread or “width”) of the distribution. Must be non-negative.

  • **kwargs – Additional keyword arguments.

calc_control_cost(control)#

Calculates the L2 norm / dimension of every vector in the control

Parameters:

control (ndarray) –

Return type:

float

calc_dynamics(t, x)#

Calculates the dynamics for the system. Your class must implement this.

calc_error(x, y)#

Returns the MSE error normalized by the embedded dimension.

Return type:

float

property controller#

The controller matrix. For example, in a system \(\dot{x} = Ax + Bu\), the controller is \(B\).

property embed_dim#

The embedded dimension for the system.

property embedder#

The embedder matrix. An invertible map from the latent space to the embedding space.

property latent_dim#

The latent dimension for the system.

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

Uses the calc_dynamics() method to generate data. Mathematically, data is generated like \(\dot{x} = f(x) + Bu\). Where \(f(x)\) is given by calc_dynamics().

Parameters:
  • init_conds (numpy.ndarray) – (n, embed_dim) Initial conditions matrix.

  • control (numpy.ndarray) – (n, timesteps, embed_dim) Controls tensor.

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

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

Returns:

(n, timesteps, embed_dim) Trajectories tensor.

Return type:

numpy.ndarray

make_init_conds(n, in_dist=True)#

Uniformly samples embedded-dimensional points from an inside or outside distribution

Note

Systems developers determine what counts as in vs out-of-distribution. DynaDojo doesn’t provide any verification that this distinction makes sense or even exists. See LDSystem for a principled example.

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

  • in_dist (bool, optional) – 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:

numpy.ndarray

property seed#

The random seed for the system.