TL;DR
A system changes over time, and you can push it with an input. Optimal control asks which input makes a total cost as small as possible, where the cost adds up a running penalty and a final penalty. For linear dynamics and quadratic costs, the answer is a feedback law: the input is a fixed matrix times the current state. That is the linear-quadratic regulator (LQR).
Where you'll see it: flight and robot controllers, rocket landing, and the theory under model predictive control and the value-based methods of reinforcement learning.
Intuition
Imagine steering a boat across a river with a current. You could hold the wheel at one angle and drift, or correct constantly. The best policy depends on where you are now, not on a fixed script. If you are drifting left, push right harder. The rule "push right in proportion to how far left you are" is a feedback law.
Optimal control formalises this. There are three ingredients.
- State , the numbers that describe the system right now, such as position and velocity.
- Input , the choice you control, such as a motor torque.
- Cost, a number that says how bad a trajectory is. It is usually a running cost for each moment plus a terminal cost for where you end up.
Why does this need theory at all? Trying every input sequence is hopeless. The state at each moment depends on all the earlier inputs, so the choices are coupled over time. The two classical tools, the maximum principle and dynamic programming, deal with that coupling in different ways. For the linear-quadratic case they meet in a single matrix equation.
flowchart LR C[Controller: u = -Kx] -->|input u| P[Plant: dx/dt = Ax + Bu] P -->|state x| S[Sensor reads x] S --> C
The math
The problem
The state evolves by a differential equation with input :
Here is the time derivative of . The cost over a fixed horizon is
is the running cost and is the terminal cost. The goal is to find the input function that minimises . Notice that is a whole function of time, not a single number. This is why optimal control is a calculus of variations problem: the unknown is a function, and variational methods handle that.
Dynamic programming and the value function
Define the value function as the lowest cost you can still achieve if you are in state at time :
Splitting the first small step off gives the Hamilton-Jacobi-Bellman equation, the continuous version of the Bellman equation:
Here is the gradient of with respect to the state. The minimising at each point is the optimal feedback. The equation is exact but solving it is hard, because is a function of the whole state. In more than a few dimensions, storing it on a grid is impossible.
The maximum principle
Pontryagin's maximum principle takes a different route. It introduces a costate , a vector the same size as the state, and the Hamiltonian
The optimal trajectory satisfies three conditions. The state runs forward with . The costate runs backward with , and . The input minimises at each moment, . This turns the search over functions into a two-point boundary problem, which is solved numerically or by a shooting method.
Linear-quadratic regulator
Now take linear dynamics and quadratic cost. The state equation is , and the cost over an infinite horizon is
with and , so the cost penalises both state error and effort. The answer is a linear feedback
where is a symmetric matrix that solves the algebraic Riccati equation
Two facts make this useful. The feedback depends only on the model and the cost weights, not on the starting state. And the optimal cost from any starting state is , a quadratic form. Under standard conditions (the pair is stabilisable and sees every unstable mode), the closed loop is stable.
Worked examples
Take with cost . In the notation above, , , , .
- The Riccati equation is , so and (we take the positive root).
- The gain is .
- The optimal input is . The closed loop is , so .
- Check the cost: .
- This equals , as the theory says.
Interpretation: the plant alone would hold the state wherever it is, so the controller supplies all the decay, at rate 1, and the cost matches the value function exactly.
Now , same cost, so , , , . Without control the state grows as .
- Riccati: , so . The positive root is .
- Gain: .
- Closed loop: . The unstable plant is now stable.
- Check the Riccati: , which is consistent to rounding.
- Optimal cost from : .
Interpretation: the controller pulls the state back harder than the plant pushes it out. The feedback gain is larger than the unstable rate, so the closed loop decays at rate 1.414. The plot shows the uncontrolled and controlled trajectories from .
- no control
- optimal LQR
Tradeoffs and failure modes
| Situation | What goes wrong | Better choice |
|---|---|---|
| Dynamics are linear and cost is quadratic | Nothing, this is the easy case | LQR. One Riccati solve gives the whole controller |
| Dynamics are nonlinear | The Riccati equation does not apply | Linearise around a trajectory and iterate (iLQR), or use model predictive control |
| Hard limits on input or state | LQR may demand impossible inputs | Pontryagin with constraints, or model predictive control, which re-solves with the limits in place |
| The model is wrong | The optimal gain is optimal only for the model you gave it | Robust control, or re-estimate the model online |
| State has many dimensions | Solving the Hamilton-Jacobi-Bellman equation on a grid is impossible | Approximate dynamic programming, or use the maximum principle numerically |
| Only some states are measured | The feedback needs the full state | Combine LQR with a Kalman filter (LQG) |
The main failure mode is confusing the model with the plant. A gain that is optimal for a model can be unstable on real hardware if the delay, the friction, or the sensor noise is different.
History
The calculus of variations was developed in the 1700s by Euler and Lagrange, to find curves that minimise integrals. The idea that a control input could be chosen optimally was made practical in the late 1950s. Lev Pontryagin and his colleagues stated the maximum principle around 1956 to 1958, and Richard Bellman developed dynamic programming in the same period. Rudolf Kalman's work around 1960 gave the linear-quadratic regulator and its filtering counterpart. These results were used for aerospace guidance and then for industrial control. Model predictive control grew out of this work in the process industries, starting in the 1970s, and handles constraints that LQR cannot.
Check yourself
QuestionFor the scalar plant with and , what is the optimal gain if you change to 4?Show answer
With , , , , the Riccati equation is , so and . The gain is . Making effort more expensive ( larger) lowers the gain, so the controller acts more gently.
QuestionCompute the value of and explain what it tests.Show answer
, to rounding. This tests that satisfies the algebraic Riccati equation for , , , . If the value were not close to zero, the chosen would be wrong and the gain would not give the optimal feedback.
QuestionWhy does the optimal feedback not depend on the starting state , while the optimal cost does?Show answer
The feedback is the policy: it says what to do at each state, and it depends only on the dynamics and the cost weights. The cost is the value of being in a particular state, and that value depends on how far from zero the state starts. For LQR the cost is , so it grows with the square of the starting distance, while the policy is the same linear rule everywhere.
QuestionA drone's dynamics are nonlinear and it must keep its thrust between 0 and 10 newtons. Which tool from this lesson fits best, and why not plain LQR?Show answer
Model predictive control fits best. Plain LQR assumes linear dynamics and does not enforce limits, so it can ask for thrust outside 0 to 10 newtons. Model predictive control solves a finite-horizon problem at each step with the limits as constraints, and it applies only the first input before re-solving. It can handle nonlinear models, at the cost of solving an optimisation problem online.
Sources
- Optimal control, Wikipedia
- Pontryagin's maximum principle, Wikipedia
- Donald E. Kirk, Optimal Control Theory: An Introduction. A standard text covering the maximum principle and linear-quadratic regulators.