Algorithm Search⌘K

Definitioncore

Costate

Also called adjoint state, costate variables.

The multiplier of the dynamics in an optimal control problem, which runs backward in time and gives the sensitivity of the optimal cost to the state.

The costate λ(t)∈Rn\lambda(t) \in \mathbb{R}^n is the time-varying multiplier that an optimal control problem attaches to its dynamics x˙=f(x,u)\dot x = f(x, u). It solves a linear differential equation that runs backward from a condition at the final time, and it enters the Hamiltonian whose minimum gives the optimal input. Where the optimal cost V(t,x)V(t, x) is smooth, the costate is its gradient along the optimal trajectory, so λi(t)\lambda_i(t) is the marginal cost of one more unit of xix_i at time tt.

Definition

Take the optimal control problem with dynamics x˙=f(x,u)\dot x = f(x, u), running cost LL, terminal cost KK, and the Hamiltonian H(x,u,λ,λ0)=λ0L(x,u)+λTf(x,u)H(x, u, \lambda, \lambda_0) = \lambda_0 L(x, u) + \lambda^T f(x, u), where ff, LL and KK are C1C^1 in xx. Let u∗u^* be an admissible input on [t0,tf][t_0, t_f] and x∗x^* its trajectory.

A costate for (x∗,u∗)(x^*, u^*) with cost multiplier λ0∈{0,1}\lambda_0 \in \{0, 1\} is an absolutely continuous function λ:[t0,tf]→Rn\lambda : [t_0, t_f] \to \mathbb{R}^n that solves the adjoint equation

λ˙(t)=−Hx(x∗(t),u∗(t),λ(t),λ0)T=−fx(x∗(t),u∗(t))Tλ(t)−λ0Lx(x∗(t),u∗(t))T\dot \lambda(t) = -H_x(x^*(t), u^*(t), \lambda(t), \lambda_0)^T = -f_x(x^*(t), u^*(t))^T \lambda(t) - \lambda_0 L_x(x^*(t), u^*(t))^T

for almost every tt, together with the end conditions of the problem (the transversality conditions), and with (λ0,λ(t))≠(0,0)(\lambda_0, \lambda(t)) \ne (0, 0). For a free final state the end condition is λ(tf)=λ0∇K(x∗(tf))\lambda(t_f) = \lambda_0 \nabla K(x^*(t_f)). For a fixed final state there is no condition on λ(tf)\lambda(t_f).

The adjoint equation is linear in λ\lambda, so λ(t)\lambda(t) is determined by its final value, and it is integrated from tft_f back to t0t_0. Its homogeneous part λ˙=−fxTλ\dot\lambda = -f_x^T \lambda is the adjoint of the linearized dynamics δ˙=fxδ\dot\delta = f_x \delta: for every solution δ\delta of the linearization,

ddt(λTδ)=−λ0Lxδ.\frac{d}{dt}\left( \lambda^T \delta \right) = -\lambda_0 L_x \delta.

The costate as a gradient. Suppose the value function V(t,x)V(t, x), the optimal cost from state xx at time tt, is C2C^2 near the optimal trajectory and solves the HJB equation −Vt=min⁡u∈U(L+Vxf)-V_t = \min_{u \in U} (L + V_x f). Then λ(t)=Vx(t,x∗(t))T\lambda(t) = V_x(t, x^*(t))^T is a costate with λ0=1\lambda_0 = 1. Proof: let φ(t,x)=L(x,u∗(t))+Vt(t,x)+Vx(t,x)f(x,u∗(t))\varphi(t, x) = L(x, u^*(t)) + V_t(t, x) + V_x(t, x) f(x, u^*(t)). The HJB equation gives φ≥0\varphi \ge 0 everywhere, and φ(t,x∗(t))=0\varphi(t, x^*(t)) = 0 because u∗u^* attains the minimum along the optimal trajectory. So x∗(t)x^*(t) minimizes φ(t,⋅)\varphi(t, \cdot), and φx(t,x∗(t))=0\varphi_x(t, x^*(t)) = 0:

Lx+Vtx+fTVxx+Vxfx=0at (t,x∗(t),u∗(t)).L_x + V_{tx} + f^T V_{xx} + V_x f_x = 0 \quad \text{at } (t, x^*(t), u^*(t)).

Then ddtVx(t,x∗(t))T=VxtT+Vxxf=−LxT−fxTVxT\frac{d}{dt} V_x(t, x^*(t))^T = V_{xt}^T + V_{xx} f = -L_x^T - f_x^T V_x^T, which is the adjoint equation, and Vx(tf,x)T=∇K(x)V_x(t_f, x)^T = \nabla K(x) is the end condition.

Examples and non-examples

A scalar problem. For x˙=u\dot x = u, J=∫0Tu2 dt+x(T)2J = \int_0^T u^2\, dt + x(T)^2, U=RU = \mathbb{R}, the Hamiltonian is H=u2+λuH = u^2 + \lambda u, so u=−λ/2u = -\lambda/2. The adjoint equation is λ˙=−Hx=0\dot\lambda = -H_x = 0, so λ\lambda is a constant, and the end condition gives λ=2x(T)\lambda = 2 x(T). Then x(T)=x0−λT/2=x0−x(T)Tx(T) = x_0 - \lambda T / 2 = x_0 - x(T) T, so x(T)=x0/(1+T)x(T) = x_0/(1 + T), λ=2x0/(1+T)\lambda = 2 x_0/(1 + T) and u∗=−x0/(1+T)u^* = -x_0/(1 + T). The optimal cost is V(0,x0)=x02/(1+T)V(0, x_0) = x_0^2/(1 + T), and indeed ∂V/∂x0=2x0/(1+T)=λ(0)\partial V / \partial x_0 = 2 x_0/(1 + T) = \lambda(0). With x0=1x_0 = 1 and T=1T = 1: λ=1\lambda = 1, u∗=−1/2u^* = -1/2 and the cost is 1/21/2.

The costate gives the gradient of the cost. For an input uu that is not optimal, solve the adjoint equation with λ0=1\lambda_0 = 1 along its own trajectory. Then the derivative of JJ in the direction of a change δu\delta u of the input is ∫t0tfHu(x,u,λ) δu dt\int_{t_0}^{t_f} H_u(x, u, \lambda)\, \delta u\, dt. In the scalar example with T=1T = 1, x0=1x_0 = 1 and constant inputs u=cu = c, λ=2(1+c)\lambda = 2(1 + c), and ∫01Hu dt=2c+2(1+c)\int_0^1 H_u\, dt = 2c + 2(1 + c), which is the derivative of J=c2+(1+c)2J = c^2 + (1 + c)^2. This is the adjoint method for gradients. Its discrete form, λk=LxT+FxTλk+1\lambda_k = L_x^T + F_x^T \lambda_{k+1} for xk+1=F(xk,uk)x_{k+1} = F(x_k, u_k), is reverse-mode differentiation, and it gives the gradient used by gradient descent on the inputs.

The linear quadratic regulator. For the LQR problem with the cost ∫(xTQx+uTRu) dt+x(T)TQfx(T)\int (x^T Q x + u^T R u)\, dt + x(T)^T Q_f x(T), the value function is V=xTP(t)xV = x^T P(t) x and the costate is λ(t)=2P(t)x∗(t)\lambda(t) = 2 P(t) x^*(t), where PP solves the Riccati differential equation with P(T)=QfP(T) = Q_f.

Non-example: a costate that is not a gradient. Take x˙=u\dot x = u, U=[−1,1]U = [-1, 1], x(0)=0x(0) = 0, the horizon 1 and the cost K(x(1))=−x(1)2K(x(1)) = -x(1)^2. The inputs u=1u = 1 and u=−1u = -1 are both optimal, with cost −1-1. The value function is V(t,x)=−(∣x∣+1−t)2V(t, x) = -(|x| + 1 - t)^2, which is not differentiable at x=0x = 0. The costate is constant with λ=−2x(1)\lambda = -2 x(1), so it is −2-2 along u=1u = 1 and +2+2 along u=−1u = -1. At (0,0)(0, 0) there are two costates and no gradient. For t>0t > 0 each costate equals VxV_x along its own trajectory.

Non-example: an abnormal multiplier. Minimize ∫01u dt\int_0^1 u\, dt with x˙=u2\dot x = u^2, x(0)=x(1)=0x(0) = x(1) = 0, U=RU = \mathbb{R}. Only u=0u = 0 is admissible. A costate exists only with λ0=0\lambda_0 = 0 (see the maximum principle), and any constant λ>0\lambda > 0 works. Here λ\lambda does not measure a change of the cost, because the constraint alone fixes the input.

  • Lagrange multiplier. The costate is the multiplier of the equality constraint x˙−f(x,u)=0\dot x - f(x, u) = 0 at each time. In discrete time, λk+1\lambda_{k+1} is the multiplier of xk+1=F(xk,uk)x_{k+1} = F(x_k, u_k) in the KKT conditions of the finite program.
  • Momentum. In the calculus of variations, λ=−Lx˙\lambda = -L_{\dot x}, the negative of the momentum of mechanics (Euler-Lagrange equation).
  • Transversality conditions. The end conditions on λ\lambda for free, fixed and constrained end points and a free final time (transversality conditions).
  • Shooting. In an indirect method, the unknown initial costate λ(t0)\lambda(t_0) is found by Newton's method so that the end condition holds.

References

  1. Daniel Liberzon, Calculus of Variations and Optimal Control Theory, A Concise Introduction, Princeton University Press, 2012, Section 4.2.8 (the adjoint equation in the proof of the maximum principle) and Section 5.2 (the relation between the HJB equation and the maximum principle)
  2. Arthur E. Bryson and Yu-Chi Ho, Applied Optimal Control, Optimization, Estimation, and Control, Hemisphere, 1975 (revised printing of the 1969 edition)
  3. Donald E. Kirk, Optimal Control Theory, An Introduction, Prentice-Hall, 1970 (Dover reprint, 2004), Section 5.1 (the costate equations among the necessary conditions)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/FAF6PP/text.yaml