dymad.utils.control

Classes

ControlInterpolator(t, u[, axis, order])

Interpolates the sampled control signal u(t_k) when the ODE solver requests u(t_query).

class dymad.utils.control.ControlInterpolator(t, u, axis=-2, order='linear')

Bases: Module

Interpolates the sampled control signal u(t_k) when the ODE solver requests u(t_query).

Parameters:
  • t (torch.Tensor) – 1-D tensor of shape (N,). Sampling times (must be ascending).

  • u (torch.Tensor) – Tensor of shape (…, N, m). Control samples, m inputs per step.

  • axis (int) – Axis of u that corresponds to time. Default is -2.

  • order (str) – Interpolation mode. One of {‘none’, ‘zoh’, ‘linear’, ‘cubic’, etc}.

Note

Not to be confused with dymad.utils.sampling._build_interpolant, which is for data generation, esp. with Numpy. ControlInterpolator is meant to be used in a Torch setting.

forward(t_query)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Return type:

Tensor | None

t: torch.Tensor
training: bool
u: torch.Tensor | None