Direct Numerical Methods and Direct Shooting
Indirect methods derive and solve the continuous first-order optimality conditions. Direct methods instead approximate the state and/or control with finite-dimensional representations and transcribe the optimal-control problem into a nonlinear programming problem.
This section introduces:
indirect versus direct methods;
state and control parameterization;
trial or basis functions;
finite-dimensional transcription;
direct shooting;
numerical integration of dynamics and cost;
the nonlinear programming formulation;
parameterization error;
discontinuous controls; and
method-selection considerations.
Indirect and Direct Methods¶
Indirect methods¶
An indirect method:
derives first-order necessary conditions;
constructs the state–costate boundary-value problem;
determines switching, singular, and boundary structures; and
solves the resulting system.
Direct methods¶
A direct method:
approximates the state and/or control;
discretizes or integrates the dynamics;
approximates the objective;
enforces constraints numerically; and
solves the resulting finite-dimensional nonlinear program.
From Infinite to Finite Dimensions¶
The original unknowns are functions:
This is an infinite-dimensional optimization problem.
A finite-dimensional approximation may be written as
and
The functions and are known basis or trial functions.
The coefficients are unknown decision variables.
Common Basis Functions¶
Possible choices include:
monomials;
piecewise constants;
piecewise linear functions;
splines;
Lagrange polynomials;
Legendre polynomials;
Chebyshev polynomials; and
local finite-element basis functions.
A global polynomial example is
Direct Shooting¶
Direct shooting parameterizes only the control.
Let
The approximate control is substituted into
Given:
the parameter vector ;
an initial state;
an initial time; and
a final time,
the state trajectory is obtained by forward integration.
Unknowns in Direct Shooting¶
Typical decision variables are
depending on which quantities are fixed.
The terminal state is not independently parameterized:
because it is produced by integration.
Cost Approximation¶
The original cost is
After control parameterization and numerical integration,
Thus, the functional becomes an ordinary function of finitely many variables.
Integrating the Cost as an Additional State¶
Define
with
Then
The augmented integration is
Using the same integration method for dynamics and cost provides consistency.
Endpoint Constraints¶
Suppose the endpoint constraints are
After integration,
The direct-shooting problem becomes
Additional inequalities may be included:
This is a nonlinear programming problem.
The NLP View¶
The abstract nonlinear program is
For direct shooting:
A Basic Algorithm¶
Choose a control parameterization.
Choose an initial guess for the parameters.
Construct .
Integrate the dynamics.
Integrate the running cost.
Evaluate endpoint constraints.
Evaluate sampled path constraints.
Return objective and constraints to an NLP solver.
Update the decision variables.
Repeat until convergence.
The Main Strength of Direct Shooting¶
Direct shooting is attractive because:
the state equations are satisfied through integration;
the number of decision variables may be small;
implementation is straightforward;
standard ODE solvers can be used;
standard NLP solvers can be used; and
it can work well when the control has a simple known structure.
The Main Weakness: Parameterization Error¶
Direct shooting does not optimize over all admissible controls. It optimizes over the selected approximation space:
Therefore, it finds
not necessarily
The result can be optimal for the parameterization but poor for the original problem.
Bang–Bang Controls and Smooth Basis Functions¶
Suppose the true control is
This control is discontinuous.
A global polynomial approximation is smooth. Therefore, it cannot represent the switch exactly.
Increasing polynomial degree may introduce:
oscillation;
overshoot;
poor local resolution;
numerical ill-conditioning; and
inaccurate switching times.
Structure-Aware Parameterization¶
If the bang–bang structure is known, a better approximation is
with decision variables
For a bounded minimum-time problem, one may even impose
and optimize only the switching time.
This can recover the exact solution when the assumed structure is correct.
The Structural Knowledge Dilemma¶
A structure-aware parameterization is powerful only when the solution structure is known.
However, in a difficult problem, the analyst may not know:
how many switches occur;
whether singular arcs exist;
whether path constraints become active;
whether the control is smooth;
whether the control is discontinuous; or
where local features occur.
Thus, direct shooting can be highly effective or highly misleading, depending on the chosen parameterization.
Path Constraints in Direct Shooting¶
Direct shooting does not automatically enforce path constraints continuously.
One common approximation is to enforce
at selected sample times .
However, a constraint may be satisfied at the samples and violated between them.
Therefore, verification requires:
dense post-processing;
adaptive sampling;
event detection;
mesh refinement; or
a more suitable transcription method.
Sensitivity and Conditioning¶
The NLP solver needs derivatives such as
and
These may be computed by:
finite differences;
sensitivity equations;
complex-step differentiation;
automatic differentiation; or
adjoint methods.
Long-horizon instability can still make direct shooting poorly conditioned because terminal quantities may be extremely sensitive to the control parameters.
When Direct Shooting Works Well¶
Direct shooting can work well when:
the control is low-dimensional;
the control is smooth or piecewise simple;
the time horizon is moderate;
the dynamics are not excessively unstable;
path constraints are mild;
a good initial guess is available; and
the solution structure is known approximately.
Examples may include some launch-vehicle guidance problems with piecewise low-order steering laws.
When Direct Shooting Performs Poorly¶
It can perform poorly when:
the control contains many local features;
switching structure is unknown;
singular arcs occur;
strong path constraints are present;
the horizon is long;
the state is highly sensitive to parameters;
the chosen basis is globally smooth but the solution is not; or
many coefficients are required.
Why More General Direct Methods Are Needed¶
More advanced methods parameterize both states and controls and enforce dynamics at many points.
These include:
direct multiple shooting;
direct transcription;
collocation;
orthogonal collocation;
pseudospectral methods; and
finite-element methods in time.
These methods usually introduce more decision variables but provide:
better local resolution;
improved handling of path constraints;
sparse NLP structure;
reduced sensitivity to one-way propagation; and
systematic mesh refinement.
Practical Engineering Perspective¶
A computational method must do more than return a feasible-looking trajectory.
It should provide evidence that:
the solution is close to the true optimum;
constraints are satisfied;
the result is insensitive to mesh or parameterization changes;
the objective has converged;
the control structure is resolved; and
the numerical result is physically meaningful.
Small improvements can have large economic value in:
aerospace propellant usage;
chemical processing;
refinery energy consumption;
thermal systems;
power generation; and
long-duration industrial operation.
Common Errors¶
Calling the approximate control the exact optimal control.
Choosing basis functions without considering solution regularity.
Using a global polynomial for a discontinuous control.
Ignoring violations between path-constraint sample points.
Treating terminal state values as independent of the control parameters.
Using an inconsistent integration method for dynamics and cost.
Failing to test higher-order or refined parameterizations.
Reporting an NLP optimum without verifying the original continuous problem.
Verification Checklist¶
After convergence:
reintegrate with tighter tolerances;
sample constraints densely;
increase parameterization order;
change the basis;
perturb the initial guess;
compare objective values;
inspect control smoothness and switching;
check endpoint residuals;
compare against necessary conditions when possible; and
document convergence behavior.
Summary¶
Direct methods convert optimal control into finite-dimensional optimization.
Direct shooting parameterizes only the control.
States and cost are obtained through numerical integration.
The resulting problem is an NLP.
Direct shooting is simple and useful for low-dimensional control structures.
Its accuracy is limited by the approximation space.
Smooth global functions may poorly represent discontinuous controls.
Structure-aware parameterizations can be excellent when the structure is known.
Path constraints and long-horizon sensitivities remain challenging.
More general direct methods address many of these limitations.
Connection. Direct shooting depends on repeated propagation of the dynamics, making numerical integration the essential bridge to more general direct transcriptions.