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.

Adaptive Mesh Refinement for Pseudospectral Optimal Control

Adaptive mesh refinement is the process of repeatedly modifying the discretization until the numerical solution satisfies a prescribed accuracy requirement. In a multiple-interval pseudospectral method, the mesh is defined by:

The refinement process is iterative:

  1. choose an initial mesh;

  2. solve the nonlinear programming problem;

  3. estimate the discretization error;

  4. modify the mesh;

  5. interpolate the previous solution onto the new mesh;

  6. resolve the NLP;

  7. repeat until the accuracy tolerance is satisfied.

This procedure is analogous to adaptive step-size integration for ordinary differential equations. In smooth regions, relatively large intervals or higher-order polynomials may provide excellent accuracy. Near rapid changes, switching points, singular arcs, boundary layers, or discontinuities, smaller intervals are often necessary.

This section develops an interpolation-and-integration error estimator for multiple-interval Legendre–Gauss–Radau (LGR) collocation and explains how the estimated error can guide hh-, pp-, and hphp-refinement.

Initial Mesh and Polynomial Degrees

The transformed time domain is

s[1,1].s\in[-1,1].

Choose mesh points

1=s0<s1<<sK1<sK=1.-1=s_0<s_1<\cdots<s_{K-1}<s_K=1.

The kkth mesh interval is

Sk=[sk1,sk].\mathcal{S}_k=[s_{k-1},s_k].

Assign NkN_k LGR collocation points to interval kk:

s1(k),,sNk(k).s_1^{(k)},\ldots,s_{N_k}^{(k)}.

The state is approximated using Nk+1N_k+1 points:

s1(k),,sNk(k),sNk+1(k),s_1^{(k)},\ldots,s_{N_k}^{(k)},s_{N_k+1}^{(k)},

where

sNk+1(k)=sk.s_{N_k+1}^{(k)}=s_k.

Thus, the discretization is determined by:

M={s0,,sK;N1,,NK}.\mathcal{M} = \left\{ s_0,\ldots,s_K; N_1,\ldots,N_K \right\}.

Mesh Refinement as an Iterative Process

Let M(r)\mathcal{M}^{(r)} denote the mesh at refinement iteration rr. The basic process is

M(r)NLP solutionerror estimateM(r+1).\mathcal{M}^{(r)} \rightarrow \text{NLP solution} \rightarrow \text{error estimate} \rightarrow \mathcal{M}^{(r+1)}.

The iteration terminates when

ekϵfor all k=1,,K,e_k\le\epsilon \qquad \text{for all }k=1,\ldots,K,

where eke_k is an interval-wise error indicator and ϵ\epsilon is the required tolerance.

State Approximation on One Mesh Interval

Consider interval

Sk=[sk1,sk].\mathcal{S}_k=[s_{k-1},s_k].

The LGR state polynomial is

X(k)(s)=i=1Nk+1Xi(k)i(k)(s),\boldsymbol{X}^{(k)}(s) = \sum_{i=1}^{N_k+1} \boldsymbol{X}_i^{(k)} \ell_i^{(k)}(s),

where

i(k)(s)=j=1jiNk+1ssj(k)si(k)sj(k).\ell_i^{(k)}(s) = \prod_{\substack{j=1\\j\neq i}}^{N_k+1} \frac{s-s_j^{(k)}}{s_i^{(k)}-s_j^{(k)}}.

Because the state polynomial is known, it can be evaluated at any point in the interval.

Constructing an Enriched LGR Grid

To assess accuracy, create a new set of LGR points containing one additional collocation point:

Mk=Nk+1.M_k=N_k+1.

Let the enriched LGR nodes be

s~1(k),,s~Mk(k).\widetilde{s}_1^{(k)}, \ldots, \widetilde{s}_{M_k}^{(k)}.

The associated additional terminal state point is

s~Mk+1(k)=sk.\widetilde{s}_{M_k+1}^{(k)}=s_k.

Because the new LGR set has a different polynomial degree, most of its interior points differ from the original set.

Interpolated State on the Enriched Grid

Evaluate the original state polynomial at the enriched nodes:

Yj(k)=X(k)(s~j(k)),j=1,,Mk+1.\boxed{ \boldsymbol{Y}_j^{(k)} = \boldsymbol{X}^{(k)}\left(\widetilde{s}_j^{(k)}\right), \qquad j=1,\ldots,M_k+1. }

Equivalently,

Yj(k)=i=1Nk+1Xi(k)i(k)(s~j(k)).\boldsymbol{Y}_j^{(k)} = \sum_{i=1}^{N_k+1} \boldsymbol{X}_i^{(k)} \ell_i^{(k)}\left(\widetilde{s}_j^{(k)}\right).

Define the state interpolation matrix

Iji(k)=i(k)(s~j(k)).I_{ji}^{(k)} = \ell_i^{(k)}\left(\widetilde{s}_j^{(k)}\right).

Then

Y(k)=Ix(k)X(k).\boxed{ \boldsymbol{Y}^{(k)} = \boldsymbol{I}_x^{(k)} \boldsymbol{X}^{(k)}. }

The state interpolation is unique because the state polynomial is explicitly known.

Why Control Interpolation Is Different

The control variables in a direct collocation method are nodal samples:

Ui(k)u(si(k)).\boldsymbol{U}_i^{(k)} \approx \boldsymbol{u}\left(s_i^{(k)}\right).

Unlike the state, the control is not necessarily defined by a unique polynomial approximation. Infinitely many continuous functions can pass through the same set of control samples.

Therefore, the control reconstruction is not unique.

Piecewise-Linear Control Reconstruction

A simple reconstruction is piecewise-linear interpolation.

Let

Vj(k)\boldsymbol{V}_j^{(k)}

denote the control evaluated at the enriched node

s~j(k).\widetilde{s}_j^{(k)}.

Then

Vj(k)=PLInterp({si(k),Ui(k)}i=1Nk,s~j(k)).\boxed{ \boldsymbol{V}_j^{(k)} = \operatorname{PLInterp} \left( \left\{s_i^{(k)},\boldsymbol{U}_i^{(k)}\right\}_{i=1}^{N_k}, \widetilde{s}_j^{(k)} \right). }

Piecewise-linear interpolation is not guaranteed to reproduce the exact control, but it is:

Implicit Integration Form of the LGR Method

The LGR collocation method can be written in differentiation form or in an equivalent implicit integration form.

For the original grid in interval kk:

X2:Nk+1(k)=1(X1(k))T+tft02A(k)F1:Nk(k),\boldsymbol{X}_{2:N_k+1}^{(k)} = \boldsymbol{1} \left(\boldsymbol{X}_1^{(k)}\right)^\mathsf{T} + \frac{t_f-t_0}{2} \boldsymbol{A}^{(k)} \boldsymbol{F}_{1:N_k}^{(k)},

where:

For a scalar state, this becomes

Xj(k)=X1(k)+tft02i=1NkAji(k)Fi(k),j=2,,Nk+1.X_j^{(k)} = X_1^{(k)} + \frac{t_f-t_0}{2} \sum_{i=1}^{N_k} A_{ji}^{(k)} F_i^{(k)}, \qquad j=2,\ldots,N_k+1.

Integrated State on the Enriched Grid

On the enriched grid, evaluate the dynamics using the interpolated state and reconstructed control:

F~j(k)=f(Yj(k),Vj(k),t~j(k),p),j=1,,Mk.\widetilde{\boldsymbol{F}}_j^{(k)} = \boldsymbol{f}\left( \boldsymbol{Y}_j^{(k)}, \boldsymbol{V}_j^{(k)}, \widetilde{t}_j^{(k)}, \boldsymbol{p} \right), \qquad j=1,\ldots,M_k.

The enriched physical time is

t~j(k)=tft02s~j(k)+tf+t02.\widetilde{t}_j^{(k)} = \frac{t_f-t_0}{2} \widetilde{s}_j^{(k)} + \frac{t_f+t_0}{2}.

Use the enriched LGR integration matrix B(k)\boldsymbol{B}^{(k)}:

Z2:Mk+1(k)=1(Y1(k))T+tft02B(k)F~1:Mk(k).\boxed{ \boldsymbol{Z}_{2:M_k+1}^{(k)} = \boldsymbol{1} \left(\boldsymbol{Y}_1^{(k)}\right)^\mathsf{T} + \frac{t_f-t_0}{2} \boldsymbol{B}^{(k)} \widetilde{\boldsymbol{F}}_{1:M_k}^{(k)}. }

The initial value satisfies

Z1(k)=Y1(k)=X1(k).\boldsymbol{Z}_1^{(k)} = \boldsymbol{Y}_1^{(k)} = \boldsymbol{X}_1^{(k)}.

Two Independent State Estimates

The enriched grid now contains two state estimates.

Interpolation-Based Estimate

Yj(k)=X(k)(s~j(k)).\boldsymbol{Y}_j^{(k)} = \boldsymbol{X}^{(k)}\left(\widetilde{s}_j^{(k)}\right).

This estimate comes directly from the original state polynomial.

Dynamics-Based Estimate

Zj(k)\boldsymbol{Z}_j^{(k)}

is obtained by integrating the dynamics on the enriched grid using the interpolated state and reconstructed control.

If the original solution is sufficiently accurate, the two estimates should be close.

Absolute Error Indicator

Define the pointwise error:

δj(k)=Yj(k)Zj(k).\boldsymbol{\delta}_j^{(k)} = \left| \boldsymbol{Y}_j^{(k)} - \boldsymbol{Z}_j^{(k)} \right|.

For multiple states, the absolute value is taken componentwise.

A scalar interval indicator is

ekabs=maxj=1,,Mk+1Yj(k)Zj(k).\boxed{ e_k^{\mathrm{abs}} = \max_{j=1,\ldots,M_k+1} \left\lVert \boldsymbol{Y}_j^{(k)}-\boldsymbol{Z}_j^{(k)} \right\rVert_\infty. }

Relative Error Indicator

A relative measure is often more useful:

ek=maxjmaxr=1,,nxYjr(k)Zjr(k)1+Yjr(k).\boxed{ e_k = \max_j \max_{r=1,\ldots,n_x} \frac{ \left| Y_{jr}^{(k)} - Z_{jr}^{(k)} \right| }{ 1+ \left| Y_{jr}^{(k)} \right| }. }

Alternatively, each state can be normalized using a problem-specific scale SrS_r:

ek=maxjmaxrYjr(k)Zjr(k)Sr.e_k = \max_j \max_r \frac{ \left| Y_{jr}^{(k)} - Z_{jr}^{(k)} \right| }{ S_r }.

The interval is accepted if

ekϵ.e_k\le\epsilon.

Interpretation of the Error Distribution

The maximum error alone determines whether refinement is needed. The spatial distribution of the pointwise error helps determine which type of refinement should be used.

Let

δj(k)=Yj(k)Zj(k).\delta_j^{(k)} = \left\lVert \boldsymbol{Y}_j^{(k)}-\boldsymbol{Z}_j^{(k)} \right\rVert_\infty.

Two common patterns are:

Localized Error

The tolerance is violated only in a small region.

This may indicate:

The preferred response is usually hh-refinement.

Distributed Error

The tolerance is violated throughout most of the interval.

This suggests that the polynomial degree is insufficient over the entire interval.

The preferred response is usually pp-refinement.

hh-Refinement

In hh-refinement, an interval is subdivided:

[sk1,snew][snew,sk].\rightarrow [s_{k-1},s_{\mathrm{new}}] \cup [s_{\mathrm{new}},s_k].

A natural splitting location is the enriched point with maximum error:

j=argmaxjδj(k),j^\star = \arg\max_j \delta_j^{(k)},

and

snew=s~j(k).\boxed{ s_{\mathrm{new}} = \widetilde{s}_{j^\star}^{(k)}. }

Safeguards should prevent the new point from being too close to either endpoint.

pp-Refinement

In pp-refinement, the interval remains unchanged and the polynomial degree is increased:

Nknew=Nk+Δp.\boxed{ N_k^{\mathrm{new}} = N_k+\Delta p. }

Typical values are

Δp=1orΔp=2.\Delta p=1 \qquad\text{or}\qquad \Delta p=2.

A small increase is preferred because:

Maximum Polynomial Degree

Impose an upper bound:

NkNmax.N_k\le N_{\max}.

Typical choices might be

Nmax=8,10,12,or14.N_{\max}=8,\quad 10,\quad 12,\quad\text{or}\quad 14.

If pp-refinement is indicated but

Nk=Nmax,N_k=N_{\max},

the interval should be subdivided instead.

Thus:

Nk=Nmaxapply h-refinement.\boxed{ N_k=N_{\max} \quad\Longrightarrow\quad \text{apply }h\text{-refinement}. }

hphp-Refinement

An hphp method permits both:

A simple decision rule is:

Refinement type={none,ekϵ,h,error is localized,p,error is distributed and Nk<Nmax,h,error is distributed and Nk=Nmax.\text{Refinement type} = \begin{cases} \text{none}, & e_k\le\epsilon,\\ h, & \text{error is localized},\\ p, & \text{error is distributed and }N_k<N_{\max},\\ h, & \text{error is distributed and }N_k=N_{\max}. \end{cases}

Localized-Error Metric

To automate the decision, define the set

Vk={j:δj(k)>ϵ}.\mathcal{V}_k = \left\{ j: \delta_j^{(k)}>\epsilon \right\}.

Define the violation fraction:

ρk=VkMk+1.\rho_k = \frac{|\mathcal{V}_k|}{M_k+1}.

One simple rule is:

ρkρcritlocalized error.\rho_k\le\rho_{\mathrm{crit}} \quad\Longrightarrow\quad \text{localized error}.

For example,

ρcrit=0.25.\rho_{\mathrm{crit}}=0.25.

Then:

Alternative Smoothness Indicator

Another strategy is to inspect the decay of polynomial coefficients.

Write the state approximation in a Legendre basis:

X(k)(s)=n=0Nkan(k)Pn(τ(s)).X^{(k)}(s) = \sum_{n=0}^{N_k} a_n^{(k)} P_n(\tau(s)).

For a smooth function, the coefficients should decay rapidly:

an(k)0rapidly as nNk.|a_n^{(k)}| \rightarrow 0 \quad\text{rapidly as }n\rightarrow N_k.

If the decay is fast, pp-refinement is appropriate. If the decay is slow or irregular, hh-refinement is safer.

Adaptive Refinement Algorithm

Algorithm: Adaptive hphp Mesh Refinement

Choose an initial mesh and interval degrees.
Set tolerance epsilon, degree increment Delta  p, and N_{\max}.
for r=0,1,2,:
    Solve the NLP on the current mesh.
    for each interval k:
        Set M_k=N_k+1.
        Construct the enriched LGR grid.
        Interpolate the state onto the enriched grid.
        Reconstruct the control using piecewise-linear interpolation.
        Evaluate the dynamics on the enriched grid.
        Integrate the dynamics using the enriched LGR integration matrix.
        Compute the pointwise and interval errors.
        if e_k<=epsilon:
            Keep interval k unchanged.
        else if the error is localized:
            Split interval k near the maximum error.
        else if N_k<N_{\max}:
            Set N_k<- N_k+Delta  p.
        else:
            Split interval k near the maximum error.
        end if
    end for
    if all intervals satisfy the tolerance:
        Stop.
    end if
    Interpolate the previous solution onto the new mesh.
end for

Warm Starting the Refined NLP

After changing the mesh, the old solution should be mapped to the new nodes.

For new state node snews_{\mathrm{new}}:

Xguess(snew)=Xold(snew).\boldsymbol{X}_{\mathrm{guess}}(s_{\mathrm{new}}) = \boldsymbol{X}_{\mathrm{old}}(s_{\mathrm{new}}).

For new control node snews_{\mathrm{new}}:

Uguess(snew)=PLInterp(Uold,snew).\boldsymbol{U}_{\mathrm{guess}}(s_{\mathrm{new}}) = \operatorname{PLInterp} \left( \boldsymbol{U}_{\mathrm{old}}, s_{\mathrm{new}} \right).

Retain the previous values of:

Warm starts usually reduce the number of NLP iterations significantly.

Pure hh Methods

A pure hh method keeps the polynomial degree fixed:

Nk=Nfixedfor all intervals.N_k=N_{\mathrm{fixed}} \quad \text{for all intervals}.

Only interval widths are adapted.

Advantages:

Disadvantages:

Pure pp Methods

A pure pp method uses one interval or fixed interval boundaries and increases polynomial degree.

Advantages:

Disadvantages:

Why hphp Methods Are Attractive

The hphp strategy combines the strengths of both methods:

The main difficulty is classification: determining whether the interval is smooth enough for pp-refinement or should instead be divided.

NLP Size Considerations

Let

N=k=1KNk.N=\sum_{k=1}^K N_k.

For nxn_x states and nun_u controls, the principal number of nodal variables is

(N+1)nx+Nnu.(N+1)n_x+Nn_u.

Pure hh-refinement may increase KK rapidly and thereby increase NN.

Pure pp-refinement increases the density of local differentiation blocks.

A successful hphp method seeks a balance:

required accuracywith minimal N.\text{required accuracy} \quad\text{with minimal }N.

Bang–Bang Double Integrator Example

Consider

x˙1=x2,x˙2=u,\begin{aligned} \dot{x}_1&=x_2,\\ \dot{x}_2&=u, \end{aligned}

with bounded control

1u1.-1\le u\le1.

For a minimum-time transfer, the optimal control is typically bang–bang:

u(t)={+1,t<ts,1,t>ts.u(t) = \begin{cases} +1,&t<t_s,\\ -1,&t>t_s. \end{cases}

Then:

An ideal mesh places an interval boundary at tst_s. Then each state segment can be represented exactly by a low-degree polynomial.

A pure hh method may repeatedly cluster intervals around the switch. An effective hphp method should identify the localized error, place a mesh boundary near the switch, and retain low polynomial degrees on either side.

Why Over-Refinement Is Wasteful

Suppose the exact solution is piecewise quadratic. A discretization with many low-order intervals may approximate it accurately, but the NLP can be much larger than necessary.

The goal of adaptive refinement is not merely:

eϵ.e\le\epsilon.

A better goal is:

achieve eϵ using as few variables as practical.\boxed{ \text{achieve }e\le\epsilon \text{ using as few variables as practical}. }

This is especially important when using general-purpose sparse NLP solvers.

MATLAB-Like Error Estimator

function [err,delta,Y,Z] = estimateIntervalError( ...
    X,U,sOld,sNew,t0,tf,Bnew,p)

% Interpolate state polynomial to enriched grid.
Y = interpolateStateLagrange(X,sOld,sNew);

% Reconstruct control using piecewise-linear interpolation.
V = interp1(sOld(1:end-1),U,sNew(1:end-1), ...
            'linear','extrap');

% Map enriched nodes to physical time.
tNew = 0.5*(tf-t0)*sNew(1:end-1) ...
     + 0.5*(tf+t0);

% Evaluate dynamics at enriched collocation points.
Fnew = dynamics(Y(1:end-1,:),V,tNew,p);

% Integrate dynamics from the initial state.
Z = zeros(size(Y));
Z(1,:) = Y(1,:);
Z(2:end,:) = Y(1,:) ...
    + 0.5*(tf-t0)*(Bnew*Fnew);

% Relative pointwise discrepancy.
scale = 1 + abs(Y);
delta = abs(Y-Z)./scale;

% Scalar interval error.
err = max(delta,[],'all');

end

MATLAB-Like Refinement Decision

function action = chooseRefinement(delta,tol,Nk,Nmax,rhoCrit)

viol = max(delta,[],2) > tol;
rho = nnz(viol)/numel(viol);

if ~any(viol)
    action.type = 'none';
    return
end

[~,jmax] = max(max(delta,[],2));

if rho <= rhoCrit
    action.type = 'h';
    action.splitIndex = jmax;
elseif Nk < Nmax
    action.type = 'p';
    action.newDegree = Nk + 2;
else
    action.type = 'h';
    action.splitIndex = jmax;
end

end

Safeguards for Mesh Splitting

A split point should not be too close to an endpoint.

Define

scandidate=s~j(k).s_{\mathrm{candidate}} = \widetilde{s}_{j^\star}^{(k)}.

Choose a minimum fractional distance η\eta, such as

η=0.1.\eta=0.1.

Then enforce

snew[sk1+ηΔsk,skηΔsk].s_{\mathrm{new}} \in \left[ s_{k-1}+\eta\Delta s_k, s_k-\eta\Delta s_k \right].

This avoids creating extremely small intervals.

Stopping Criteria

The refinement loop may stop when:

  1. every interval satisfies the error tolerance;

  2. the maximum number of refinement iterations is reached;

  3. the maximum number of nodes is reached;

  4. the NLP fails repeatedly;

  5. the objective and state trajectories no longer change materially.

A strong convergence test includes both error and solution stabilization:

maxkekϵ,J(r)J(r1)1+J(r)ϵJ.\begin{aligned} \max_k e_k&\le\epsilon,\\ \frac{|J^{(r)}-J^{(r-1)}|} {1+|J^{(r)}|} &\le\epsilon_J. \end{aligned}

Possible Failure Modes

Inaccurate Control Reconstruction

Piecewise-linear control interpolation may be poor near rapid changes or discontinuities.

Possible remedies:

Error Cancellation

The interpolated and integrated states may agree by coincidence.

Use multiple checks, including:

Repeated Refinement without Convergence

Possible causes include:

Practical Recommendations

  1. Start with a modest number of intervals.

  2. Use low-to-moderate polynomial degree.

  3. Set a reasonable maximum degree.

  4. Normalize state errors using physical scales.

  5. Prefer hh-refinement when nonsmoothness is suspected.

  6. Prefer pp-refinement only in clearly smooth intervals.

  7. Warm start every refined solve.

  8. Verify the final solution independently.

  9. Monitor both accuracy and NLP size.

  10. Retain the full refinement history.

Refinement History Table

A useful refinement log contains:

IterationIntervalsTotal NodesMax ErrorObjectiveNLP Status
0K0K_0N0N_0e0e_0J0J_0Converged
1K1K_1N1N_1e1e_1J1J_1Converged
2K2K_2N2N_2e2e_2J2J_2Converged

This table helps identify stagnation, excessive node growth, and objective instability.

Summary

Adaptive mesh refinement converts a fixed-mesh pseudospectral method into an accuracy-controlled computational procedure.

The principal steps are:

  1. solve the NLP on a current mesh;

  2. create an enriched LGR grid;

  3. interpolate the state to that grid;

  4. reconstruct the control;

  5. integrate the dynamics on the enriched grid;

  6. compare interpolated and integrated state values;

  7. accept accurate intervals;

  8. apply hh-refinement to localized errors;

  9. apply pp-refinement to distributed smooth errors;

  10. enforce a maximum polynomial degree;

  11. interpolate the old solution onto the new mesh;

  12. repeat until convergence.

Pure hh methods are robust but may create large NLPs. Pure pp methods are efficient for smooth solutions but perform poorly near discontinuities. An hphp method seeks to combine robustness with compactness by placing resolution only where it is needed.