Stanford AA203 Optimal and Learning-Based Control | Spring 2026 | Lecture 6: Direct Methods
Overview
Stanford Online's Lecture 6 on Direct Methods for Optimal Control introduces techniques to solve optimal control problems by discretizing them into nonlinear optimization problems. The lecture details two main families: state and control parameterization (collocation) and control parameterization (shooting), contrasting their approaches to handling states and controls as optimization variables. It also explores sequential convex programming (SCP) as an iterative strategy to solve these nonlinear problems by repeatedly solving linearized convex sub-problems, demonstrating practical examples like particle control and Zermelo's problem.
Key takeaways
- Direct methods transform optimal control problems into nonlinear optimization problems by discretizing time, offering an alternative to indirect methods.
- Two main direct method families exist: state/control parameterization (collocation) and control parameterization (shooting), differing in how states and controls are treated as optimization variables.
- Sequential Convex Programming (SCP) iteratively solves nonlinear optimal control problems by linearizing dynamics and cost around nominal trajectories, solving convex sub-problems at each step.
- Zermelo's problem (river crossing) illustrates challenges in direct methods, particularly sensitivity to initial guesses and constraint handling, requiring techniques like relaxation and iterative refinement.
- Control parameterization (shooting) may be less sensitive to initial guesses than state/control parameterization, especially when state constraints are complex.
- SCP leverages the efficiency of convex optimization solvers to tackle complex nonlinear optimal control problems, often employing techniques like trust regions and slack variables.
Chapters
- Indirect methods involve deriving optimality conditions (e.g., two-point boundary value problems) and solving them computationally.
- Direct methods offer an alternative by discretizing the optimal control problem into a nonlinear optimization problem.
- The lecture will focus on direct methods, starting with an example of a particle on a line system.
- Many solvers assume a standard form with a known final time.
- Time rescaling is used to transform problems with free final time into a standard form where tau = t / tf, making the final time 1.
- A dummy state variable 'r' with trivial dynamics (r_dot = 0) is introduced to represent the final time.
- Revisiting a previous example: controlling a particle from x=10 to x=0 with zero velocity.
- The cost functional includes a term for final time and control effort.
- This problem has a free final time, requiring the time rescaling and dummy variable trick.
- System dynamics: x1_dot = x2, x2_dot = u.
- Hamiltonian: H = 0.5 * u^2 + p1 * x2 + p2 * u.
- Optimality conditions: p1_dot = 0, p2_dot = -p1, u = -p2 / b.
- Initial conditions: x1(0)=10, x2(0)=0.
- Final conditions: x1(tf)=0, x2(tf)=0.
- Master boundary condition for free final time: H(tf) + terminal_cost_derivative = 0, leading to -p2^2 * tf / (2b) + alpha * tf = 0.
- Defining differential equations including the rescaled time dynamics and the dummy variable 'r'.
- Boundary conditions are fed to the solver as residuals.
- Discretized time array from 0 to 1 is used due to time rescaling.
- Running the solver yields a final time tf = 4.47.
- This matches the analytical solution (1800 * b/a)^(1/5).
- State variables x1 and x2, and control 'u' are visualized.
- Indirect methods require deriving optimality conditions, which can be complex.
- Direct methods are increasingly popular due to ease of use and direct discretization.
- Indirect methods offer potential for analytical solutions and interpretability (e.g., bang-bang control).
- Direct methods discretize the continuous-time optimal control problem into a nonlinear constrained optimization problem.
- Improvements in nonlinear optimization solvers make real-time solutions feasible.
- The core idea is to discretize time and solve the resulting optimization problem.
- State and Control Parameterization (Collocation): Both states and controls are optimization variables; dynamics become constraints.
- Control Parameterization (Shooting): Only controls are optimization variables; states are computed recursively from dynamics.
- Control parameterization: Smaller optimization problems (fewer variables), but harder to enforce state constraints.
- State and control parameterization: Easier to enforce state constraints by treating states as optimization variables.
- Hybrid methods like multiple shooting can combine benefits.
- Discretizes time using Euler integration and assumes a zero-order hold on controls.
- Dynamics are approximated using Euler's method: x(t+dt) = x(t) + dt * f(x, u, t).
- The cost integral is approximated as a sum, with integrals over time steps becoming products of cost function and step size 'h'.
- Goal: Cross a river with non-uniform flow, minimizing control effort (angle 'u').
- Problem setup: Constant forward velocity 'v', control 'u' is the angle, cost is integral of u^2.
- River flow lambda(y) is 0 at banks and maximum in the middle.
- Variables: x, y positions and control 'u' at discrete time steps.
- Constraints: Initial (0,0) and final (M,L) positions, control bounds [-umax, umax].
- Dynamics constraints: x(i+1) = x(i) + h * (v + lambda(y(i)) * cos(u(i))), y(i+1) = y(i) + h * (lambda(y(i)) * sin(u(i))). (Note: Actual code uses simpler dynamics for illustration).
- A restrictive umax (0.75) leads to solver failure ('garbage' solution).
- Direct methods are sensitive to initial guess quality and problem conditioning.
- Solving a relaxed problem (umax=1) first and using its solution as an initial guess for the constrained problem (umax=0.75) enables convergence.
- Only controls 'ui' are optimization variables; states are computed recursively.
- Dynamics are propagated forward from an initial state x0.
- This is also known as shooting methods due to the sequential propagation of states.
- Problem definition (dynamics, cost, bounds) is similar to the previous method.
- Constraints function depends only on 'u'; dynamics are propagated internally within the constraint evaluation.
- This method successfully solves both umax=1 and umax=0.75 cases, potentially less sensitive to initial guess quality.
Transcript excerpt
0:05 So for today, we will be, first of all, wrapping up the discussion on indirect methods. And then we'll be introducing another class of open loop control strategies, which is one of direct methods. And so specifically, remember that last time we basically were wrapping up the discussion, indirect methods, where a bird's eye view, we were saying that indirect methods represents this class of solution methods for optimal control problems, whereby we define and derive some optimality conditions which we want to solve for generating candidates for optimality. These optimal conditions boiled down into two-point boundary value problems, which we have to solve. And so, what we did is essentially started to look at computational methods for solving these two-point boundary value problems,
0:52 whereby we first of all introduced the solve BVP solver in Python, specifically for an abstract two-point boundary value problem. And so today we will be using the same solve BVP, but this time applied to an actual optimal control problem. First of all, so that you can see how this can be done in practice, and then also for you to have potentially a useful template for optimizing or for solving other optimal control problems. But specifically, we were also mentioning how these solve-- the solve BVP solvers, and most solvers out there, to be honest, for a two-point boundary value problem, assume that we specify the problem in quote unquote, "standard form," where, for example, we were assuming that the final time is given and known.
1:45 And so we know that in general, we have been dealing with optimal control problems where this is not the case. And so, there are a number of tricks that have been developed in order to basically reformulate any given structure of our optimal control problem into a form that is amenable for classical solvers.
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.