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.

Multiple-Interval LGR Pseudospectral Methods

Single-interval pseudospectral methods approximate the state and control over the entire time horizon using a global polynomial. These methods are highly accurate when the solution is smooth. However, many realistic optimal control problems contain:

A single global polynomial is often inadequate for such problems. The practical remedy is to divide the horizon into multiple mesh intervals and perform local collocation in each interval.

This section develops the multiple-interval Legendre–Gauss–Radau (LGR) pseudospectral method in detail. The main goals are to:

  1. review LG, LGR, and LGL collocation structures;

  2. explain why global polynomial approximations may fail;

  3. derive the multiple-interval LGR discretization;

  4. obtain the quadrature approximation of the objective;

  5. derive the local collocation equations;

  6. impose state continuity between intervals;

  7. describe the block-sparse nonlinear programming structure;

  8. explain mesh refinement and practical implementation.

Review of Gaussian Collocation Points

Three common sets of orthogonal collocation points are:

  1. Legendre–Gauss (LG);

  2. Legendre–Gauss–Radau (LGR);

  3. Legendre–Gauss–Lobatto (LGL).

All are commonly defined on the reference domain

τ[1,1].\tau\in[-1,1].

Legendre–Gauss Points

LG points lie strictly inside the interval:

1<τ1<τ2<<τN<1.-1<\tau_1<\tau_2<\cdots<\tau_N<1.

Neither endpoint is included.

For an LG transcription, the state approximation typically includes the initial point, the interior LG nodes, and a separately reconstructed terminal state. The controls are defined only at the LG collocation points.

Legendre–Gauss–Radau Points

Forward LGR points include the left endpoint but exclude the right endpoint:

τ1=1,τN<1.\tau_1=-1, \qquad \tau_N<1.

A terminal state value at

τN+1=1\tau_{N+1}=1

is added to the state approximation, but it is not a collocation point.

Thus, an LGR discretization uses:

Legendre–Gauss–Lobatto Points

LGL points include both endpoints:

τ1=1,τN=1.\tau_1=-1, \qquad \tau_N=1.

The state and control are typically represented at all LGL nodes.

Why Multiple Intervals Are Necessary

Global Polynomial Approximation

Suppose the entire time interval

t[t0,tf]t\in[t_0,t_f]

is mapped to

τ[1,1].\tau\in[-1,1].

A global polynomial approximation is then used:

x(τ)X(τ)=j=1N+1Xjj(τ),\boldsymbol{x}(\tau) \approx \boldsymbol{X}(\tau) = \sum_{j=1}^{N+1} \boldsymbol{X}_j\ell_j(\tau),

where j\ell_j are Lagrange interpolation polynomials.

This approach is spectrally accurate for analytic solutions. The error can decrease extremely rapidly with increasing polynomial degree.

Failure Near Discontinuities

If the exact control has a jump, such as

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

then a global polynomial remains smooth and cannot represent the discontinuity exactly.

Increasing the polynomial degree produces oscillations near the jump. This is the Gibbs phenomenon.

This behavior is analogous to approximating a square wave using a truncated Fourier series.

Local Polynomial Approximation

The remedy is to divide the domain into intervals:

[t0,tf]=[t0,t1][t1,t2][tK1,tK],[t_0,t_f] = [t_0,t_1]\cup[t_1,t_2]\cup\cdots\cup[t_{K-1},t_K],

where

tK=tf.t_K=t_f.

A separate polynomial is used in each interval. Then:

Comparison of LG, LGR, and LGL on Multiple Intervals

Consider two adjacent intervals:

[t0,t1],[t1,tf].[t_0,t_1], \qquad [t_1,t_f].

The state must satisfy continuity:

x(t1)=x(t1+).\boldsymbol{x}(t_1^-)=\boldsymbol{x}(t_1^+).

The control need not be continuous unless the physics or problem formulation requires it.

LG Structure

LG points exclude both interval endpoints.

Consequences:

LGR Structure

Forward LGR includes the left endpoint of each interval but excludes the right endpoint.

At the interface:

This is one reason LGR is attractive for multiple-interval transcription.

LGL Structure

LGL includes both endpoints of every interval.

At a shared interface, there are two control values:

u(tk)andu(tk+).u(t_k^-) \qquad\text{and}\qquad u(t_k^+).

These values may differ if the optimal control is discontinuous. If the user incorrectly enforces equality, a physically valid control jump may be suppressed.

Original Optimal Control Problem

Consider the Bolza problem

minx(),u(),t0,tf,pJ=Φ(x(t0),t0,x(tf),tf,p)+t0tfL(x(t),u(t),t,p)dt.\min_{\boldsymbol{x}(\cdot),\boldsymbol{u}(\cdot),t_0,t_f,\boldsymbol{p}} J = \Phi\left( \boldsymbol{x}(t_0),t_0, \boldsymbol{x}(t_f),t_f, \boldsymbol{p} \right) + \int_{t_0}^{t_f} L\left( \boldsymbol{x}(t),\boldsymbol{u}(t),t,\boldsymbol{p} \right)\,\mathrm{d} t.

The dynamics are

x˙(t)=f(x(t),u(t),t,p).\dot{\boldsymbol{x}}(t) = \boldsymbol{f}\left( \boldsymbol{x}(t),\boldsymbol{u}(t),t,\boldsymbol{p} \right).

Endpoint constraints are

ϕ(x(t0),t0,x(tf),tf,p)=0.\boldsymbol{\phi}\left( \boldsymbol{x}(t_0),t_0, \boldsymbol{x}(t_f),t_f, \boldsymbol{p} \right) = \boldsymbol{0}.

Path constraints are

cminc(x(t),u(t),t,p)cmax.\boldsymbol{c}_{\min} \le \boldsymbol{c}\left( \boldsymbol{x}(t),\boldsymbol{u}(t),t,\boldsymbol{p} \right) \le \boldsymbol{c}_{\max}.

Global Time Transformation

Map physical time t[t0,tf]t\in[t_0,t_f] to

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

using

s=2(tt0)tft01.\boxed{ s = \frac{2(t-t_0)}{t_f-t_0}-1. }

The inverse mapping is

t=tft02s+tf+t02.\boxed{ t = \frac{t_f-t_0}{2}s + \frac{t_f+t_0}{2}. }

The derivative relationships are

dsdt=2tft0,dtds=tft02.\begin{aligned} \frac{\,\mathrm{d} s}{\,\mathrm{d} t} &= \frac{2}{t_f-t_0},\\ \frac{\,\mathrm{d} t}{\,\mathrm{d} s} &= \frac{t_f-t_0}{2}. \end{aligned}

Thus,

dxds=tft02f(x,u,t,p).\frac{\,\mathrm{d}\boldsymbol{x}}{\,\mathrm{d} s} = \frac{t_f-t_0}{2} \boldsymbol{f}\left( \boldsymbol{x},\boldsymbol{u},t,\boldsymbol{p} \right).

The cost becomes

J=Φ(x(1),t0,x(1),tf,p)+tft0211L(x(s),u(s),t(s),p)ds.\begin{aligned} J &= \Phi\left( \boldsymbol{x}(-1),t_0, \boldsymbol{x}(1),t_f, \boldsymbol{p} \right) \\ &\quad+ \frac{t_f-t_0}{2} \int_{-1}^{1} L\left( \boldsymbol{x}(s),\boldsymbol{u}(s),t(s),\boldsymbol{p} \right)\,\mathrm{d} s. \end{aligned}

Mesh Definition

Divide the transformed domain into KK mesh intervals:

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

The kkth interval is

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

The quantities

s0,s1,,sKs_0,s_1,\ldots,s_K

are called mesh points.

For a fixed mesh, they are constants during the nonlinear programming solve.

The mesh width is

Δsk=sksk1.\Delta s_k=s_k-s_{k-1}.

A uniform mesh satisfies

Δsk=2K.\Delta s_k=\frac{2}{K}.

A nonuniform mesh allows smaller intervals in difficult regions.

Local Coordinate Mapping

Standard LGR points are defined on

τ[1,1].\tau\in[-1,1].

For interval Sk=[sk1,sk]\mathcal{S}_k=[s_{k-1},s_k], map τ\tau to ss using

s=sksk12τ+sk+sk12.\boxed{ s = \frac{s_k-s_{k-1}}{2}\tau + \frac{s_k+s_{k-1}}{2}. }

Equivalently,

τ=2s(sk+sk1)sksk1.\boxed{ \tau = \frac{2s-(s_k+s_{k-1})}{s_k-s_{k-1}}. }

The derivative scaling is

dsdτ=Δsk2,dτds=2Δsk.\frac{\,\mathrm{d} s}{\,\mathrm{d}\tau} = \frac{\Delta s_k}{2}, \qquad \frac{\,\mathrm{d}\tau}{\,\mathrm{d} s} = \frac{2}{\Delta s_k}.

If the standard LGR nodes are

τ1(k),,τNk(k),\tau_1^{(k)},\ldots,\tau_{N_k}^{(k)},

then the nodes in interval kk are

si(k)=Δsk2τi(k)+sk+sk12,i=1,,Nk.\boxed{ s_i^{(k)} = \frac{\Delta s_k}{2}\tau_i^{(k)} + \frac{s_k+s_{k-1}}{2}, \qquad i=1,\ldots,N_k. }

The noncollocated terminal state point is

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

Local State Approximation

In interval kk, approximate the state using

x(k)(s)X(k)(s)=j=1Nk+1Xj(k)j(k)(s),\boldsymbol{x}^{(k)}(s) \approx \boldsymbol{X}^{(k)}(s) = \sum_{j=1}^{N_k+1} \boldsymbol{X}_j^{(k)} \ell_j^{(k)}(s),

where

Xj(k)x(sj(k)).\boldsymbol{X}_j^{(k)} \approx \boldsymbol{x}\left(s_j^{(k)}\right).

The Lagrange basis polynomial is

j(k)(s)=m=1mjNk+1ssm(k)sj(k)sm(k).\ell_j^{(k)}(s) = \prod_{\substack{m=1\\m\neq j}}^{N_k+1} \frac{s-s_m^{(k)}}{s_j^{(k)}-s_m^{(k)}}.

It satisfies the cardinal property

j(k)(si(k))=δij.\ell_j^{(k)}\left(s_i^{(k)}\right) = \delta_{ij}.

Control Approximation

The control is represented only at the NkN_k LGR collocation points:

Ui(k)u(si(k)),i=1,,Nk.\boldsymbol{U}_i^{(k)} \approx \boldsymbol{u}\left(s_i^{(k)}\right), \qquad i=1,\ldots,N_k.

A polynomial control interpolant may be formed if desired:

u(k)(s)j=1NkUj(k)^j(k)(s).\boldsymbol{u}^{(k)}(s) \approx \sum_{j=1}^{N_k} \boldsymbol{U}_j^{(k)} \hat\ell_j^{(k)}(s).

However, in the NLP, only the nodal control values are usually required.

Local Differentiation Matrix

Differentiate the state approximation:

dX(k)ds=j=1Nk+1Xj(k)dj(k)ds.\frac{\,\mathrm{d}\boldsymbol{X}^{(k)}}{\,\mathrm{d} s} = \sum_{j=1}^{N_k+1} \boldsymbol{X}_j^{(k)} \frac{\,\mathrm{d}\ell_j^{(k)}}{\,\mathrm{d} s}.

Evaluate at the collocation points:

dX(k)dss=si(k)=j=1Nk+1Dij(k)Xj(k),\left. \frac{\,\mathrm{d}\boldsymbol{X}^{(k)}}{\,\mathrm{d} s} \right|_{s=s_i^{(k)}} = \sum_{j=1}^{N_k+1} D_{ij}^{(k)} \boldsymbol{X}_j^{(k)},

where

Dij(k)=dj(k)dss=si(k).\boxed{ D_{ij}^{(k)} = \left. \frac{\,\mathrm{d}\ell_j^{(k)}}{\,\mathrm{d} s} \right|_{s=s_i^{(k)}}. }

The local differentiation matrix has dimensions

D(k)RNk×(Nk+1).\boldsymbol{D}^{(k)} \in \mathbb{R}^{N_k\times(N_k+1)}.

Scaling from the Standard LGR Matrix

Let

D^(k)\hat{\boldsymbol{D}}^{(k)}

be the LGR differentiation matrix on τ[1,1]\tau\in[-1,1].

Because

dds=2Δskddτ,\frac{\,\mathrm{d}}{\,\mathrm{d} s} = \frac{2}{\Delta s_k} \frac{\,\mathrm{d}}{\,\mathrm{d}\tau},

the interval differentiation matrix is

D(k)=2ΔskD^(k).\boxed{ \boldsymbol{D}^{(k)} = \frac{2}{\Delta s_k} \hat{\boldsymbol{D}}^{(k)}. }

Collocation Equations

The transformed dynamics are

dxds=tft02f(x,u,t,p).\frac{\,\mathrm{d}\boldsymbol{x}}{\,\mathrm{d} s} = \frac{t_f-t_0}{2} \boldsymbol{f}\left( \boldsymbol{x},\boldsymbol{u},t,\boldsymbol{p} \right).

At node ii of interval kk:

j=1Nk+1Dij(k)Xj(k)=tft02f(Xi(k),Ui(k),ti(k),p).\begin{aligned} \sum_{j=1}^{N_k+1} D_{ij}^{(k)} \boldsymbol{X}_j^{(k)} &= \frac{t_f-t_0}{2} \boldsymbol{f}\left( \boldsymbol{X}_i^{(k)}, \boldsymbol{U}_i^{(k)}, t_i^{(k)}, \boldsymbol{p} \right). \end{aligned}

Thus,

j=1Nk+1Dij(k)Xj(k)tft02Fi(k)=0.\boxed{ \sum_{j=1}^{N_k+1} D_{ij}^{(k)} \boldsymbol{X}_j^{(k)} - \frac{t_f-t_0}{2} \boldsymbol{F}_i^{(k)} = \boldsymbol{0}. }

These equations hold for

i=1,,Nk,k=1,,K.i=1,\ldots,N_k, \qquad k=1,\ldots,K.

Physical Time at Each Node

The global transformed coordinate si(k)s_i^{(k)} maps to physical time through

ti(k)=tft02si(k)+tf+t02.\boxed{ t_i^{(k)} = \frac{t_f-t_0}{2}s_i^{(k)} + \frac{t_f+t_0}{2}. }

If t0t_0 or tft_f is free, these nodal times depend on the NLP decision variables.

Quadrature over Multiple Intervals

For an arbitrary integrand G(s)G(s):

11G(s)ds=k=1Ksk1skG(s)ds.\int_{-1}^{1}G(s)\,\mathrm{d} s = \sum_{k=1}^{K} \int_{s_{k-1}}^{s_k} G(s)\,\mathrm{d} s.

In interval kk, LGR quadrature gives

sk1skG(s)dsi=1Nkwi(k)G(si(k)).\int_{s_{k-1}}^{s_k} G(s)\,\mathrm{d} s \approx \sum_{i=1}^{N_k} w_i^{(k)} G\left(s_i^{(k)}\right).

The interval weights scale from the standard LGR weights:

wi(k)=Δsk2w^i(k).\boxed{ w_i^{(k)} = \frac{\Delta s_k}{2} \hat w_i^{(k)}. }

Therefore,

11G(s)dsk=1Ki=1Nkwi(k)Gi(k).\boxed{ \int_{-1}^{1}G(s)\,\mathrm{d} s \approx \sum_{k=1}^{K} \sum_{i=1}^{N_k} w_i^{(k)} G_i^{(k)}. }

Discrete Cost Functional

The objective becomes

JJh=Φ(X1(1),t0,XNK+1(K),tf,p)+tft02k=1Ki=1Nkwi(k)L(Xi(k),Ui(k),ti(k),p).\begin{aligned} J \approx J_h &= \Phi\left( \boldsymbol{X}_1^{(1)},t_0, \boldsymbol{X}_{N_K+1}^{(K)},t_f, \boldsymbol{p} \right) \\ &\quad+ \frac{t_f-t_0}{2} \sum_{k=1}^{K} \sum_{i=1}^{N_k} w_i^{(k)} L\left( \boldsymbol{X}_i^{(k)}, \boldsymbol{U}_i^{(k)}, t_i^{(k)}, \boldsymbol{p} \right). \end{aligned}

Hence,

Jh=Φh+tft02k=1Ki=1Nkwi(k)Li(k).\boxed{ J_h = \Phi_h + \frac{t_f-t_0}{2} \sum_{k=1}^{K} \sum_{i=1}^{N_k} w_i^{(k)}L_i^{(k)}. }

State Continuity between Mesh Intervals

For a continuous state trajectory:

XNk+1(k)=X1(k+1),k=1,,K1.\boxed{ \boldsymbol{X}_{N_k+1}^{(k)} = \boldsymbol{X}_1^{(k+1)}, \qquad k=1,\ldots,K-1. }

There are two implementation choices.

Explicit Continuity Constraints

Keep both interface state variables and impose

XNk+1(k)X1(k+1)=0.\boldsymbol{X}_{N_k+1}^{(k)} - \boldsymbol{X}_1^{(k+1)} = \boldsymbol{0}.

Shared State Variables

Use the same NLP variable for both sides:

XNk+1(k)X1(k+1).\boldsymbol{X}_{N_k+1}^{(k)} \equiv \boldsymbol{X}_1^{(k+1)}.

This eliminates explicit continuity constraints and reduces the number of decision variables.

Control Behavior at Interfaces

Forward LGR has no control at the terminal point of interval kk, but it does have a control at the initial point of interval k+1k+1.

Thus, there is one interface control value:

U1(k+1).\boldsymbol{U}_1^{(k+1)}.

This is especially useful when the control is discontinuous. The method does not force left and right control limits to be equal.

Endpoint Constraints

The discrete endpoint constraints are

ϕ(X1(1),t0,XNK+1(K),tf,p)=0.\boxed{ \boldsymbol{\phi}\left( \boldsymbol{X}_1^{(1)},t_0, \boldsymbol{X}_{N_K+1}^{(K)},t_f, \boldsymbol{p} \right) = \boldsymbol{0}. }

The initial state comes from the first node of the first interval. The final state comes from the additional terminal state point of the last interval.

Path Constraints

At every collocation point:

cminc(Xi(k),Ui(k),ti(k),p)cmax.\boxed{ \boldsymbol{c}_{\min} \le \boldsymbol{c}\left( \boldsymbol{X}_i^{(k)}, \boldsymbol{U}_i^{(k)}, t_i^{(k)}, \boldsymbol{p} \right) \le \boldsymbol{c}_{\max}. }

These constraints are imposed for

i=1,,Nk,k=1,,K.i=1,\ldots,N_k, \qquad k=1,\ldots,K.

Because constraints are enforced only at collocation nodes, the continuous-time solution should be checked between nodes after solving.

Discrete Nonlinear Programming Problem

The NLP decision vector contains:

A generic decision vector is

Z=[vec(X),vec(U),t0,tf,p]T.\boldsymbol{Z} = \left[ \operatorname{vec}(\boldsymbol{X}), \operatorname{vec}(\boldsymbol{U}), t_0,t_f,\boldsymbol{p} \right]^{\mathsf{T}}.

The NLP is

minZJh(Z)\min_{\boldsymbol{Z}} J_h(\boldsymbol{Z})

subject to

Δ(k)(Z)=0,k=1,,K,ϕh(Z)=0,cminch(Z)cmax,ZminZZmax.\begin{aligned} \boldsymbol{\Delta}^{(k)}(\boldsymbol{Z})&=\boldsymbol{0}, &&k=1,\ldots,K,\\ \boldsymbol{\phi}_h(\boldsymbol{Z})&=\boldsymbol{0},\\ \boldsymbol{c}_{\min} &\le \boldsymbol{c}_h(\boldsymbol{Z}) \le \boldsymbol{c}_{\max},\\ \boldsymbol{Z}_{\min} &\le \boldsymbol{Z} \le \boldsymbol{Z}_{\max}. \end{aligned}

Global Matrix Structure

Let

Ntot=k=1KNk.N_{\mathrm{tot}} = \sum_{k=1}^{K}N_k.

The global differentiation matrix is block diagonal:

Dglobal=blkdiag(D(1),D(2),,D(K)).\boxed{ \boldsymbol{D}_{\mathrm{global}} = \operatorname{blkdiag} \left( \boldsymbol{D}^{(1)}, \boldsymbol{D}^{(2)}, \ldots, \boldsymbol{D}^{(K)} \right). }

Unlike a single global pseudospectral differentiation matrix, this matrix is sparse.

The global collocation equations can be written schematically as

DglobalXtft02F(X,U)=0.\boldsymbol{D}_{\mathrm{global}}\boldsymbol{X} - \frac{t_f-t_0}{2}\boldsymbol{F}(\boldsymbol{X},\boldsymbol{U}) = \boldsymbol{0}.

Sparsity Pattern

Each local collocation defect depends only on:

Therefore, the Jacobian has a block-banded structure.

This sparsity is one of the principal computational advantages of multiple-interval methods.

Number of Decision Variables

Suppose:

Without shared interface states, the state decision variables are

nxk=1K(Nk+1).n_x\sum_{k=1}^{K}(N_k+1).

The controls contribute

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

With shared interface states, the number of unique state nodes is

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

Thus,

nstate=nx(1+k=1KNk).\boxed{ n_{\mathrm{state}} = n_x \left( 1+\sum_{k=1}^{K}N_k \right). }

Defect Constraints

Define the defect at node ii of interval kk:

Δi(k)=j=1Nk+1Dij(k)Xj(k)tft02Fi(k).\boldsymbol{\Delta}_i^{(k)} = \sum_{j=1}^{N_k+1} D_{ij}^{(k)} \boldsymbol{X}_j^{(k)} - \frac{t_f-t_0}{2} \boldsymbol{F}_i^{(k)}.

The collocation conditions are

Δi(k)=0.\boldsymbol{\Delta}_i^{(k)}=\boldsymbol{0}.

For all intervals, the number of defect equations is

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

Integral Consistency Check

LGR quadrature also gives an integral form of the state update:

XNk+1(k)X1(k)tft02i=1Nkwi(k)Fi(k).\boldsymbol{X}_{N_k+1}^{(k)} - \boldsymbol{X}_1^{(k)} \approx \frac{t_f-t_0}{2} \sum_{i=1}^{N_k} w_i^{(k)} \boldsymbol{F}_i^{(k)}.

This relation can be used as a consistency check.

Mesh Refinement

The mesh should adapt to the solution.

Two basic refinement operations are:

hh-Refinement

Divide an interval into smaller intervals.

This is effective near:

pp-Refinement

Increase polynomial degree NkN_k within an interval.

This is effective when the solution is smooth and the approximation error is distributed across the interval.

hphp-Refinement

Combine interval subdivision and degree elevation.

Modern pseudospectral optimal control software often uses adaptive hphp refinement.

Error Estimation

A common error estimator compares:

  1. the polynomial state approximation;

  2. a state reconstructed by integrating the dynamics using the approximate control.

Let

Xpoly(k)(s)\boldsymbol{X}_{\mathrm{poly}}^{(k)}(s)

be the collocation polynomial and

Xint(k)(s)\boldsymbol{X}_{\mathrm{int}}^{(k)}(s)

be an integrated state reconstruction.

Define

ek=maxsSkXpoly(k)(s)Xint(k)(s).e_k = \max_{s\in\mathcal{S}_k} \left\| \boldsymbol{X}_{\mathrm{poly}}^{(k)}(s) - \boldsymbol{X}_{\mathrm{int}}^{(k)}(s) \right\|_{\infty}.

If

ek>ϵ,e_k>\epsilon,

the interval is refined.

Detecting Nonsmoothness

A smooth solution is typically characterized by rapidly decaying polynomial coefficients.

Suppose the local state approximation is written in an orthogonal basis:

X(k)(τ)=j=0Nkaj(k)Pj(τ).X^{(k)}(\tau) = \sum_{j=0}^{N_k} a_j^{(k)}P_j(\tau).

If

aj(k)|a_j^{(k)}|

decreases rapidly with jj, pp-refinement is appropriate.

If the coefficients decay slowly or stagnate, the interval may contain a nonsmooth feature and should be subdivided.

Switch Detection

For bang–bang problems, switch locations can be inferred from:

Placing a mesh boundary near the switch dramatically improves accuracy.

Algorithmic Workflow

Algorithm: Multiple-Interval LGR Pseudospectral Method

Choose an initial mesh \{s_k\}_{k=0}^{K}.
Choose polynomial degrees N_k.
Compute standard LGR nodes and weights.
Map nodes and weights into each mesh interval.
Form local differentiation matrices.
Construct the NLP decision vector.
Impose collocation defects.
Impose state continuity.
Impose endpoint and path constraints.
Solve the NLP.
Estimate interval-wise discretization error.
if all interval errors are below tolerance:
    Accept the solution.
else:
    Apply h-, p-, or hp-refinement.
    Interpolate the previous solution onto the new mesh.
    Resolve the NLP.
end if

Practical Implementation Details

Initial Guess

The initial guess may be generated using:

Scaling

States, controls, constraints, and time should be scaled so that typical values are near unity.

For example:

xˉi=xixi,refsxi.\bar x_i = \frac{x_i-x_{i,\mathrm{ref}}}{s_{x_i}}.

Poor scaling can cause:

Derivative Computation

Derivatives may be obtained using:

Automatic differentiation is usually preferred for large sparse problems.

MATLAB-Like Assembly Skeleton

function data = buildMultipleIntervalLGR(mesh, degree)

K = length(mesh)-1;

Dblocks = cell(K,1);
nodes   = cell(K,1);
weights = cell(K,1);

for k = 1:K

    Nk = degree(k);

    % Standard forward LGR data on [-1,1]
    [tau, wHat, DHat] = lgrData(Nk);

    sL = mesh(k);
    sR = mesh(k+1);
    ds = sR-sL;

    % Map collocation nodes to current mesh interval
    s = 0.5*ds*tau + 0.5*(sR+sL);

    % Scale quadrature weights and differentiation matrix
    w = 0.5*ds*wHat;
    D = (2/ds)*DHat;

    nodes{k}   = s;
    weights{k} = w;
    Dblocks{k} = D;
end

data.nodes   = nodes;
data.weights = weights;
data.D       = blkdiag(Dblocks{:});

end

Defect Assembly Example

for k = 1:K

    Nk = degree(k);

    Xk = X{k};        % (Nk+1)-by-nx
    Uk = U{k};        % Nk-by-nu
    tk = timeMap(nodes{k}, t0, tf);

    Fk = dynamics(Xk(1:Nk,:), Uk, tk, p);

    defect{k} = D{k}*Xk ...
              - 0.5*(tf-t0)*Fk;
end

Advantages of Multiple-Interval LGR

  1. Handles nonsmooth solutions more effectively than a global polynomial.

  2. Preserves high-order accuracy within smooth intervals.

  3. Produces sparse Jacobian and Hessian structures.

  4. Avoids double-valued interface controls.

  5. Supports adaptive mesh refinement.

  6. Provides a natural framework for large-scale trajectory optimization.

  7. Works well with sparse nonlinear programming solvers.

Limitations

  1. Requires mesh-selection and error-estimation logic.

  2. Can generate large NLPs.

  3. Path constraints are enforced only at nodes unless additional checks are used.

  4. Poorly selected meshes may miss short-duration events.

  5. Very low-order intervals may reduce accuracy.

  6. Very high-order intervals may become ill-conditioned.

  7. Discontinuous states require multiphase formulations rather than simple continuity.

Multiple Phases versus Multiple Mesh Intervals

Multiple mesh intervals are used when the dynamics and state remain continuous.

Multiple phases are used when there are:

For multiple phases, event constraints connect the terminal state of one phase to the initial state of another:

ψ(xf(q),x0(q+1),p)=0.\boldsymbol{\psi}\left( \boldsymbol{x}_f^{(q)}, \boldsymbol{x}_0^{(q+1)}, \boldsymbol{p} \right) = \boldsymbol{0}.

Verification and Validation

A converged NLP solution is not automatically a trustworthy continuous-time solution.

Verification should include:

  1. mesh refinement until the objective stabilizes;

  2. independent integration of the dynamics;

  3. endpoint residual checks;

  4. path-constraint checking between nodes;

  5. comparison across mesh strategies;

  6. sensitivity to tolerances;

  7. examination of control oscillations;

  8. Hamiltonian or costate checks when available.

Common Mistakes

Summary

The multiple-interval LGR method extends single-interval pseudospectral collocation to realistic optimal control problems.

The principal ideas are:

  1. transform the physical time domain to a fixed global domain;

  2. divide the transformed domain into mesh intervals;

  3. map standard LGR points into each interval;

  4. approximate the state locally using Lagrange polynomials;

  5. enforce the dynamics at local LGR points;

  6. approximate the cost using composite LGR quadrature;

  7. enforce state continuity between intervals;

  8. exploit the resulting block-sparse NLP structure;

  9. refine the mesh until the discretization error is acceptable.

This method combines spectral accuracy in smooth regions with the flexibility required for nonsmooth controls and localized trajectory features.

Connection. Local interval equations become a useful computational method only after their states, controls, differentiation blocks, and continuity conditions are assembled globally.