Hyoungseo Son
Optimal Control
Contents · Optimal Control

Part 0 · LQR

Part 2 · Trajectory Optimization

Part 4 · Continuous Optimal Control

  • Pontryagin and Hamilton-Jacobi-Bellman

Part 4 · Continuous Optimal Control

Pontryagin and Hamilton-Jacobi-Bellman

Dynamic programming in discrete time gives the Bellman equation. Push the time step to zero and the same optimality splits into two continuous-time views: a pointwise condition on the control (Pontryagin), and a partial differential equation for the value function (Hamilton-Jacobi-Bellman). Both start from one object, the Hamiltonian, and both feed the sampled, model-free machinery of reinforcement learning.

The Hamiltonian and Pontryagin's principle

Take a system x˙=f(x,u)\dot{x} = f(x, u) with running cost c(x,u)c(x, u), and minimize J=0Tc(x,u)dtJ = \int_0^T c(x, u)\, dt over controls u(t)Uu(t) \in U. Introduce a costate (or adjoint) p(t)Rnp(t) \in \mathbb{R}^n, the continuous analogue of a Lagrange multiplier on the dynamics, and form the Hamiltonian

H(x,u,p)=c(x,u)+pf(x,u).H(x, u, p) = c(x, u) + p^{\top} f(x, u) .

Pontryagin's Maximum Principle (here a minimum principle, since we minimize cost) states that along an optimal trajectory the control minimizes HH pointwise, and the costate runs backward under Hamilton's equations:1

u(t)=arg minuUH(x,u,p),x˙=Hp=f,p˙=Hx.u^{\star}(t) = \operatorname*{arg\,min}_{u \in U} H(x, u, p), \qquad \dot{x} = \frac{\partial H}{\partial p} = f, \qquad \dot{p} = -\frac{\partial H}{\partial x} .

When the dynamics are control-affine, f(x,u)=a(x)+B(x)uf(x, u) = a(x) + B(x)\, u, and cc does not depend on uu, the Hamiltonian is linear in uu:

H=c(x)+pa(x)+(B(x)p)u.H = c(x) + p^{\top} a(x) + \bigl(B(x)^{\top} p\bigr)^{\top} u .

Minimizing a linear function over a box ui1|u_i| \le 1 pins each control to a vertex, ui=sign ⁣((Bp)i)u_i^{\star} = -\operatorname{sign}\!\big((B^{\top} p)_i\big). The control is bang-bang: it sits at its bounds and jumps when the switching function BpB^{\top} p changes sign.

The Hamilton-Jacobi-Bellman equation

The value function V(x)V(x) is the optimal cost-to-go from xx. The discrete Bellman recursion over a step Δt\Delta t reads

V(x)=minu[c(x,u)Δt+V ⁣(x+f(x,u)Δt)].V(x) = \min_{u}\, \big[\, c(x, u)\,\Delta t + V\!\big(x + f(x,u)\,\Delta t\big) \,\big] .

Expand V(x+fΔt)V(x)+V(x)fΔtV(x + f\,\Delta t) \approx V(x) + \nabla V(x)^{\top} f\, \Delta t, cancel V(x)V(x), and let Δt0\Delta t \to 0:

minu[c(x,u)+V(x)f(x,u)]=0.\min_{u}\, \Big[\, c(x, u) + \nabla V(x)^{\top} f(x, u) \,\Big] = 0 .

That is the (stationary) HJB equation, the continuous limit of the Bellman equation.2 The bracket is exactly the Hamiltonian with p=Vp = \nabla V: the Pontryagin costate is the gradient of the value function along the optimal path, p(t)=V ⁣(x(t))p(t) = \nabla V\!\big(x^{\star}(t)\big). HJB is the field (every state), PMP is one characteristic curve through it.

Worked example: the minimum-time double integrator

Drive x˙=v, v˙=u\dot{x} = v,\ \dot{v} = u with u1|u| \le 1 to rest at the origin in minimum time. Here c1c \equiv 1 (each second costs one), so

H=1+pxv+pvu.H = 1 + p_x v + p_v u .

The costate equations are p˙x=H/x=0\dot{p}_x = -\partial H/\partial x = 0 and p˙v=H/v=px\dot{p}_v = -\partial H/\partial v = -p_x, so pxp_x is constant and pv(t)=pv(0)pxtp_v(t) = p_v(0) - p_x t is affine in time. Minimizing HH over uu gives u=sign(pv)u^{\star} = -\operatorname{sign}(p_v), and an affine pvp_v changes sign at most once: bang-bang with a single switch.

Under constant u=±1u = \pm 1, eliminating tt from x˙=v, v˙=u\dot{x}=v,\ \dot{v}=u gives parabolas x=12uv2+constx = \tfrac{1}{2u} v^2 + \text{const}. The two arcs that actually reach the origin form the switching curve

x=12vv{x=12v2,v>0  (terminal u=1),x=+12v2,v<0  (terminal u=+1).x = -\tfrac{1}{2}\, v\, |v| \quad\Longleftrightarrow\quad \begin{cases} x = -\tfrac{1}{2} v^2, & v > 0 \ \ (\text{terminal } u = -1), \\[2pt] x = +\tfrac{1}{2} v^2, & v < 0 \ \ (\text{terminal } u = +1). \end{cases}

With the switching function σ(x,v)=x+12vv\sigma(x, v) = x + \tfrac{1}{2} v |v|, the optimal feedback law is u=sign(σ)u^{\star} = -\operatorname{sign}(\sigma): above the curve (σ>0\sigma > 0) use u=1u = -1, below it (σ<0\sigma < 0) use u=+1u = +1, and ride the curve into the origin.

Take the start (x0,v0)=(1,0)(x_0, v_0) = (1, 0). Then σ=1>0\sigma = 1 > 0, so u=1u = -1 and the state follows x=112v2x = 1 - \tfrac{1}{2} v^2. It meets the lower terminal arc x=12v2x = \tfrac{1}{2} v^2 where

112v2=12v2    v2=1    (xsw,vsw)=(0.5,1).1 - \tfrac{1}{2} v^2 = \tfrac{1}{2} v^2 \;\Rightarrow\; v^2 = 1 \;\Rightarrow\; (x_{\text{sw}}, v_{\text{sw}}) = (0.5,\, -1) .

Switch to u=+1u = +1 and coast up the curve x=12v2x = \tfrac{1}{2}v^2 to (0,0)(0,0). Each phase changes vv by one unit at rate u=1|u| = 1, so

t1=0(1)=1,t2=10=1,T=2.t_1 = |0 - (-1)| = 1, \qquad t_2 = |-1 - 0| = 1, \qquad T^{\star} = 2 .
Minimum-time bang-bang on the switching curveinteractive

phase plane (drag the start state)

xv
start (x, v)
(1.00, 0.00)
region
above the curve, u = -1
control
u = -1, then u = +1
switch at
(0.50, -1.00)
phase 1 time
1.00
phase 2 time
1.00
total time T*
2.00
u = -1 region (above)
u = +1 region (below)
switching curve x = -½ v|v|

Push at full authority against the curve, ride it in: one switch, minimum time. This is the Pontryagin bang-bang solution.

Phase plane (x horizontal, v vertical). The amber curve x = -1/2 v|v| splits the plane into u = -1 (red, above) and u = +1 (blue, below). Drag the start: the blue trajectory pushes at full authority until it meets the curve, switches once, and rides it into the origin. The readout shows the control sequence and the minimum time. Default start (1, 0) switches at (0.5, -1) with T* = 2.

From optimal control to reinforcement learning

HJB is model-based dynamic programming in continuous time: it needs ff and cc and returns the value field VV. Reinforcement learning is what remains when the model is unknown. Sampling transitions in place of the expansion above turns HJB into a temporal-difference update, and the learned V\nabla V (or QQ) is the critic that a policy improves against.2 The Pontryagin side survives too: the costate p=Vp = \nabla V is the pathwise gradient that adjoint methods and differentiable controllers backpropagate, and the bang-bang structure warns that optimal continuous-control policies can be genuinely discontinuous, not the smooth outputs a naive function approximator prefers.

Footnotes

  1. Liberzon, Calculus of Variations and Optimal Control Theory (2012).

  2. Bertsekas, Dynamic Programming and Optimal Control. 2