dynadojo.systems.utils.opinion.OpinionSystem#

class dynadojo.systems.utils.opinion.OpinionSystem#

Bases: AbstractSystem

Methods

__init__(latent_dim, embed_dim, noise_scale, ...)

Initialize the class.

calc_control_cost(control)

Calculate the control cost for each control trajectory (i.e., calculates the costs for every control matrix, not for the whole tensor).

calc_error(x, y)

Calculates the error between two tensors of trajectories.

create_model(x0)

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

Makes trajectories from initial conditions.

make_init_conds(n[, in_dist])

Generate initial conditions..

Attributes

embed_dim

The embedded dimension for the system.

latent_dim

The latent dimension for the system.

seed

The random seed for the system.

__init__(latent_dim, embed_dim, noise_scale, IND_range, OOD_range, seed=None)#

Initialize the class.

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

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

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

  • **kwargs – Additional keyword arguments.

calc_control_cost(control)#

Calculate the control cost for each control trajectory (i.e., calculates the costs for every control matrix, not for the whole tensor).

Parameters:

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

Returns:

(n,) Control costs vector.

Return type:

numpy.ndarray

calc_error(x, y)#

Calculates the error between two tensors of trajectories.

Parameters:
  • x (numpy.ndarray) – (n, timesteps, embed_dim) Trajectories tensor.

  • y (numpy.ndarray) – (n, timesteps, embed_dim) Trajectories tensor.

Returns:

The error between x and y.

Return type:

float

property embed_dim#

The embedded dimension for the system.

property latent_dim#

The latent dimension for the system.

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

Makes trajectories from initial conditions.

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)#

Generate initial conditions..

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.