AI Wiki中文/EN

Optimal control: what is the best input, and how would you know?

最优控制

Running and terminal costs, Pontryagin's maximum principle as necessary conditions, the HJB equation as a verification tool, bang-bang minimum-time inputs and why bounds matter, checked on synthetic scalar and double-integrator examples.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Two ways to park a cart

Optimal control finds the input that makes a chosen cost as small as possible while the system obeys its dynamics. It turns “control this well” into a precise question: say what you care about, such as time, effort or error, and compute the best input. For example, a cart with a limited motor that must stop at a mark as fast as possible should push at full strength and then brake at full strength.

Here is that example in more detail. A cart sits at rest one metre from a mark on a frictionless track. Its motor sets the acceleration u, so the dynamics are simply q̈ = u, where q is the position. This model is called a double integrator, because the input is integrated twice to give the position. Consider two requests. The first asks the cart to reach the mark, at rest, as fast as possible. The second asks it to get there while keeping both the distance and the push small along the way. Each request defines a cost, a single number that scores a whole motion. Optimal control finds the input history, or a feedback policy (a rule that picks the input from the current state), that minimises that cost subject to the dynamics.

The two requests give very different answers. If the motor is limited to |u| ≤ 1, the fastest strategy is to push at full strength toward the mark and then brake at full strength. The cart arrives after exactly 2 s, and the input jumps between its limits. If the motor is unlimited, the “fastest” request has no answer at all, because a stronger push always arrives sooner. The second request also puts a cost on the push itself. Its answer is a smooth, linear feedback that approaches the mark exponentially and never quite reaches it in finite time. Tedrake uses this double integrator to illustrate the same contrasts. Two formulations

Two classical methods show where such answers come from and how to check them. Pontryagin’s maximum principle gives conditions that any optimal trajectory must satisfy. Dynamic programming builds the answer backwards from the end of the task and leads to the Hamilton–Jacobi–Bellman (HJB) equation. When that equation has a smooth solution, the solution certifies that a policy is optimal. All numbers below come from a small, original, synthetic simulation; no real vehicle or robot is involved.

Costs, the Hamiltonian and the cost-to-go

This section states the general problem, derives the two classical tools, the maximum principle and the HJB equation, and works small examples by hand.

The problem. Murray states the general problem for a state x ∈ ℝⁿ and an input u restricted to an admissible set Ω ⊂ ℝᵐ. The cost adds an integral (running) cost L along the trajectory to a terminal cost V on the final state: Problem statement

min⁡u(⋅)  J=∫0TL(x(t),u(t)) dt+V(x(T))s.t.x˙=f(x,u),  x(0)=x0,  u(t)∈Ω\min_{u(\cdot)}\; J=\int_0^T L\bigl(x(t),u(t)\bigr)\,dt+V\bigl(x(T)\bigr)\quad\text{s.t.}\quad \dot x=f(x,u),\; x(0)=x_0,\; u(t)\in\Omega

In words: choose the input over the interval so that the running cost L, added up along the way, plus the terminal cost V at the end is as small as possible, while the state follows the dynamics f from x₀ and the input stays in the allowed set Ω. The unknown is a whole function u(·), not a finite vector, which is why the conditions below look like differential equations rather than “set the gradient to zero”. Murray lists the common variants: an infinite horizon with T = ∞ and no terminal cost; the linear-quadratic case with linear dynamics and quadratic cost; terminal constraints ψ(x(T)) = 0 that force the final state onto a set; and time-optimal control, where L = 1, the final time is free and the terminal state is fixed, so J is simply the elapsed time. Variants

Well-posedness. Two remarks in Murray’s chapter prevent a lot of confusion. If an infinite-horizon problem has a finite-cost solution, the running cost must tend to zero as t → ∞; otherwise the integral cannot converge. And a time-optimal problem is usually well posed only if the input is also bounded. Well-posedness remarks Tedrake makes the same point for the double integrator: without input limits both the minimum-time and the quadratic-state-cost formulations would ask for infinite input, and the usual fix, besides limits, is to add an input cost uᵀRu. Input limits or input cost

Hamiltonian and costate. The maximum principle attaches a time-varying vector λ(t), the costate, to the dynamics and forms the Hamiltonian Hamiltonian

H(x,u,λ)=L(x,u)+λTf(x,u)H(x,u,\lambda)=L(x,u)+\lambda^{\mathsf T}f(x,u)

In words, H adds the running cost to the dynamics weighted by the costate. The costate plays the role that a Lagrange multiplier plays in constrained optimisation: it prices the constraint ẋ = f(x,u) at every instant. Murray’s proof sketch, which he says follows Lewis and Syrmos, does exactly this: adjoin the dynamics to the cost with λ(t), take the first variation around the optimum, integrate the λᵀẋ term by parts to remove ẋ, and require the variation to vanish. Proof sketch

The maximum principle. For the case without terminal constraints the resulting conditions are

x˙=∂H∂λT,λ˙=−∂H∂xT,λ(T)=∂V∂xT(x(T)),u∗(t)=arg⁡min⁡u∈ΩH(x∗(t),u,λ∗(t))\dot x=\frac{\partial H}{\partial \lambda}^{\mathsf T},\qquad \dot\lambda=-\frac{\partial H}{\partial x}^{\mathsf T},\qquad \lambda(T)=\frac{\partial V}{\partial x}^{\mathsf T}\bigl(x(T)\bigr),\qquad u^*(t)=\arg\min_{u\in\Omega}H\bigl(x^*(t),u,\lambda^*(t)\bigr)

In words: the state runs forward under the dynamics, the costate runs backward from a final value set by the terminal cost V, and at every instant the input minimises H. Murray’s Theorem 3.1, which he attributes to the 1962 book by Pontryagin and co-authors, states that if (x*, u*) is optimal then a costate λ* (and, with terminal constraints, a multiplier ν* that adds νᵀ∂ψ/∂x to the terminal costate condition) exists so that these hold, with u*(t) minimising H over Ω at every time. Theorem 3.1 Three features matter in practice.

First, the conditions are necessary. Every optimal trajectory satisfies them, but a trajectory that satisfies them is only a candidate: Murray’s sketch is a local first-variation argument, and he remarks in his bang-bang example that the result is a necessary condition. Necessary, not sufficient His chapter also shows a singular extremal, a straight-line minimum-time path for the nonholonomic integrator that satisfies the conditions with one multiplier identically zero. Singular extremals

Second, the conditions form a two-point boundary value problem. The state has n initial conditions; the costate’s conditions sit at the final time. With q terminal constraints there are q of those plus n − q terminal conditions on λ, 2n boundary values in all. Boundary values One cannot simply integrate forward from t = 0, because λ(0) is unknown.

Third, the input set may be constrained. The minimisation is over Ω, so bounded inputs are allowed. If Ω = ℝᵐ and H is differentiable, the condition reduces to ∂H/∂u = 0. The name says “maximum” even when the cost is minimised; Murray calls this an artifact of history. Constrained inputs and naming

A scalar example worked by hand. Take ẋ = ax + bu with J = ½∫₀ᵀ u² dt + ½c x(T)². Then H = ½u² + λ(ax + bu), so ∂H/∂u = 0 gives u* = −bλ, and λ̇ = −aλ with λ(T) = c x(T) gives λ(t) = c x(T)·exp(a(T − t)). Substituting into the state equation and solving for x(T) gives Murray’s closed form (here with t₀ = 0 and t_f = T): Example 3.2

x∗(T)=2a eaTx02a−b2c (1−e2aT),u∗(t)=−b c x∗(T) ea(T−t)x^*(T)=\frac{2a\,e^{aT}x_0}{2a-b^2c\,(1-e^{2aT})},\qquad u^*(t)=-b\,c\,x^*(T)\,e^{a(T-t)}

Here x*(T) is the optimal final state and u*(t) the optimal input at time t. As the terminal weight c grows, x*(T) → 0: a heavy terminal cost behaves like a terminal constraint. The input is largest at the start and decays toward T when a > 0, because early pushes are amplified by the unstable dynamics.

Bang-bang control. For linear dynamics ẋ = Ax + Bu with |u| ≤ 1 and the minimum-time cost L = 1, the Hamiltonian is 1 + λᵀ(Ax + Bu). It is linear in u, so its minimum over the box lies on a corner: Example 3.3

u∗(t)=−sgn⁡(λ(t)TB)u^*(t)=-\operatorname{sgn}\bigl(\lambda(t)^{\mathsf T}B\bigr)

The input always sits on a limit (“bang-bang”), and with a free final time the extra condition H = 0 holds at T. For the double integrator Tedrake derives the policy informally: accelerate at full strength toward the goal, then brake at full strength along the parabola that passes through the origin. He also gives the minimum time-to-go. Writing s = q + ½q̇|q̇| for the side of that parabola (our own shorthand; the source draws the curve rather than naming s), the time-to-go is Minimum-time double integrator

T∗(q,q˙)={q˙+212q˙2+q,s>0 (u=−1)212q˙2−q−q˙,s<0 (u=+1)T^*(q,\dot q)=\begin{cases}\dot q+2\sqrt{\tfrac12\dot q^2+q}, & s>0\ (u=-1)\\[2pt] 2\sqrt{\tfrac12\dot q^2-q}-\dot q, & s<0\ (u=+1)\end{cases}

Here T* is the shortest time to bring the cart to rest at the origin from position q and velocity q̇. Tedrake points out that this function is continuous over the state but not smooth, even though the policy is discontinuous. By our reading of the formula, the kinks lie on the switching curve s = 0, where the policy jumps. A quadratic state cost instead gives an exponential approach to the goal, while minimum time arrives in finite time. Exponential versus finite-time approach

The principle of optimality and the cost-to-go. The second route starts from a simple observation that Murray states as the principle of optimality: the remainder of an optimal trajectory, started from any state along it, is itself optimal. That suggests defining the optimal cost-to-go J*(x, t), the best cost achievable from state x at time t, and computing it backwards from the final time where J*(x, T) = V(x). Principle of optimality Tedrake notes that additive costs, a sum or integral of per-step costs, are what make such recursions possible; even minimum time fits, with a cost of 1 everywhere except 0 at the goal. Additive cost This is the same idea as dynamic programming and the Bellman equations for discrete decisions.

The HJB equation. Over a short interval the cost-to-go must equal the running cost plus the cost-to-go from where the dynamics lead. Letting the interval shrink gives a partial differential equation:

−∂J∗∂t(x,t)=min⁡u∈Ω[L(x,u)+∂J∗∂x(x,t) f(x,u)],J∗(x,T)=V(x),λT=∂J∗∂x-\frac{\partial J^*}{\partial t}(x,t)=\min_{u\in\Omega}\Bigl[L(x,u)+\frac{\partial J^*}{\partial x}(x,t)\,f(x,u)\Bigr],\qquad J^*(x,T)=V(x),\qquad \lambda^{\mathsf T}=\frac{\partial J^*}{\partial x}

In words: the rate at which the optimal cost-to-go J* falls as time advances equals the best achievable running cost plus the change of J* along the motion. The bracket is the Hamiltonian with λᵀ replaced by ∂J*/∂x. This gives the costate a concrete meaning: it is the sensitivity of the optimal cost-to-go to the state. HJB and costate interpretation For an infinite horizon with no explicit time dependence, Tedrake writes

0=min⁡u[ℓ(x,u)+∂J∗∂xf(x,u)]0=\min_{u}\Bigl[\ell(x,u)+\frac{\partial J^*}{\partial x}f(x,u)\Bigr]

with ℓ the running cost. In words, under the best input the running cost is exactly balanced by the fall in cost-to-go. Infinite-horizon HJB

Necessary or sufficient? The two sources frame it differently. Murray introduces HJB from the principle of optimality and states it as a necessary condition: an optimal trajectory must satisfy it. HJB in Murray Tedrake states an informal sufficiency theorem: if a continuously differentiable, positive-definite J satisfies the infinite-horizon HJB at every x, with ℓ strictly positive definite (zero only at one goal state) and some technical existence conditions, then J, minus its value at that goal state, is the optimal cost-to-go and the minimising input is an optimal policy. HJB sufficiency theorem Both framings are true under their assumptions. This article uses HJB in Tedrake’s verification role, because that is what makes it a practical check: verification needs no integration of trajectories, only a derivative test on a candidate J.

Tedrake’s double-integrator example shows the test. With ℓ = q² + q̇² + u² and no input bound, the candidate

J(q,q˙)=3 q2+2qq˙+3 q˙2,π(q,q˙)=−q−3 q˙J(q,\dot q)=\sqrt3\,q^2+2q\dot q+\sqrt3\,\dot q^2,\qquad \pi(q,\dot q)=-q-\sqrt3\,\dot q

satisfies HJB everywhere, so π is optimal. HJB for the double integrator The minimum time-to-go above also satisfies HJB wherever its gradient exists, but it has cusps, so it fails the theorem’s differentiability assumption; Tedrake remarks that such cusps are common in optimal value functions. Cusps

Solving for the minimising input. When the dynamics are control-affine, f = f₁(x) + f₂(x)u, and the running cost is ℓ₁(x) + uᵀRu with R ≻ 0, the bracket in HJB is a convex quadratic in u and its minimiser has a closed form: Minimising control

u∗=−12R−1f2(x)T∂J∗∂xTu^*=-\tfrac12R^{-1}f_2(x)^{\mathsf T}\frac{\partial J^*}{\partial x}^{\mathsf T}

In words: the best input pushes against the slope of the cost-to-go, along the directions f₂ that the input can move, scaled down by the input weight R. With linear input constraints the minimisation becomes a small quadratic program at each state. For the double integrator, f₂ = (0, 1)ᵀ and R = 1, so u* = −½∂J/∂q̇ = −q − √3q̇, matching π.

The linear-quadratic special case. When the dynamics are linear and the cost quadratic, Murray shows that the maximum-principle conditions are solved by a costate that is linear in the state, λ(t) = P(t)x(t). This turns the two-point boundary value problem into a Riccati differential equation solved backwards from the final time, followed by a forward simulation with linear feedback u = −K(t)x. Linear-quadratic case That case, the linear quadratic regulator, has its own article, LQR, which covers the Riccati equations, weight selection and the infinite-horizon gain.

Why numerics. Outside the linear-quadratic case, both routes are hard. The maximum principle leaves a nonlinear boundary value problem; HJB is a partial differential equation in as many dimensions as the state. Murray notes that solving HJB over a continuous state is difficult and that the principle of optimality is most directly usable for discrete decision problems, stepping backwards from the final cost. Difficulty of HJB Tedrake stresses that the optimisation view is general (linear or nonlinear, deterministic or stochastic, continuous or discrete) and lends itself to numerical solution, and he describes reinforcement learning as, in effect, optimal control under its machine-learning name. Generality and numerics

Checking each claim on small problems

This section tests the main claims of the theory numerically on three small problems with known answers. The program below uses only numpy, is deterministic and runs in under a second. It has three parts. Part A compares Murray’s scalar closed form with a direct transcription: the input is held piecewise-constant on N intervals, the dynamics are discretised exactly, and the resulting finite-dimensional problem, which here is exactly a least-squares problem, is solved in closed form. This is a toy used only as an independent check of the maximum-principle answer; it is not how numerical trajectory optimisation works in general. Part B simulates the bang-bang feedback for the double integrator with a semi-implicit Euler step of 10⁻⁴ s. Part C evaluates the HJB residual of Tedrake’s candidate cost-to-go on a grid and simulates three linear policies.

# Synthetic, deterministic optimal-control study (numpy only).
import numpy as np

print("A. Maximum principle vs direct transcription")
print("   xdot = a x + b u, J = 0.5*int u^2 dt + 0.5*c*x(T)^2, a = b = 1, x0 = 1, T = 1")
a, b, x0, T = 1.0, 1.0, 1.0, 1.0


def pmp_solution(c):
    xT = 2 * a * np.exp(a * T) * x0 / (2 * a - b * b * c * (1 - np.exp(2 * a * T)))
    u0 = -b * c * xT * np.exp(a * T)
    J = 0.5 * (b * c * xT) ** 2 * (np.exp(2 * a * T) - 1) / (2 * a) + 0.5 * c * xT ** 2
    return xT, u0, J


def direct_solution(c, N):
    h = T / N
    k = np.arange(N)
    g = np.exp(a * h * (N - 1 - k)) * (np.exp(a * h) - 1) / a * b
    free = np.exp(a * T) * x0
    xT = free / (1 + c * (g @ g) / h)
    u = -(c * xT / h) * g
    J = 0.5 * h * (u @ u) + 0.5 * c * xT ** 2
    return xT, u[0], J


for c in (1.0, 10.0, 100.0, 1e4):
    xT, u0, J = pmp_solution(c)
    xT_d, u0_d, J_d = direct_solution(c, 1000)
    print(f"   c = {c:>7g}: PMP x(T) = {xT:.5f}, u(0) = {u0:.4f}, J = {J:.5f} | "
          f"direct N=1000: x(T) = {xT_d:.5f}, u(0) = {u0_d:.4f}, J = {J_d:.5f}")
c = 10.0
for N in (10, 100, 1000):
    print(f"   c = 10, N = {N:>4}: |J_direct - J_PMP| = {abs(direct_solution(c, N)[2] - pmp_solution(c)[2]):.2e}")

print()
print("B. Minimum-time double integrator, |u| <= 1, start (q, qdot) = (1, 0)")


def time_to_go(q, qd):
    s = q + 0.5 * qd * abs(qd)
    if s > 0:
        return qd + 2 * np.sqrt(0.5 * qd * qd + q)
    if s < 0:
        return 2 * np.sqrt(0.5 * qd * qd - q) - qd
    return abs(qd)


def bang_bang(q, qd):
    s = q + 0.5 * qd * abs(qd)
    if s > 0:
        return -1.0
    if s < 0:
        return 1.0
    return -np.sign(qd)


print(f"   analytic time-to-go from (1, 0): {time_to_go(1.0, 0.0):.4f} s")
q, qd, t, dt = 1.0, 0.0, 0.0, 1e-4
switches, u_prev = 0, None
while q * q + qd * qd > 1e-6 and t < 10:
    u = bang_bang(q, qd)
    if u_prev is not None and u != u_prev:
        switches += 1
    u_prev = u
    qd += dt * u
    q += dt * qd
    t += dt
print(f"   simulated bang-bang feedback (dt = 1e-4): reached |x| < 1e-3 at t = {t:.3f} s, "
      f"input sign changes = {switches}")
for start in ((1.0, 0.0), (0.0, 1.0), (-2.0, 1.0)):
    print(f"   time-to-go from {start}: {time_to_go(*start):.4f} s")
for umax in (0.5, 1.0, 2.0):
    print(f"   input bound |u| <= {umax:g}: minimum time from (1, 0) = {2 * np.sqrt(1 / umax):.4f} s")

print()
print("C. Verifying an HJB solution: l = q^2 + qdot^2 + u^2, no input bound")
s3 = np.sqrt(3.0)


def hjb_residual(scale, q, qd):
    dJq = scale * (2 * s3 * q + 2 * qd)
    dJqd = scale * (2 * q + 2 * s3 * qd)
    u = -0.5 * dJqd
    return q * q + qd * qd + u * u + dJq * qd + dJqd * u


grid = [(q, qd) for q in np.linspace(-2, 2, 9) for qd in np.linspace(-2, 2, 9)]
for scale in (1.0, 1.1):
    r = max(abs(hjb_residual(scale, q, qd)) for q, qd in grid)
    print(f"   J = {scale:g} * (sqrt3 q^2 + 2 q qdot + sqrt3 qdot^2): max |HJB residual| on 9x9 grid = {r:.2e}")
dt = 1e-4
print(f"   J(1, 0) = sqrt3 = {s3:.4f}; simulated costs from (1, 0), Euler dt = 1e-4, 30 s:")
for kq, kd in ((1.0, s3), (2.0, 2.0), (0.5, 1.0)):
    q, qd, cost = 1.0, 0.0, 0.0
    for _ in range(300000):
        u = -kq * q - kd * qd
        cost += (q * q + qd * qd + u * u) * dt
        q, qd = q + dt * qd, qd + dt * u
    print(f"   policy u = -{kq:g} q - {kd:.4g} qdot: cost {cost:.4f}")
Recorded output
A. Maximum principle vs direct transcription
   xdot = a x + b u, J = 0.5*int u^2 dt + 0.5*c*x(T)^2, a = b = 1, x0 = 1, T = 1
   c =       1: PMP x(T) = 0.64805, u(0) = -1.7616, J = 0.88080 | direct N=1000: x(T) = 0.64805, u(0) = -1.7607, J = 0.88080
   c =      10: PMP x(T) = 0.08251, u(0) = -2.2428, J = 1.12141 | direct N=1000: x(T) = 0.08251, u(0) = -2.2417, J = 1.12141
   c =     100: PMP x(T) = 0.00848, u(0) = -2.3058, J = 1.15291 | direct N=1000: x(T) = 0.00848, u(0) = -2.3047, J = 1.15291
   c =   10000: PMP x(T) = 0.00009, u(0) = -2.3130, J = 1.15648 | direct N=1000: x(T) = 0.00009, u(0) = -2.3118, J = 1.15648
   c = 10, N =   10: |J_direct - J_PMP| = 9.06e-04
   c = 10, N =  100: |J_direct - J_PMP| = 9.06e-06
   c = 10, N = 1000: |J_direct - J_PMP| = 9.06e-08

B. Minimum-time double integrator, |u| <= 1, start (q, qdot) = (1, 0)
   analytic time-to-go from (1, 0): 2.0000 s
   simulated bang-bang feedback (dt = 1e-4): reached |x| < 1e-3 at t = 1.999 s, input sign changes = 1
   time-to-go from (1.0, 0.0): 2.0000 s
   time-to-go from (0.0, 1.0): 2.4142 s
   time-to-go from (-2.0, 1.0): 2.1623 s
   input bound |u| <= 0.5: minimum time from (1, 0) = 2.8284 s
   input bound |u| <= 1: minimum time from (1, 0) = 2.0000 s
   input bound |u| <= 2: minimum time from (1, 0) = 1.4142 s

C. Verifying an HJB solution: l = q^2 + qdot^2 + u^2, no input bound
   J = 1 * (sqrt3 q^2 + 2 q qdot + sqrt3 qdot^2): max |HJB residual| on 9x9 grid = 7.11e-15
   J = 1.1 * (sqrt3 q^2 + 2 q qdot + sqrt3 qdot^2): max |HJB residual| on 9x9 grid = 4.08e+00
   J(1, 0) = sqrt3 = 1.7321; simulated costs from (1, 0), Euler dt = 1e-4, 30 s:
   policy u = -1 q - 1.732 qdot: cost 1.7322
   policy u = -2 q - 2 qdot: cost 2.2503
   policy u = -0.5 q - 1 qdot: cost 1.8751

A: the maximum principle against brute force. With a = b = 1, x₀ = 1 and T = 1, the closed form gives x(T) = 0.64805, u(0) = −1.7616 and J = 0.88080 for c = 1. Raising the terminal weight drives the final state toward zero: x(T) = 0.08251 at c = 10, 0.00848 at c = 100 and 0.00009 at c = 10⁴. The cost rises toward 1.15648, close to the limit e²/(e² − 1) ≈ 1.1565, the minimum input energy needed to reach x = 0 exactly. The direct transcription with N = 1000 agrees with x(T) and J to every printed digit. Its first input differs in the third decimal (−1.7607 against −1.7616 for c = 1) because a piecewise-constant input averages the decaying optimal input over the first interval. The cost error for c = 10 is 9.06e-04, 9.06e-06 and 9.06e-08 for N = 10, 100 and 1000: one hundred times smaller for every tenfold refinement, the second-order behaviour one expects from this discretisation.

B: bang-bang with one switch. From (q, q̇) = (1, 0) the analytic time-to-go is 2.0000 s. The simulated feedback reaches |x| below 10⁻³ at t = 1.999 s and changes the sign of its input exactly once. The same formula gives 2.4142 s from (0, 1), where the cart starts moving the wrong way and must first stop, and 2.1623 s from (−2, 1). The bound matters: the minimum time from (1, 0) is 2/√U for |u| ≤ U, which prints as 2.8284 s for U = 0.5, 2.0000 s for U = 1 and 1.4142 s for U = 2. It shrinks without limit as U grows, so with no bound there is no minimiser.

C: verification is a derivative test. For the true candidate the largest HJB residual on a 9 × 9 grid over [−2, 2]² is 7.11e-15, rounding error. Multiplying the same function by 1.1 raises it to 4.08, so the scaled candidate fails. J(1, 0) = √3 = 1.7321, and simulating the policy u = −q − 1.732q̇ from (1, 0) for 30 s costs 1.7322; the extra 10⁻⁴ is Euler error, not a better policy. Two other linear policies cost more, 2.2503 for u = −2q − 2q̇ and 1.8751 for u = −0.5q − q̇, as optimality requires. The check needed one formula per grid point; the simulations are there only to show that the certified number is the achieved cost.

What these checks do not establish

This section lists what the checks above do not prove and where the examples are idealised. Satisfying the maximum principle does not prove a trajectory optimal. Part A is convincing only because the problem is convex and a second method agrees; for a nonlinear problem the conditions can admit several extremals, including singular or abnormal ones, and choosing among them needs extra arguments.

HJB verification needs a candidate. Here Tedrake’s closed form was available. In general, finding a smooth J that satisfies HJB in many dimensions is as hard as solving the problem, and the true cost-to-go may not be smooth at all: the minimum-time example has a kink, so the stated sufficiency theorem cannot certify it, even though the formula is correct.

The examples are low-dimensional and idealised. The double integrator has no friction, delay or sensor noise, and the bang-bang policy, which switches on a curve, would chatter around that curve on real hardware with measurement noise; practical designs smooth or bound the switching. The grid test in Part C checks 81 points, not every state; for this quadratic J the residual is a quadratic form, so the grid result does reflect an identity, but that argument does not carry over to arbitrary candidates.

The switching function s and the “at most one switch” argument in the exercises are derivations written for this article, not statements quoted from the sources. The history mentioned below is reported second-hand from the books named; the original papers and monographs were not read.

Exercises

The five exercises test understanding, a hand calculation, a boundary case, a short proof and a method choice; each answer explains its reasoning.

  1. Why is the maximum principle called a necessary condition, and what does the HJB equation add?

    Answer: Every optimal pair (x*, u*) must admit a costate satisfying the conditions, but a trajectory that satisfies them may be a local extremum or a singular extremal, as in Murray’s nonholonomic example. HJB, when a smooth solution exists, works globally in the other direction: a continuously differentiable, positive-definite J that satisfies it at every state certifies the minimising policy as optimal (Tedrake’s informal theorem). In the program the true J has residual 7.11e-15 and the 1.1-scaled candidate 4.08.

  2. For ẋ = x + u, J = ½∫₀¹u² dt + ½c x(1)², x(0) = 1, compute x*(1) for c = 10 and the limiting cost as c → ∞.

    Answer: With a = b = 1 and T = 1, x*(1) = 2e/(2 − 10(1 − e²)) = 5.43656/(2 + 63.8906) = 5.43656/65.8906 = 0.08251, as printed. As c → ∞, c·x(1) → 2e/(e² − 1), the terminal term vanishes, and the input energy ½(c·x(1))²(e² − 1)/2 tends to e²/(e² − 1) = 7.38906/6.38906 ≈ 1.1565. The program gives 1.15648 at c = 10⁴.

  3. “Minimum-time control of q̈ = u always has a solution.” Is this true?

    Answer: Only if the input is bounded. With |u| ≤ U the time from (1, 0) is 2/√U, printed as 2.8284, 2.0000 and 1.4142 s for U = 0.5, 1 and 2. As U → ∞ it tends to 0 but no admissible input attains 0, so no minimiser exists. Even with a bound, the time-to-go has a kink on the switching curve; it is not continuously differentiable, so the HJB sufficiency theorem as stated cannot be used to certify it.

  4. Show that for the minimum-time double integrator the optimal input switches at most once. (This derivation is ours, applying Murray’s general bang-bang condition to this system.)

    Answer: Here A has a single 1 in the upper-right corner and B = (0, 1)ᵀ. The costate equation λ̇ = −Aᵀλ gives λ̇₁ = 0 and λ̇₂ = −λ₁, so λ₁ is constant and λ₂(t) = λ₂(0) − λ₁t is affine in time. The bang-bang law is u = −sgn(λᵀB) = −sgn(λ₂), and an affine function changes sign at most once. The simulation from (1, 0) indeed shows one sign change.

  5. A drone must fly to a waypoint with thrust limits and a no-fly zone; another task only asks it to hover near an equilibrium. Which tools fit each task?

    Answer: Hovering near an equilibrium with a good linear model and no active constraints is the linear-quadratic case: linearise and use LQR (LQR), which gives closed-form linear feedback from a Riccati equation. The waypoint task has nonlinear dynamics and constraints. The maximum principle then yields a hard boundary value problem, and HJB is a partial differential equation in many dimensions, so in practice one solves the problem numerically, for example by direct trajectory optimisation (trajectory optimization), and obtains feedback by re-solving online (model predictive control). Grid-based dynamic programming such as value iteration only scales to low-dimensional states.

History and further reading

This section gives the history as the cited books report it and points to further reading. Murray names the 1962 book by Pontryagin and co-authors as one of the first and best treatments of optimal control, and points to the texts by Athans and Falb and by Bryson and Ho as standard textbooks of the 1960s and 1970s, and to Liberzon’s open notes for more depth. Further reading Åström and Murray report that Kalman’s 1960 paper “Contributions to the theory of optimal control” obtained the state feedback gain by minimising a quadratic loss. Kalman’s paper as reported None of these original works was read for this article; the attributions are as the cited books give them.

Murray’s chapter 3 is the main reference here for the problem statement, the maximum principle, its examples and the dynamic-programming view. Optimization-Based Control, chapter 3 Tedrake’s dynamic-programming chapter provides the double-integrator formulations, the HJB sufficiency theorem and the control-affine minimiser, and continues to numerical dynamic programming and value-function approximation. Underactuated Robotics, chapter 7 For the mathematical background see differential equations and Lagrange multipliers; for the discrete and stochastic counterparts see Markov decision processes, value iteration and policy iteration. For model-free feedback and the robot models these methods are applied to, see PID control and robot dynamics. The estimation side, Kalman filter and state estimation, is dual to the linear-quadratic problem.

Make a prediction, then check

A candidate cost-to-go J(x) is continuously differentiable, positive definite and satisfies the infinite-horizon HJB equation at every state; a different trajectory satisfies all conditions of Pontryagin's maximum principle. Which statement is correct?

Choose one answer

Learning objectives

  • State an optimal control problem with running cost, terminal cost and input constraints, write Pontryagin's maximum principle with the Hamiltonian and costate, and solve the two-point boundary value problem for a scalar linear example.
  • Distinguish the maximum principle (necessary conditions) from the HJB equation (verification/sufficiency), and explain why bounded-input minimum-time problems give bang-bang control and why input bounds matter for well-posedness.

Prerequisites & connections

Explore related knowledge →

References

  1. Optimization-Based Control, Chapter 3: Optimal Control (v2.3d, 14 Jan 2023) — scoped
    Richard M. Murray · 2023
  2. Underactuated Robotics, Ch. 7: Dynamic Programming (2024 working notes, Wayback snapshot 2026-08-14) — scoped
    Russ Tedrake · 2024
  3. Feedback Systems: An Introduction for Scientists and Engineers, 2nd ed. (electronic v3.1.5) — scoped
    Karl Johan Åström; Richard M. Murray · 2020

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Claude · 2026-12-03 · Independent AI check (Claude subagent, not the author; not a human or expert review). Before this check the main session applied style-only edits suggested by the Gemini app to the opening section, logged in gemini-edits-016a.json; research was done by a separate research subagent (facts.md) and the prose by a writer subagent. All four en and three zh Gemini edits for this topic were compared with their old text: none changed a fact, hedge or attribution, but the zh '对比了两种做法' had narrowed the en 'the same contrasts' and was realigned. I then made readability (D012) edits to the intuition section and section openings in both languages and did the factual check on the edited text. I ran example.py with the pinned numpy 1.26.4 interpreter and diffed it with example.stdout.txt (identical), confirmed the python and output blocks in both languages are byte-identical to the files and that the ten display equations match across languages, and matched every quoted number. I re-derived Murray's Example 3.2 closed form and the c → ∞ limit e²/(e² − 1) ≈ 1.1565, the minimum-time time-to-go values 2.0000/2.4142/2.1623 s and 2/√U, the non-differentiability of T* on the switching curve, the one-switch argument (λ₂ affine in t), and the HJB identity for Tedrake's J = √3q² + 2qq̇ + √3q̇². I downloaded the sources myself and read them as extracted text: Murray's Optimization-Based Control ch. 3 v2.3d (14 Jan 2023), all 27 pages including §3.2 Theorem 3.1 and the proof sketch, Examples 3.2–3.4, §3.5, §3.7 dynamic programming/HJB and singular extremals (Example 3.6), and §3.8; Tedrake's Underactuated Robotics ch. 7 from the 2026-08-14 Wayback snapshot (formulation, double-integrator formulations, minimum-time problem, additive cost, HJB, sufficiency theorem, HJB for the double integrator, minimising control); Feedback Systems 2e v3.1.5 §7.5 and §7.6 p. 7-33 with the [Kal60] bibliography entry. Kalman 1960, Pontryagin et al. 1962 and the other books are reported second-hand only. I did not read Tedrake's numerical DP sections, Murray's exercises in detail, or any original paper. Catalogue IDs, h2 anchors, source IDs and the quiz answer were checked, and both files compile as MDX.

  • Example re-run with the pinned interpreter matches; every quoted number (0.64805, 9.06e-04/06/08, 2.0000 s, 1.999 s, 7.11e-15, 4.08, 1.7322, etc.) agrees with the output.
  • Maximum principle (Theorem 3.1, attributed to Pontryagin et al. 1962), 2n boundary values, the 'maximum' naming, the Example 3.2 closed form, Example 3.3 bang-bang with H(T) = 0 and the singular extremal (Example 3.6) match Murray ch. 3.
  • HJB is framed in Tedrake's verification (sufficiency) role, with Murray's necessary-condition framing stated separately; Tedrake's theorem concludes that J minus its value at the goal state is the optimal cost-to-go, which the text now says.
  • The switching function s, the at-most-one-switch proof and the 81-point grid argument are labelled as the article's own; Kalman 1960 is reported only via Feedback Systems.
  • zh and en compared section by section: same claims, numbers, exercises and answers.

Source locations checked:

  • Optimization-Based Control, Chapter 3: Optimal Control (v2.3d, 14 Jan 2023) — scoped · pdftotext of obc-optimal_14Jan2023.pdf (v2.3d, 27 pp.). Checked: §3.2 pp. 3-4–3-6 problem J = ∫L + V, Ω ⊂ R^m, L2 formulation, variants (infinite horizon and L → 0, LQ, terminal constraints, time optimal needs bounded inputs); Hamiltonian H = L + λᵀf, costate; Theorem 3.1 (attributed to [PBGM62]) incl. terminal costate condition, min over Ω, 2n boundary values, ∂H/∂u = 0 if unconstrained, 'maximum' naming an artifact of history; proof sketch pp. 3-7–3-8 (Lewis–Syrmos, adjoin, integrate by parts). Example 3.2 pp. 3-8–3-9 (λ(t), u*, x*(tf) formula, c → ∞ limit — formula re-derived and reproduced numerically). Example 3.3 pp. 3-9–3-10 (u = −sgn(λᵀB), H(T) = 0 for free T, necessary-condition remark). §3.5 pp. 3-11–3-13 (λ = P x, Riccati ODE (3.7), separation of the TPBVP). §3.7 pp. 3-16–3-18 (principle of optimality, cost to go (3.10), HJB (3.11) stated as necessary, λᵀ = ∂J*/∂x, DP for discrete decisions, Liberzon pointer); singular extremals pp. 3-19–3-20; §3.8 p. 3-20. Symbol glyphs garbled in extraction (λ, ψ, ≤ missing) and reconstructed from context. NOT read: §3.1 beyond skim, §3.4 python-control API detail, Figures, exercises 3.1–3.12, any cited book.
  • Underactuated Robotics, Ch. 7: Dynamic Programming (2024 working notes, Wayback snapshot 2026-08-14) — scoped · HTML of https://underactuated.mit.edu/dp.html via Wayback snapshot 20260814054330 (before the 2026-09-04 cutoff), page header '© Russ Tedrake, 2024', Spring 2024 working notes. Checked sections: 'Formulating control design as an optimization' (generality, scalar objective, numerics, RL = ML name for optimal control); 'Optimal Control Formulations for the Double Integrator' (min-time vs quadratic, exponential vs finite-time approach, input limits or input cost needed); 'The minimum time problem…' (bang-bang, parabolic arcs, time-to-go formula, continuous but non-smooth; the policy's case formula was truncated in text extraction, so the switching function used in the sheet is the research agent's own); 'Additive cost'; 'The Hamilton-Jacobi-Bellman Equation'; 'HJB Sufficiency Theorem (stated informally)' (formal Megretski version skimmed); 'HJB for the Double Integrator' (J and π verified numerically); 'Solving for the minimizing control' (control-affine closed form, QP with constraints). NOT read: graph search / grid world / DP numerics / fitted VI / continuous-time PI / stochastic / LP / SOS sections, exercises, figures and notebooks.
  • Feedback Systems: An Introduction for Scientists and Engineers, 2nd ed. (electronic v3.1.5) — scoped · Used only for: §7.6 Further Reading p. 7-33 (Kalman [Kal60] obtained state feedback by minimising a quadratic loss) and bibliography entry [Kal60] (Bol. Soc. Mat. Mexicana 5:102–119, 1960); §7.5 pp. 7-28–7-29 for the LQR summary. Kalman's paper itself NOT read (no readable copy found).

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.