Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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 and Direct Methods

Indirect methods

An indirect method:

  1. derives first-order necessary conditions;

  2. constructs the state–costate boundary-value problem;

  3. determines switching, singular, and boundary structures; and

  4. solves the resulting system.

Direct methods

A direct method:

  1. approximates the state and/or control;

  2. discretizes or integrates the dynamics;

  3. approximates the objective;

  4. enforces constraints numerically; and

  5. solves the resulting finite-dimensional nonlinear program.

From Infinite to Finite Dimensions

The original unknowns are functions:

x(),u().\boldsymbol{x}(\cdot), \qquad \boldsymbol{u}(\cdot).

This is an infinite-dimensional optimization problem.

A finite-dimensional approximation may be written as

x(t)i=1Nxcx,iϕi(t),\boxed{ \boldsymbol{x}(t) \approx \sum_{i=1}^{N_x} \boldsymbol{c}_{x,i}\phi_i(t), }

and

u(t)i=1Nucu,iαi(t).\boxed{ \boldsymbol{u}(t) \approx \sum_{i=1}^{N_u} \boldsymbol{c}_{u,i}\alpha_i(t). }

The functions ϕi\phi_i and αi\alpha_i are known basis or trial functions.

The coefficients are unknown decision variables.

Common Basis Functions

Possible choices include:

A global polynomial example is

u(t)c0+c1t+c2t2++cNtN.u(t) \approx c_0+c_1t+c_2t^2+\cdots+c_Nt^N.

Direct Shooting

Direct shooting parameterizes only the control.

Let

U(t;c)=i=1Nciαi(t).\boxed{ U(t;\boldsymbol{c}) = \sum_{i=1}^{N} c_i\alpha_i(t). }

The approximate control is substituted into

x˙=f(x,U(t;c),t).\dot{\boldsymbol{x}} = \boldsymbol{f}(\boldsymbol{x},U(t;\boldsymbol{c}),t).

Given:

the state trajectory is obtained by forward integration.

Unknowns in Direct Shooting

Typical decision variables are

z=[cx(t0)t0tf],\boldsymbol{z} = \begin{bmatrix} \boldsymbol{c}\\ \boldsymbol{x}(t_0)\\ t_0\\ t_f \end{bmatrix},

depending on which quantities are fixed.

The terminal state is not independently parameterized:

x(tf)=x(tf;z),\boldsymbol{x}(t_f) = \boldsymbol{x}(t_f;\boldsymbol{z}),

because it is produced by integration.

Cost Approximation

The original cost is

J=Φ(x(t0),t0,x(tf),tf)+t0tfL(x,U,t)dt.J = \Phi(\boldsymbol{x}(t_0),t_0,\boldsymbol{x}(t_f),t_f) + \int_{t_0}^{t_f} L(\boldsymbol{x},U,t)\,\mathrm{d} t.

After control parameterization and numerical integration,

JJa(z).J \approx J_a(\boldsymbol{z}).

Thus, the functional becomes an ordinary function of finitely many variables.

Integrating the Cost as an Additional State

Define

x˙n+1=L(x,U,t),\dot{x}_{n+1} = L(\boldsymbol{x},U,t),

with

xn+1(t0)=0.x_{n+1}(t_0)=0.

Then

xn+1(tf)=t0tfL(x,U,t)dt.x_{n+1}(t_f) = \int_{t_0}^{t_f} L(\boldsymbol{x},U,t)\,\mathrm{d} t.

The augmented integration is

ddt[xxn+1]=[f(x,U,t)L(x,U,t)].\frac{\,\mathrm{d}}{\,\mathrm{d} t} \begin{bmatrix} \boldsymbol{x}\\ x_{n+1} \end{bmatrix} = \begin{bmatrix} \boldsymbol{f}(\boldsymbol{x},U,t)\\ L(\boldsymbol{x},U,t) \end{bmatrix}.

Using the same integration method for dynamics and cost provides consistency.

Endpoint Constraints

Suppose the endpoint constraints are

Ψ(x(t0),t0,x(tf),tf)=0.\boldsymbol{\Psi} \left( \boldsymbol{x}(t_0),t_0, \boldsymbol{x}(t_f),t_f \right) = \boldsymbol{0}.

After integration,

Ψ=ge(z).\boldsymbol{\Psi} = \boldsymbol{g}_e(\boldsymbol{z}).

The direct-shooting problem becomes

minzJa(z)subject toge(z)=0.\boxed{ \begin{aligned} \min_{\boldsymbol{z}} \quad& J_a(\boldsymbol{z}) \\ \text{subject to} \quad& \boldsymbol{g}_e(\boldsymbol{z})=\boldsymbol{0}. \end{aligned} }

Additional inequalities may be included:

gi(z)0.\boldsymbol{g}_i(\boldsymbol{z})\leq\boldsymbol{0}.

This is a nonlinear programming problem.

The NLP View

The abstract nonlinear program is

minzf(z)subject toge(z)=0,gi(z)0.\begin{aligned} \min_{\boldsymbol{z}} \quad& f(\boldsymbol{z}) \\ \text{subject to} \quad& \boldsymbol{g}_e(\boldsymbol{z})=\boldsymbol{0}, \\ & \boldsymbol{g}_i(\boldsymbol{z})\leq\boldsymbol{0}. \end{aligned}

For direct shooting:

f(z)=Ja(z),ge(z)=endpoint residuals,gi(z)=parameter and sampled path constraints.\begin{aligned} f(\boldsymbol{z})&=J_a(\boldsymbol{z}),\\ \boldsymbol{g}_e(\boldsymbol{z})&=\text{endpoint residuals},\\ \boldsymbol{g}_i(\boldsymbol{z})&=\text{parameter and sampled path constraints}. \end{aligned}

A Basic Algorithm

  1. Choose a control parameterization.

  2. Choose an initial guess for the parameters.

  3. Construct U(t;c)U(t;\boldsymbol{c}).

  4. Integrate the dynamics.

  5. Integrate the running cost.

  6. Evaluate endpoint constraints.

  7. Evaluate sampled path constraints.

  8. Return objective and constraints to an NLP solver.

  9. Update the decision variables.

  10. Repeat until convergence.

The Main Strength of Direct Shooting

Direct shooting is attractive because:

The Main Weakness: Parameterization Error

Direct shooting does not optimize over all admissible controls. It optimizes over the selected approximation space:

UN=span{α1,,αN}.\mathcal{U}_N = \operatorname{span} \{\alpha_1,\ldots,\alpha_N\}.

Therefore, it finds

uN=argminuUNJ[u],u_N^* = \arg\min_{u\in\mathcal{U}_N}J[u],

not necessarily

u=argminuUJ[u].u^* = \arg\min_{u\in\mathcal{U}}J[u].

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

u(t)={umin,t<ts,umax,t>ts.u^*(t) = \begin{cases} u_{\min}, & t<t_s,\\ u_{\max}, & t>t_s. \end{cases}

This control is discontinuous.

A global polynomial approximation is smooth. Therefore, it cannot represent the switch exactly.

Increasing polynomial degree may introduce:

Structure-Aware Parameterization

If the bang–bang structure is known, a better approximation is

U(t)={c1,t<ts,c2,tts,U(t) = \begin{cases} c_1, & t<t_s,\\ c_2, & t\geq t_s, \end{cases}

with decision variables

c1,c2,ts.c_1,\quad c_2,\quad t_s.

For a bounded minimum-time problem, one may even impose

c1=umin,c2=umax,c_1=u_{\min}, \qquad c_2=u_{\max},

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:

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

c(x(tk),U(tk),tk)0\boldsymbol{c}(\boldsymbol{x}(t_k),U(t_k),t_k)\leq\boldsymbol{0}

at selected sample times tkt_k.

However, a constraint may be satisfied at the samples and violated between them.

Therefore, verification requires:

Sensitivity and Conditioning

The NLP solver needs derivatives such as

Jaz\frac{\partial J_a}{\partial\boldsymbol{z}}

and

gz.\frac{\partial\boldsymbol{g}}{\partial\boldsymbol{z}}.

These may be computed by:

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:

Examples may include some launch-vehicle guidance problems with piecewise low-order steering laws.

When Direct Shooting Performs Poorly

It can perform poorly when:

Why More General Direct Methods Are Needed

More advanced methods parameterize both states and controls and enforce dynamics at many points.

These include:

These methods usually introduce more decision variables but provide:

Practical Engineering Perspective

A computational method must do more than return a feasible-looking trajectory.

It should provide evidence that:

Small improvements can have large economic value in:

Common Errors

  1. Calling the approximate control the exact optimal control.

  2. Choosing basis functions without considering solution regularity.

  3. Using a global polynomial for a discontinuous control.

  4. Ignoring violations between path-constraint sample points.

  5. Treating terminal state values as independent of the control parameters.

  6. Using an inconsistent integration method for dynamics and cost.

  7. Failing to test higher-order or refined parameterizations.

  8. Reporting an NLP optimum without verifying the original continuous problem.

Verification Checklist

After convergence:

  1. reintegrate with tighter tolerances;

  2. sample constraints densely;

  3. increase parameterization order;

  4. change the basis;

  5. perturb the initial guess;

  6. compare objective values;

  7. inspect control smoothness and switching;

  8. check endpoint residuals;

  9. compare against necessary conditions when possible; and

  10. document convergence behavior.

Summary

  1. Direct methods convert optimal control into finite-dimensional optimization.

  2. Direct shooting parameterizes only the control.

  3. States and cost are obtained through numerical integration.

  4. The resulting problem is an NLP.

  5. Direct shooting is simple and useful for low-dimensional control structures.

  6. Its accuracy is limited by the approximation space.

  7. Smooth global functions may poorly represent discontinuous controls.

  8. Structure-aware parameterizations can be excellent when the structure is known.

  9. Path constraints and long-horizon sensitivities remain challenging.

  10. 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.