Stanford AA203 Optimal and Learning-Based Control | Spring 2026 | Lecture 7: Dynamic Programming
Overview
Prof. Marco Pavone shifts AA203 from open-loop control sequences to closed-loop policies, deriving dynamic programming from the principle of optimality and showing how backward recursion reuses optimal solutions to tail problems. He applies the method to a shortest-path example and finite-horizon discrete-time LQR, where linear dynamics and quadratic costs yield linear state-feedback gains and Riccati matrix recursions, while highlighting the curse of dimensionality.
Key takeaways
- An additive objective makes the tail of an optimal control sequence optimal for its truncated problem, allowing dynamic programming to reuse solved future costs instead of searching every complete sequence.
- Dynamic programming computes a closed-loop policy by solving cost-to-go problems backward for possible states, then recording the minimizing action at each state.
- A state grid with 10 values per dimension grows from 10 states in one dimension to 1,000 in three dimensions, illustrating why dynamic programming becomes expensive as state dimension rises.
- For finite-horizon discrete-time LQR, linear dynamics and quadratic costs preserve a quadratic cost-to-go and yield linear state feedback at every stage.
- The LQR backward recursion starts from P_N=H and updates gain and cost matrices through Riccati equations, turning repeated control optimizations into matrix calculations.
Chapters
- Marco Pavone recaps indirect methods, which derive optimality conditions and solve a two-point boundary-value problem, and direct methods, which discretize the problem for nonlinear optimization.
- Direct methods are increasingly practical in robotics because of advances in optimization algorithms and hardware; indirect methods remain valuable when they yield explicit solutions or complement direct methods.
- A closed-loop policy maps each possible state and time to a control, unlike an open-loop sequence that prescribes actions only along a nominal trajectory.
- Feedback provides an action when disturbances or model mismatch move a system off its nominal trajectory, but computing a policy is more computationally intensive.
- The discrete-time formulation indexes instants by stage k, with each stage corresponding to a time such as 0, 0.1, or 0.2 seconds.
- Euler discretization approximates x-dot = f(x,u,t) with x(t+delta t) = x(t) + delta t f(x,u,t), producing a discrete state-update equation.
- Controls are selected at each stage and must satisfy state-dependent constraints, such as acceleration or thrust limits.
- The objective adds stage costs l_k(x_k,u_k) and a terminal cost h(x_N), while the desired solution is a policy pi_k(x_k).
- Dynamic programming exploits the principle of optimality: the tail of an optimal multi-step solution must itself be optimal for the subproblem starting at the tail's state.
- The key assumption is additive cost, which lets a path from a to e through b be written as the cost from a to b plus the cost from b to e.
- Pavone introduces the principle as the structural link between an optimal-control formulation and an actionable recursive algorithm.
- Pavone proves the principle by contradiction: if the b-to-e tail were not optimal, a cheaper alternative tail could replace it.
- Replacing that tail would lower the total a-to-e cost while leaving the a-to-b segment unchanged, contradicting the assumption that the original path was optimal.
- The result applies to the remaining segment of an optimal sequence, not automatically to any arbitrary subset of that sequence.
- For an optimal sequence u_0* through u_(N-1)* and its associated states x_k*, the controls after stage k solve the truncated problem starting at x_k*.
- Pavone summarizes the idea as: tails of optimal sequences are optimal for their corresponding tail subproblems.
- The truncated problem retains only the costs from stage k onward, making previously solved future portions reusable.
- In an example with choices from b to c, d, or e, each immediate transition can be combined with the already computed optimal cost from that destination to f.
- The decision at b becomes a comparison of immediate cost plus tail cost, rather than a fresh search over every possible future control sequence.
- This reuse of subproblem solutions is the computational advantage that motivates dynamic programming.
- Dynamic programming solves the problem backward in time, beginning at the terminal stage where the remaining cost is simply the terminal cost.
- At each preceding stage, it combines an immediate action cost with the optimal cost-to-go from the next state.
- Once the recursion has reached the initial stage, the stored minimizing actions across states define the closed-loop policy.
- Pavone works through a graph from initial node a to destination h, using the cost of each arrow as a stage cost.
- Starting at h gives cost 0; working backward yields J(g)=2, J(f)=5, and J(e)=min(8, 2+5)=7.
- Continuing the calculations gives J(d)=10, J(c)=8, J(b)=17, and J(a)=min(8+10, 5+17)=18.
- Backtracking the minimizing choices gives the path a to d to e to f to g to h.
- A problem must be expressed using discrete stages, state transitions, and additive costs before the standard recursion can be applied.
- For shortest paths, the stage index can represent the number of hops remaining to reach the destination, which provides an ordering for backward computation.
- Pavone identifies problem formulation as a key source of difficulty, even when the recursion itself is straightforward.
- Dynamic programming solves an optimization at every stage and every relevant state; continuous states generally require quantization to make this computation finite.
- With 10 discretized values per state dimension and 10 time steps, a one-dimensional state requires about 100 state-stage recursions.
- A two-dimensional state requires about 1,000 recursions under the same grid, while a three-dimensional state requires about 10,000.
- The exponential growth with state dimension is the curse of dimensionality, motivating approximate dynamic programming and learning-based control.
- Recording the minimizing control for each state constructs a policy that can respond to whichever state the system reaches.
- The Bellman decision balances immediate cost against the effect of today's action on tomorrow's cost-to-go.
- Pavone emphasizes that solving from a particular initial state can require considering many possible intermediate states, since the future trajectory is not known in advance.
- Dynamic programming seeks a global minimum at each recursion, while state constraints can reduce the actions that must be considered.
- The LQR system has dynamics x_(k+1)=A x_k+B u_k, where A is the state matrix and B is the input matrix.
- Its stage cost is quadratic in state and control, and its terminal cost is quadratic in the final state, with Q, R, and H positive semidefinite and R strengthened to positive definite.
- The objective trades off moving the state toward the origin against control effort, such as energy use.
- LQR is useful in trajectory tracking and can support successive-linearization approaches to nonlinear optimal control.
- At the terminal stage N, the cost-to-go is the quadratic form one-half x_N^T H x_N, so Pavone initializes P_N=H.
- For each possible state x_(N-1), the recursion minimizes the stage cost plus the terminal cost evaluated at A x_(N-1)+B u_(N-1).
- With x_(N-1) fixed, this is a quadratic optimization over u_(N-1); positive-definite R ensures a unique minimizing control.
- Differentiating the quadratic objective produces a control that is linear in the current state.
- The optimal LQR action at each stage has state-feedback form u_k=K_k x_k, where the gain depends on A, B, R, and the next cost matrix P_(k+1).
- Substituting that control back into the objective leaves a quadratic cost-to-go in x_k, so the same structure repeats at every backward step.
- The backward computation updates the feedback gain K_k and cost matrix P_k, beginning with P_N=H; these matrix updates are the Riccati recursion.
- Pavone closes by distinguishing the easy procedural recursion from the harder tasks of modeling problems in the required form and scaling computation to large state spaces.
Transcript excerpt
0:05 So I hope you enjoyed the lectures from Daniele. Now, I'm back. For the next three lectures, I'll be your instructor. So let me first recap where we are, and then I'm going to introduce the topic for today. And to do so, let's go back to our usual roadmap for this class. So far, what we have been investigating is the left-hand side branch of this complicated roadmap. That is, we have been looking at the methods that solve the optimal control problem in open loop form. That is what we are trying to compute, is the sequence of controls parameterized by time, that optimize a given cost function given in additive form.
0:55 And we'll be looking at the two broad classes of methods referred to as the indirect methods and the direct methods. These two classes of methods are really complementary. So in the case of indirect methods, the idea is to first derive the necessary conditions for optimality. Basically, the generalization of the gradient equal to 0 condition from non-linear optimization to the setting of infinite dimensional optimization, namely optimal control. You saw that necessary optimality condition boils down to solving a 2 point boundary value problem, that is a differential equation with split boundary conditions. And historically, that's the first methods
1:43 that has been developed to solve this class of problems. And then you also saw the other approach referred to as direct methods, where the idea is to take the given continuous time optimal control problem, discretize it. And once you have discretized the problem, now you are back to the setting of a nonlinear optimization, and then use a nonlinear solver of your choice in order to solve that nonlinear optimization problem. These days, particularly for robotics, direct methods are more popular. Thanks to advances in algorithms, for example,
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Stanford Online.