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
state_diff_size ¶
Size of the difference vector: \(\boldsymbol{x}_1 \ominus \boldsymbol{x}_2\)
Where \(\ominus\): the defined right_minus operator
state_right_plus ¶
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 ¶
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 function \(f(\boldsymbol{x}, \boldsymbol{u})\)
Returns: output vector, \(n \times 1\)
gradient ¶
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 ¶
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 ¶
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 ¶
Get product \(\nabla_{u} \lambda_k^\top \nabla_{u} \boldsymbol{f}_k(\boldsymbol{x}, \boldsymbol{u})\)
Returns:
Puu: Product, \(n_u \times n_u\)
parameters ¶
Get parameter vector \(\theta\)
Note: Implementing this method is optional; this method allows for online
adaptation of any model parameters, \(\theta\)
parameter_gradient ¶
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 parameter vector \(\theta\)
Note: Implementing this method is optional; this method allows for online
adaptation of any model parameters, \(\theta\)