LQR (sequential)#
Solve LQR problem via dynamic programming
- diffilqrax.lqr.simulate_trajectory(dynamics, Us, params, dims)[source]#
Simulate forward pass with LQR params.
- Parameters:
dynamics (
Callable[[Array,Array,Array,Any],Array]) – Function of dynamics with args t, x, u, params.Us (
Array|ndarray|bool|number|bool|int|float|complex) – Input timeseries shape [Txm].params (
LQRParams) – Parameters containing x_init, horizon and theta.dims (
ModelDims) – Parameters containing shape of system n, m, horizon and dt.
- Returns:
State trajectory [(T+1)xn].
- Return type:
- diffilqrax.lqr.lqr_adjoint_pass(Xs, Us, params)[source]#
Adjoint backward pass with LQR params.
- Parameters:
- Returns:
Adjoint λs [(T+1)xn].
- Return type:
- diffilqrax.lqr.regularised_backward_pass(lqr, mu=0.0, pd_thresh=1e-08, return_grad=False)[source]#
LQR backward pass with Levenberg-Marquardt regularisation of the input Hessian.
Only
Huuis regularised,Huu_reg = Huu + mu B^T B. The value function update uses the full form so it stays consistent with the regularised gains, and the expected change in cost uses the unregularisedHuu(Tassa et al., 2012). Withmu=0this is the exact LQR solution.- Parameters:
lqr (
LQR) – LQR parameters.mu (
float) – Regularisation strength, by default 0.0.pd_thresh (
float) – Minimum eigenvalue ofHuu_regfor it to count as positive definite, by default 1e-8.return_grad (
bool) – Also return max_t |hu_t|, by default False. hu_t = r_t + B_t^T (v_{t+1} + V_{t+1} a_t) is the gradient of the cost-to-go wrt u_t; it vanishes at every t if and only if dL/dU does, but v is propagated through the closed loop A + BK, so it stays bounded for unstable open-loop dynamics.
- Returns:
Expected change in cost terms (V: 0.5 k^T Huu k, v: k^T hu summed over time), the optimal feedback gains, and a boolean flag that is True if
Huu_regis positive definite at every time step. Withreturn_grad, also max_t |hu_t|.- Return type:
- diffilqrax.lqr.lqr_backward_pass(lqr)[source]#
LQR backward pass learn optimal Gains given LQR cost constraints and dynamics.