Numerical approaches
Numerical optimal control methods fall into indirect and direct methods. The distinction is whether we first derive optimality conditions or first approximate the problem with finitely many numbers. OpenGoddard uses a direct pseudospectral method.
| Indirect methods | Direct methods | |
|---|---|---|
| Approach | Optimize, then discretize | Discretize, then optimize |
| Resulting problem | Two-point boundary-value problem | Nonlinear programming problem (NLP) |
| Typical methods | Pontryagin’s minimum principle with shooting | Direct shooting and collocation, including pseudospectral methods |
Indirect methods: derive optimality conditions first
Section titled “Indirect methods: derive optimality conditions first”Connection to ordinary optimization
Section titled “Connection to ordinary optimization”At a smooth minimum of , we have . An indirect approach first derives this equation, then solves it. For constrained problems, Lagrange multipliers play the same role.
In optimal control, Pontryagin’s minimum principle introduces time-dependent multipliers for the dynamics. The Hamiltonian is
The multipliers are called costates or adjoint variables. An optimal solution satisfies
Boundary conditions and terminal costate conditions (transversality conditions) complete the system.
Example: minimum-time move and stop
Section titled “Example: minimum-time move and stop”For , , from the preceding page, duration is , so :
The costate equations give and . Thus is constant and is linear in time. Minimizing yields
A linear function changes sign at most once, so we know in advance that the optimum switches once from maximum acceleration to maximum braking. Revealing the structure of the solution is a major strength of indirect methods.
Two-point boundary-value problems and shooting
Section titled “Two-point boundary-value problems and shooting”The state has a known initial value, but the costate generally has terminal conditions instead. Differential equations with conditions at both ends form a two-point boundary-value problem.
In shooting, guess , integrate to the end, measure the terminal mismatch, and adjust the guess. It resembles adjusting a cannon’s aim until it hits a target.

Strengths and limitations
Section titled “Strengths and limitations”- Strength: high accuracy and analytic insight into the structure, such as the number of switches.
- Limitation: the Hamiltonian and costate equations must be derived for each problem. Inequality constraints can require guessing the sequence of constrained and unconstrained arcs.
- Limitation: costate guesses have little physical intuition. Integration can amplify small errors exponentially, making convergence sensitive to the guess.
Direct methods: discretize first
Section titled “Direct methods: discretize first”Represent the unknown functions and by finitely many numbers and express the dynamics, constraints, and objective in terms of them:
This is a nonlinear programming problem (NLP), solvable by a general-purpose optimizer. OpenGoddard defaults to SciPy’s SLSQP, a sequential quadratic programming method that repeatedly solves local approximations with a quadratic objective and linearized constraints.
Direct shooting
Section titled “Direct shooting”Parameterize only the controls, for example as piecewise constants, and obtain the states by numerical integration. This uses fewer variables, but integration can amplify errors, as in indirect shooting.
Collocation
Section titled “Collocation”Treat both state and control values at time nodes as unknowns. Replace integration by equality constraints requiring the state derivative to match the dynamics at every node. Optimization improves the objective and enforces the dynamics simultaneously. Avoiding repeated long integrations often makes the method more tolerant of poor initial guesses.
Collocation methods differ in their interpolants:
- Local collocation: use low-degree polynomials on short intervals, as in trapezoidal or Hermite–Simpson methods. These are robust, but accuracy usually improves algebraically with the number of points.
- Global collocation, or pseudospectral methods: use one high-degree polynomial over an entire phase, with specially placed nodes. For smooth solutions, error can decrease exponentially as nodes are added.
Strengths and limitations
Section titled “Strengths and limitations”- Strength: write dynamics, constraints, and costs without deriving costates or a Hamiltonian.
- Strength: express inequalities directly, without guessing where each constraint is active.
- Strength: initial guesses use physically meaningful states and controls.
- Limitation: more variables, roughly nodes times the number of states and controls.
- Limitation: the result is a local optimum of the discretized problem; accuracy depends on the discretization.
Where pseudospectral methods fit
Section titled “Where pseudospectral methods fit”Pseudospectral methods are direct global collocation methods. Their main advantages are:
- High accuracy with few nodes. In Example 03, increasing the node count from 6 to 8 to 10 reduces the duration error from roughly to to . At 12 nodes it approaches roundoff (accuracy check).
- Small optimization problems. Relatively few variables make general-purpose solvers such as SLSQP practical.
- Access to indirect information. NLP multipliers can estimate the continuous costates (Fahroo & Ross, 2001), allowing a direct solution to be checked against the minimum principle.
Discontinuities require care. A single polynomial oscillates near abrupt thrust switches or mass jumps. Split time into phases and use a separate polynomial in each (Examples 07 and 08).
Node choices include LG (Gauss), LGR (Radau), and LGL (Lobatto). OpenGoddard uses LGL, which includes both endpoints, making boundary and linkage conditions straightforward. The next page explains the construction.