Stanford AA203 Optimal and Learning-Based Control | Spring 2026 | Lecture 3: Calculus of Variations
Overview
Daniele Gammelli completes the finite-dimensional optimization review with active inequality constraints and the Karush-Kuhn-Tucker (KKT) conditions, then introduces calculus of variations as a route to necessary optimality conditions for continuous-time control. Starting with a fixed-endpoint functional J = ∫g(x, ẋ, t)dt, he uses a first-order Taylor expansion, integration by parts, and the fundamental lemma to derive the Euler-Lagrange equation.
Key takeaways
- At a feasible local minimum, inactive inequality constraints have slack and can be removed locally; active inequalities then contribute to stationarity like equality constraints.
- KKT conditions require zero Lagrangian gradient, feasible constraints, nonnegative inequality multipliers, and zero multipliers for inactive constraints, with a constraint qualification needed for the stated result.
- In the example minimizing x² + y² subject to 2x + y ≤ 2, the active case forces μ = −4/5 and is rejected, while the inactive case produces the feasible global minimum (0, 0).
- Indirect optimal-control methods derive continuous-time necessary conditions before numerical discretization, whereas direct methods discretize the problem before optimization.
- For J(x) = ∫g(x, ẋ, t)dt with fixed endpoints, Taylor expansion and integration by parts reduce the first variation to an integral multiplying δx.
- The fundamental lemma converts the requirement that the first variation vanish for all admissible δx into the Euler-Lagrange equation d/dt(∂g/∂ẋ) − ∂g/∂x = 0.
Chapters
- Daniele Gammelli recaps optimal control as choosing a time-varying input u(t) to steer a state trajectory and minimize terminal plus running cost.
- The lecture first completes finite-dimensional necessary conditions, then turns to infinite-dimensional optimal control.
- Inequality constraints are written g_j(x) ≤ 0, alongside equality constraints h_i(x) = 0.
- An inequality constraint is active at x when g_j(x) = 0, and inactive when g_j(x) < 0.
- For minimizing x + y subject to x ≥ 0, y ≥ 0, and x + y ≤ 3, the origin activates the first two constraints while x + y ≤ 3 is inactive.
- The active set A(x) is a set of constraint indices determined by evaluating the constraints at the point.
- At a feasible local minimum, inactive constraints have slack, so a sufficiently small neighborhood preserves their feasibility.
- If removing inactive constraints produced a nearby feasible point with lower cost, that point would also satisfy the original constraints, contradicting local optimality.
- This argument lets active inequalities be treated like equalities when deriving local necessary conditions.
- The equality-constrained Lagrangian adds terms λ_i h_i(x) to the objective f(x).
- For inequalities, active constraints contribute multiplier terms μ_j g_j(x), while inactive constraints have μ_j = 0.
- The stationarity condition sets the gradient of the expanded Lagrangian to zero, and inequality multipliers must be nonnegative.
- The Karush-Kuhn-Tucker conditions combine Lagrangian stationarity, primal feasibility, nonnegative inequality multipliers, and zero multipliers for inactive constraints.
- Gammelli states a constraint qualification: gradients of the equality constraints and active inequalities must be linearly independent for the stated multiplier result.
- KKT conditions are necessary filters for local minima, not a guarantee that every point satisfying them is a minimum.
- The example minimizes x² + y² subject to 2x + y ≤ 2, with objective gradient (2x, 2y) and constraint gradient (2, 1).
- Assuming the constraint is active gives x = −μ and y = −μ/2; enforcing 2x + y = 2 requires μ = −4/5, which violates μ ≥ 0.
- Assuming the constraint is inactive sets μ = 0, yielding the feasible candidate (0, 0), the global minimum in this example.
- The upcoming course block focuses on open-loop optimal-control methods, distinguishing them from closed-loop policies.
- Indirect methods derive continuous-time optimality conditions first, then use numerical solvers that discretize the resulting equations.
- These methods can yield analytical or semi-analytical solutions useful in compute-limited aerospace systems and can provide initial guesses for direct methods.
- An optimal-control input u(t) is an entire function over time, making the search infinite-dimensional rather than a finite vector optimization.
- A functional maps a function, such as a trajectory, to a scalar cost; Gammelli describes functionals as functions over functions.
- Calculus of variations generalizes ordinary calculus to find extrema of functionals and will be connected back to finite-dimensional optimization.
- A functional assigns a unique real number to each function in a specified class, such as continuous functions.
- A functional is linear when it satisfies homogeneity, J(αx) = αJ(x), and additivity, J(x + y) = J(x) + J(y).
- The example J(x) = ∫ from t₀ to t_f of x(t)dt is linear because scaling can be taken outside the integral.
- A norm assigns a nonnegative magnitude to a function, is zero only for the zero function, respects scaling, and satisfies the triangle inequality.
- To measure the distance between functions y and z, take the norm of their difference y − z.
- For continuous x(t), the supremum norm max over t ∈ [t₀, t_f] of |x(t)| is one example.
- A functional has a local minimum at x*(t) if its value is no greater than that of every sufficiently close function under the chosen norm.
- A variation δx(t) is itself a function that perturbs a trajectory to x(t) + δx(t).
- The functional increment is ΔJ = J(x + δx) − J(x), analogous to the change in a finite-dimensional objective.
- Differentiability expresses the increment as a linear variation δJ plus a remainder that becomes negligible relative to the perturbation.
- The fundamental theorem of calculus of variations says that at an unconstrained extremum, δJ must vanish for every sufficiently small admissible variation.
- This is the infinite-dimensional counterpart of the finite-dimensional condition ∇f(x*)ᵀδx = 0, which leads to ∇f(x*) = 0.
- Gammelli considers minimizing J(x) = ∫ from t₀ to t_f of g(x, ẋ, t)dt, treating the trajectory as directly chosen rather than introducing a separate control.
- The integrand g is assumed twice differentiable, while initial and final times and endpoint states x(t₀) = x₀ and x(t_f) = x_f are fixed.
- With fixed endpoints, admissible variations satisfy δx(t₀) = δx(t_f) = 0.
- Substituting J into ΔJ gives the integral of g(x + δx, ẋ + δẋ, t) − g(x, ẋ, t).
- A first-order Taylor expansion yields the linear terms g_x δx and g_ẋ δẋ, plus higher-order terms.
- The first variation is δJ = ∫(g_x δx + g_ẋ δẋ)dt; the higher-order terms are excluded from this linear approximation.
- Integration by parts transforms ∫g_ẋ δẋ dt into the boundary term [g_ẋ δx] from t₀ to t_f minus ∫d(g_ẋ)/dt · δx dt.
- Because the endpoints are fixed, δx(t₀) and δx(t_f) are zero, so the boundary term vanishes.
- The variation becomes δJ = ∫[g_x − d(g_ẋ)/dt]δx dt, expressed entirely in terms of δx.
- The fundamental lemma states that if ∫h(t)δx(t)dt is zero for all admissible variations, then h(t) must be zero throughout the interval.
- Applying the lemma to the first variation gives g_x − d(g_ẋ)/dt = 0, equivalently the Euler-Lagrange equation d/dt(∂g/∂ẋ) − ∂g/∂x = 0.
- The equation is the necessary optimality condition for the fixed-endpoint variational problem; Gammelli closes by noting that the derivation will be recapped in the next lecture.
Transcript excerpt
0:05 Hi, everyone. So first of all, great to see you here. My name is Daniele Gammelli. I'm a postdoc in the Autonomous Systems Lab in the Department of Aeronautics and Astronautics. As you might guess from the accent, I'm also Italian. So if optimal control doesn't work for you, I guess you'll be experts in Italian accents at the very least. So for today, the plan is that-- so over the last week, we started introducing the general formalism for optimal control. Specifically, we introduced the general problem formulation, which is something along the lines of-- we're given a dynamical system x of t, which is in the form of a differential equation. And the overall goal for us was to determine an optimal control
0:59 signal, u star of t, that minimizes some objective, which we defined as having a terminal cost h of x of tf for the final time tf plus our running cost. And then so this we realized that this was in an infinite dimensional. Yes? Can you use a different board? All right. Again, nothing new here. What I was saying here is we defined the optimal control problem as a dynamical system, where we wanted to define an optimal control u star of t.
1:50 And this control then steers the state trajectory x of t in a way that we can optimize an objective function j, which is composed of two terms, a terminal state-- terminal cost h of x of tf evaluated at the final time plus a running cost. Again, I don't want to just-- don't take too much out of this exactly, because we saw this already. And then given that we realized that this is an infinite dimensional optimization problem, we then went into-- opened a parenthesis about finite dimensional optimization,
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.