Skip to content

ssqpy.model.dynamics

dynamics

Submodule containing classes for assigning custom dynamics to
optimization stages. This includes the general StageDynamics class,
which must be subclassed and have the relevant methods overridden to
define custom dynamics.

StageDynamics

General abstract dynamics function for an optimization stage \(k\): \(\boldsymbol{f}_k(\boldsymbol{x}, \boldsymbol{u})\)
Defines the required functions for stage dynamics, while providing
default implementations for some

names

names()

Get all dynamics' names for StageDynamics.

output_size

output_size()

Get the dynamics function output size.

state_size

state_size()

Size of state vector \(\boldsymbol{x}\).

control_size

control_size()

Size of control vector \(\boldsymbol{u}\).

state_diff_size

state_diff_size()

Size of the difference vector: \(\boldsymbol{x}_1 \ominus \boldsymbol{x}_2\)
Where \(\ominus\): the defined right_minus operator

init_state

init_state()

Initial state vector (size \(n_x\)) (default \(\boldsymbol{0}\)).

init_control

init_control()

Initial control vector (size \(n_u\)) (default \(\boldsymbol{0}\)).

state_right_plus

state_right_plus(x, dx)

Defines right plus operator between state vector and tangent space vector
Inputs: State vector \(\boldsymbol{x}\) (size \(n_x\)), state difference vector \(\boldsymbol{dx}\) (size \(n_{dx}\))
Output: State \(\boldsymbol{y}\) (size \(n_x\))
Default behavior: \(\boldsymbol{x} + \boldsymbol{dx}\)

state_right_minus

state_right_minus(x, y)

Defines right minus operator between states
Inputs: Composite states \(\boldsymbol{x}\), \(\boldsymbol{y}\) (vectors/lie group elements, size \(n_x\))
Output: State difference vector \(\boldsymbol{dx}\) (size \(n_{dx}\))
Default behavior: \(\boldsymbol{x} - \boldsymbol{y}\)

evaluate

evaluate(x, u)

Evaluate function \(f(\boldsymbol{x}, \boldsymbol{u})\)
Returns: output vector, \(n \times 1\)

gradient

gradient(x, u)

Get dynamics Jacobians with respect to \(\boldsymbol{x}\) and \(\boldsymbol{u}\), evaluated at
given \((\boldsymbol{x}, \boldsymbol{u})\): \(\nabla_x \boldsymbol{f}_k(\boldsymbol{x}, \boldsymbol{u})\) and \(\nabla_u \boldsymbol{f}_k(\boldsymbol{x}, \boldsymbol{u})\)
Returns:
dX: gradient with respect to \(\boldsymbol{x}\), \(n_{dx} \times n_{dx}\)
dU: gradient with respect to \(\boldsymbol{u}\), \(n_{dx} \times n_u\)

hessprod_xx

hessprod_xx(x, u, lam)

Get product \(\nabla_{x} \lambda_k^\top \nabla_{x} \boldsymbol{f}_k(\boldsymbol{x}, \boldsymbol{u})\)
Returns:
Pxx: Product, \(n_{dx} \times n_{dx}\)

hessprod_xu

hessprod_xu(x, u, lam)

Get product \(\nabla_{x} \lambda_k^\top \nabla_{u} \boldsymbol{f}_k(\boldsymbol{x}, \boldsymbol{u})\)
Returns:
Pxu: Product, \(n_{dx} \times n_u\)

hessprod_uu

hessprod_uu(x, u, lam)

Get product \(\nabla_{u} \lambda_k^\top \nabla_{u} \boldsymbol{f}_k(\boldsymbol{x}, \boldsymbol{u})\)
Returns:
Puu: Product, \(n_u \times n_u\)

parameter_size

parameter_size()

Size of parameter vector $ heta$ (optional method)

parameters

parameters()

Get parameter vector \(\theta\)

Note: Implementing this method is optional; this method allows for online
adaptation of any model parameters, \(\theta\)

parameter_gradient

parameter_gradient(x, u)

Get dynamics Jacobian with respect to any model parameters, evaluated at
given \((\boldsymbol{x}, \boldsymbol{u})\): \(\nabla_{\theta} \boldsymbol{f}_{\theta, k}(\boldsymbol{x}, \boldsymbol{u})\)
Returns:
gradient with respect to \(\theta\), \(n_{dx} \times n_{\theta}\)

Note: Implementing this method is optional; this method allows for online
adaptation of any model parameters, \(\theta\)

update_parameters

update_parameters(theta)

Update parameter vector \(\theta\)

Note: Implementing this method is optional; this method allows for online
adaptation of any model parameters, \(\theta\)