dynadojo.wrappers.AlgorithmChecker#

class dynadojo.wrappers.AlgorithmChecker#

Bases: object

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

Example

>>> from dynadojo.baselines.lr import LinearRegression
>>> AlgorithmChecker(LinearRegression(2, 50, 0))
<AlgorithmChecker<LinearRegression>>

Methods

__init__(alg)

Initialize the AlgorithmChecker object

act(x, **kwargs)

Verifies control tensor is the right shape.

fit(x, **kwargs)

Verifies algorithm trains on properly sized data.

predict(x0, timesteps, **kwargs)

Verifies predicted trajectories tensor has the right shape.

Attributes

embed_dim

The embedding dimension of the underlying algorithm.

max_control_cost

The max control cost for the underlying algorithm.

seed

The random seed for the underlying algorithm.

timesteps

The number of timesteps for the underlying algorithm.

__init__(alg)#

Initialize the AlgorithmChecker object

Parameters:

alg (AbstractAlgorithm) – Underlying algorithm.

act(x, **kwargs)#

Verifies control tensor is the right shape.

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

  • **kwargs – Additional keyword arguments.

Returns:

(n, timesteps, embed_dim) controls tensor

Return type:

np.ndarray

property embed_dim#

The embedding dimension of the underlying algorithm.

fit(x, **kwargs)#

Verifies algorithm trains on properly sized data.

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

  • **kwargs – Additional keyword arguments.

Return type:

None

property max_control_cost#

The max control cost for the underlying algorithm.

predict(x0, timesteps, **kwargs)#

Verifies predicted trajectories tensor has the right shape.

Parameters:
  • x0 (np.ndarray) – (n, embed_dim) Initial conditions matrix.

  • timesteps (int) – Timesteps per predicted trajectory (most commonly the same as the system timesteps).

  • **kwargs – Additional keyword arguments.

Returns:

(n, timesteps, embed_dim) Predicted trajectories tensor.

Return type:

np.ndarray

property seed#

The random seed for the underlying algorithm.

property timesteps#

The number of timesteps for the underlying algorithm.