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.

State Inequality Path Constraints and Direct Collocation

This section continues the treatment of path constraints by focusing on state inequality path constraints and their numerical implementation. These constraints are challenging because their activity is not generally known in advance. A state inequality constraint may be inactive over part of the trajectory, active over one or more constrained arcs, and inactive again later.

The continuous-time constraint is written as

c(x(t),t)0.\boxed{ c(\boldsymbol{x}(t),t)\leq 0. }

For clarity, most of the derivations in this section use a scalar constraint and a scalar control. The same ideas extend to vector-valued constraints and multiple controls.

Why State Inequality Constraints Are Difficult

A priori, one generally does not know whether

c(x(t),t)0c(\boldsymbol{x}(t),t)\leq 0

will be active at the optimal solution.

If

c(x(t),t)<0c(\boldsymbol{x}^*(t),t)<0

for all tt, then the constraint is inactive and has no effect on the optimal trajectory. If it becomes active, then there exists an interval over which

c(x(t),t)=0.c(\boldsymbol{x}^*(t),t)=0.

The times at which the constraint becomes active and inactive are generally unknown. These unknown junction times create much of the difficulty in indirect formulations.

Assumed Constrained Arc

Suppose that there exists a single interval

[t1,t2][t0,tf]\left[t_1,t_2]\subset[t_0,t_f\right]

such that

c(x(t),t)=0,t[t1,t2].\boxed{ c(\boldsymbol{x}(t),t)=0, \qquad t\in[t_1,t_2]. }

The interval [t1,t2][t_1,t_2] is called a constrained arc. The times t1t_1 and t2t_2 are the entry and exit times.

A qualitative representation is shown below.

A state inequality constraint that is active on one interval.

Figure 1:A state inequality constraint that is active on one interval.

This structure is an assumption. The true solution may have no constrained arc, one constrained arc, or several constrained arcs.

Constraint Derivatives

On the constrained arc,

c(x(t),t)=0.c(\boldsymbol{x}(t),t)=0.

Therefore, all total time derivatives must also vanish:

c(x(t),t)=0,dcdt=0,d2cdt2=0,dqcdtq=0.\begin{aligned} c(\boldsymbol{x}(t),t)&=0,\\ \frac{\,\mathrm{d} c}{\,\mathrm{d} t}&=0,\\ \frac{\,\mathrm{d}^2 c}{\,\mathrm{d} t^2}&=0,\\ &\vdots\\ \frac{\,\mathrm{d}^q c}{\,\mathrm{d} t^q}&=0. \end{aligned}

The total derivative is

dcdt=cxx˙+ct.\frac{\,\mathrm{d} c}{\,\mathrm{d} t} = \frac{\partial c}{\partial \boldsymbol{x}}\dot{\boldsymbol{x}} + \frac{\partial c}{\partial t}.

Substituting the dynamics

x˙=f(x,u,t)\dot{\boldsymbol{x}}=\boldsymbol{f}(\boldsymbol{x},\boldsymbol{u},t)

gives

dcdt=cxf(x,u,t)+ct.\frac{\,\mathrm{d} c}{\,\mathrm{d} t} = \frac{\partial c}{\partial \boldsymbol{x}} \boldsymbol{f}(\boldsymbol{x},\boldsymbol{u},t) + \frac{\partial c}{\partial t}.

Order of a State Constraint

Assume that the control does not appear explicitly in

c,c˙,,c(q1),c,\dot c,\ldots,c^{(q-1)},

but appears explicitly in

c(q).c^{(q)}.

Then the state constraint is said to have order qq.

Thus,

c(0)(x,t)=0,c(1)(x,t)=0,c(q1)(x,t)=0,c(q)(x,u,t)=0.\begin{aligned} c^{(0)}(\boldsymbol{x},t)&=0,\\ c^{(1)}(\boldsymbol{x},t)&=0,\\ &\vdots\\ c^{(q-1)}(\boldsymbol{x},t)&=0,\\ c^{(q)}(\boldsymbol{x},\boldsymbol{u},t)&=0. \end{aligned}

The highest derivative provides a control-dependent equality that can be used to determine the boundary control.

Tangency Conditions at Entry

At the entry time t1t_1, the following conditions must hold:

c(j)(x(t1),t1)=0,j=0,,q1.\boxed{ c^{(j)}(\boldsymbol{x}(t_1),t_1)=0, \qquad j=0,\ldots,q-1. }

These are the tangency conditions.

For a first-order constraint,

c(x(t1),t1)=0.c(\boldsymbol{x}(t_1),t_1)=0.

For a second-order constraint,

c(x(t1),t1)=0,c˙(x(t1),t1)=0.\begin{aligned} c(\boldsymbol{x}(t_1),t_1)&=0,\\ \dot c(\boldsymbol{x}(t_1),t_1)&=0. \end{aligned}

For a third-order constraint,

c(x(t1),t1)=0,c˙(x(t1),t1)=0,c¨(x(t1),t1)=0.\begin{aligned} c(\boldsymbol{x}(t_1),t_1)&=0,\\ \dot c(\boldsymbol{x}(t_1),t_1)&=0,\\ \ddot c(\boldsymbol{x}(t_1),t_1)&=0. \end{aligned}

These conditions ensure that the trajectory joins the constraint boundary smoothly rather than crossing into the infeasible region.

Interior-Point Interpretation

The tangency conditions act as interior-point constraints:

ψ(x(t1),t1)=0,\boldsymbol{\psi}(\boldsymbol{x}(t_1),t_1)=\boldsymbol{0},

where

ψ=[cc˙c(q1)].\boldsymbol{\psi} = \begin{bmatrix} c\\ \dot c\\ \vdots\\ c^{(q-1)} \end{bmatrix}.

Therefore, the constrained problem can be interpreted as a multiphase optimal control problem with an interior junction at t1t_1.

The trajectory must satisfy:

  1. unconstrained dynamics on [t0,t1)[t_0,t_1);

  2. tangency conditions at t1t_1;

  3. constrained dynamics on [t1,t2][t_1,t_2];

  4. exit or junction conditions at t2t_2;

  5. unconstrained dynamics on (t2,tf](t_2,t_f].

Replacing the Inequality on the Active Arc

On the active arc, the original inequality

c(x(t),t)0c(\boldsymbol{x}(t),t)\leq 0

is replaced by the equality

c(q)(x(t),u(t),t)=0,t[t1,t2].\boxed{ c^{(q)}(\boldsymbol{x}(t),\boldsymbol{u}(t),t)=0, \qquad t\in[t_1,t_2]. }

The lower-order conditions remain satisfied as a consequence of the tangency conditions and the constrained dynamics.

In favorable cases, one can solve

c(q)(x,u,t)=0c^{(q)}(\boldsymbol{x},\boldsymbol{u},t)=0

for the boundary control:

u=uboundary(x,t).\boxed{ \boldsymbol{u} = \boldsymbol{u}_{\mathrm{boundary}}(\boldsymbol{x},t). }

Single and Multiple Constrained Arcs

The assumption of one active interval may be incorrect. The unconstrained solution may suggest several separate violations.

An unconstrained solution may violate a state inequality constraint over multiple intervals.

Figure 2:An unconstrained solution may violate a state inequality constraint over multiple intervals.

However, two unconstrained violations do not guarantee that the constrained optimal solution has two constrained arcs. Enforcing one arc may alter the trajectory enough to eliminate another violation.

Therefore, the active-set structure must be tested rather than blindly assumed.

Solve the Unconstrained Problem First

A practical indirect-method strategy is:

  1. Solve the problem without the state inequality constraint.

  2. Evaluate c(x(t),t)c(\boldsymbol{x}(t),t) along the unconstrained trajectory.

  3. If c<0c<0 everywhere, the inequality is inactive.

  4. If c>0c>0 somewhere, identify approximate violation intervals.

  5. Use these intervals to initialize candidate entry and exit times.

  6. Solve constrained formulations with one or more candidate arcs.

  7. Verify complementarity, tangency, and feasibility.

This strategy provides structural information before the difficult constrained boundary-value problem is attempted.

Risk of Assuming an Active Constraint Incorrectly

Suppose one assumes an active arc and imposes tangency and boundary-control conditions, even though the true optimum never activates the constraint.

The resulting solution is generally feasible for a more restrictive problem but is not the optimum of the original inequality-constrained problem. It is therefore suboptimal.

This illustrates a key principle:

Difficulty of Indirect Shooting

Without path constraints, an indirect method typically solves a two-point boundary-value problem consisting of:

A state inequality path constraint introduces:

The problem becomes a multiphase differential-algebraic boundary-value problem.

Transition to Direct Collocation

Direct collocation avoids explicit derivation of the constrained-arc structure in the problem formulation.

Consider the continuous optimal control problem

minx(),u(),t0,tfJ=Φ(x(t0),t0,x(tf),tf)+t0tfL(x,u,t)dt,x˙=f(x,u,t),ϕ(x(t0),t0,x(tf),tf)=0,cminc(x,u,t)cmax.\begin{aligned} \min_{\boldsymbol{x}(\cdot),\boldsymbol{u}(\cdot),t_0,t_f} \quad J &= \Phi(\boldsymbol{x}(t_0),t_0,\boldsymbol{x}(t_f),t_f) + \int_{t_0}^{t_f} L(\boldsymbol{x},\boldsymbol{u},t)\,\mathrm{d} t, \\ \dot{\boldsymbol{x}} &= \boldsymbol{f}(\boldsymbol{x},\boldsymbol{u},t), \\ \boldsymbol{\phi}(\boldsymbol{x}(t_0),t_0,\boldsymbol{x}(t_f),t_f) &= \boldsymbol{0}, \\ \boldsymbol{c}_{\min} &\leq \boldsymbol{c}(\boldsymbol{x},\boldsymbol{u},t) \leq \boldsymbol{c}_{\max}. \end{aligned}

LGR/Radau Discretization

Using an NN-point Legendre–Gauss–Radau discretization, the cost is approximated by

JN=Φ(X1,t0,XN+1,tf)+tft02i=1NwiL(Xi,Ui,ti).\begin{aligned} J_N ={}& \Phi(\boldsymbol{X}_1,t_0,\boldsymbol{X}_{N+1},t_f) \nonumber\\ &+ \frac{t_f-t_0}{2} \sum_{i=1}^{N} w_i L(\boldsymbol{X}_i,\boldsymbol{U}_i,t_i). \end{aligned}

The defect constraints are

DXtft02F=0.\boxed{ \boldsymbol{D}\boldsymbol{X} - \frac{t_f-t_0}{2}\boldsymbol{F} = \boldsymbol{0}. }

More explicitly,

j=1N+1DijXjtft02f(Xi,Ui,ti)=0,i=1,,N.\sum_{j=1}^{N+1} D_{ij}\boldsymbol{X}_j - \frac{t_f-t_0}{2} \boldsymbol{f}(\boldsymbol{X}_i,\boldsymbol{U}_i,t_i) = \boldsymbol{0}, \qquad i=1,\ldots,N.

Endpoint constraints become

ϕ(X1,t0,XN+1,tf)=0.\boldsymbol{\phi}(\boldsymbol{X}_1,t_0,\boldsymbol{X}_{N+1},t_f)=\boldsymbol{0}.

Discrete Path Constraints

The continuous path constraint

cminc(x(t),u(t),t)cmax\boldsymbol{c}_{\min} \leq \boldsymbol{c}(\boldsymbol{x}(t),\boldsymbol{u}(t),t) \leq \boldsymbol{c}_{\max}

is enforced at the Radau points:

cminc(Xi,Ui,ti)cmax,i=1,,N.\boxed{ \boldsymbol{c}_{\min} \leq \boldsymbol{c}(\boldsymbol{X}_i,\boldsymbol{U}_i,t_i) \leq \boldsymbol{c}_{\max}, \qquad i=1,\ldots,N. }

Equivalently,

[c(X1,U1,t1)c(X2,U2,t2)c(XN,UN,tN)][cmin,cmax].\begin{bmatrix} \boldsymbol{c}(\boldsymbol{X}_1,\boldsymbol{U}_1,t_1)\\ \boldsymbol{c}(\boldsymbol{X}_2,\boldsymbol{U}_2,t_2)\\ \vdots\\ \boldsymbol{c}(\boldsymbol{X}_N,\boldsymbol{U}_N,t_N) \end{bmatrix} \in [\boldsymbol{c}_{\min},\boldsymbol{c}_{\max}].

No continuous-time path multiplier is explicitly introduced into the NLP formulation.

Why No Explicit Multiplier Is Added

The nonlinear program is written directly in terms of decision variables and constraints. The NLP solver introduces and estimates its own Lagrange multipliers internally as part of the Karush–Kuhn–Tucker conditions.

Therefore, the user provides:

The solver determines which inequality constraints are active at the discrete optimum.

Major Advantage of Direct Collocation

Direct collocation does not require the user to specify:

The NLP solver identifies the discrete active set.

What the NLP Solver Actually Returns

The NLP solver returns a finite-dimensional decision vector,

z=[vec(X)vec(U)t0tf],\boldsymbol{z} = \begin{bmatrix} \operatorname{vec}(\boldsymbol{X})\\ \operatorname{vec}(\boldsymbol{U})\\ t_0\\ t_f \end{bmatrix},

not a continuous trajectory.

The quantities Xi\boldsymbol{X}_i and Ui\boldsymbol{U}_i are discrete samples. A reconstructed state and control must be produced by interpolation.

Therefore, satisfaction of a path constraint at the collocation points does not automatically imply satisfaction between those points.

Discrete Activity Does Not Prove a Continuous Constrained Arc

Suppose the NLP solution satisfies

c(Xi,Ui,ti)=0c(\boldsymbol{X}_i,\boldsymbol{U}_i,t_i)=0

at several neighboring Radau points.

This means only that those discrete constraints are active. It does not prove that

c(x(t),u(t),t)=0c(\boldsymbol{x}(t),\boldsymbol{u}(t),t)=0

for every tt between them.

The reconstructed trajectory must be checked independently.

State Interpolation

For LGR collocation, the state approximation is uniquely defined by a Lagrange polynomial:

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

Thus, the state can be evaluated at dense points between the collocation nodes.

The corresponding physical time is

t(τ)=tft02τ+tf+t02.t(\tau) = \frac{t_f-t_0}{2}\tau + \frac{t_f+t_0}{2}.

Control Interpolation

The control is represented only by its values at the collocation points:

U1,,UN.\boldsymbol{U}_1,\ldots,\boldsymbol{U}_N.

Unlike the state, there is no unique control interpolation implied by the collocation derivation.

Possible choices include:

Different interpolation choices may produce different between-node behavior.

Hidden Constraint Violations

Even if

c(Xi,Ui,ti)0c(\boldsymbol{X}_i,\boldsymbol{U}_i,t_i)\leq 0

at every collocation point, an interpolated path may violate the constraint between nodes.

Discrete feasibility does not guarantee continuous feasibility.

Figure 3:Discrete feasibility does not guarantee continuous feasibility.

This is a discretization error, not necessarily an NLP error.

Dense-Grid Verification

After solving the NLP:

  1. reconstruct the state on a dense grid;

  2. choose and document a control interpolation;

  3. evaluate the path constraint on the dense grid;

  4. compute the maximum violation;

  5. compare it with a prescribed feasibility tolerance.

Define

v(t)=max{cminc(x(t),u(t),t),  c(x(t),u(t),t)cmax,  0}.v(t) = \max \left\{ \boldsymbol{c}_{\min}-\boldsymbol{c}(\boldsymbol{x}(t),\boldsymbol{u}(t),t), \; \boldsymbol{c}(\boldsymbol{x}(t),\boldsymbol{u}(t),t)-\boldsymbol{c}_{\max}, \; \boldsymbol{0} \right\}.

A useful scalar metric is

vmax=maxt[t0,tf]v(t).\boxed{ v_{\max} = \max_{t\in[t_0,t_f]} \|v(t)\|_{\infty}. }

Mesh Refinement

If the reconstructed solution violates the path constraint beyond tolerance, increase the mesh resolution.

Refinement may involve:

The process is repeated until the continuous residuals and violations are acceptably small.

Theory-Based Verification

Direct collocation simplifies the formulation, but theory remains essential for verifying the result.

For an apparently active state constraint, one should check:

  1. whether the constraint is approximately zero on an interval;

  2. whether the lower-order tangency conditions hold near entry;

  3. whether the boundary control relation is approximately satisfied;

  4. whether the constraint multiplier has the correct activity pattern;

  5. whether the solution converges under mesh refinement.

NLP Multipliers and Continuous Path Multipliers

The NLP solver returns multipliers associated with the discrete path constraints. These can be interpreted as approximations of the continuous path multiplier after appropriate scaling.

On inactive points, the discrete multiplier should be near zero. On active points, it may be nonzero and should satisfy discrete complementarity.

For an upper-bound constraint

ci(z)0,c_i(\boldsymbol z)\leq 0,

the discrete KKT conditions include

ci(z)0,μi0,μici(z)=0.\begin{aligned} c_i(\boldsymbol z^*)&\leq 0,\\ \mu_i^*&\geq 0,\\ \mu_i^*c_i(\boldsymbol z^*)&=0. \end{aligned}

The sign depends on the NLP convention.

Equality Versus Inequality Constraints in an NLP

Defect constraints are equalities:

DXtft02F=0.\boldsymbol{D}\boldsymbol{X}-\frac{t_f-t_0}{2}\boldsymbol{F}=\boldsymbol{0}.

The NLP solver knows these must be active.

Path inequalities may be active or inactive:

cmincicmax.\boldsymbol{c}_{\min} \leq \boldsymbol{c}_i \leq \boldsymbol{c}_{\max}.

The solver must determine which bounds bind at the solution.

This active-set determination may be performed through active-set methods, sequential quadratic programming, or interior-point methods.

Implementation Pattern

A typical MATLAB nonlinear-constraint function may be written as:

function [c, ceq] = constraints(z, data)

    [X, U, t0, tf] = unpackDecisionVector(z, data);

    t = ((tf - t0)/2) * data.tau + (tf + t0)/2;

    F = dynamics(X(:,1:data.N), U, t, data);

    defects = data.D * X.' ...
            - ((tf - t0)/2) * F.';

    boundary = endpointConstraints( ...
        X(:,1), t0, X(:,end), tf, data);

    path = pathFunctions( ...
        X(:,1:data.N), U, t, data);

    % Example upper-bound form: path <= pathMax
    cUpper = path - data.pathMax;

    % Example lower-bound form: path >= pathMin
    cLower = data.pathMin - path;

    c = [cUpper(:); cLower(:)];
    ceq = [defects(:); boundary(:)];
end

The path constraints are evaluated only at the collocation points inside the NLP. Dense-grid checking is performed after optimization.

  1. Formulate the continuous optimal control problem.

  2. Identify all path constraints and their physical meaning.

  3. Solve an unconstrained or relaxed problem first when useful.

  4. Discretize the states and controls using collocation.

  5. Add the path inequalities at all collocation points.

  6. Solve the NLP using a scaled initial guess.

  7. Inspect the solver status and KKT information.

  8. Reconstruct state and control trajectories.

  9. Evaluate dynamics residuals on a dense grid.

  10. Evaluate path constraints on a dense grid.

  11. Inspect active intervals and approximate tangency.

  12. Refine the mesh and resolve.

  13. Compare successive solutions and objective values.

Theory and Computation Must Work Together

A numerical solver does not understand optimal-control theory. It solves the finite-dimensional equations supplied by the user.

Therefore, obtaining a solver message such as “optimal solution found” is not enough. One must verify:

Common Failure Modes

Incorrect Path Function

A sign error in the path constraint may reverse the feasible region.

Constraint Enforced at the Wrong Nodes

The control and dynamics may be defined only at the NN Radau points, while the state includes an additional terminal point. Indexing errors are common.

Assuming Discrete Feasibility Implies Continuous Feasibility

Interpolation can violate the constraint between nodes.

Inadequate Mesh Resolution

Entry and exit regions may be poorly resolved.

Poor Control Interpolation

A high-order global interpolation may oscillate and create artificial violations.

Blind Trust in Solver Output

An NLP solver can converge to a local optimum, a poorly scaled point, or the solution of incorrectly coded equations.

Summary

  1. State inequality constraints may be inactive or active.

  2. A constrained arc is an interval on which the state constraint is exactly active.

  3. The order of the constraint is the number of derivatives required for the control to appear.

  4. Entry tangency conditions require

c(j)(t1)=0,j=0,,q1.c^{(j)}(t_1)=0, \qquad j=0,\ldots,q-1.
  1. On the active arc, the highest derivative condition determines the boundary control.

  2. Indirect methods require assumptions about constrained-arc structure.

  3. An incorrect active-set assumption may produce a suboptimal solution.

  4. Direct collocation enforces path inequalities at discrete points.

  5. The NLP solver determines the discrete active set.

  6. Discrete feasibility does not guarantee continuous feasibility.

  7. State and control interpolations must be checked on a dense grid.

  8. Mesh refinement is required until constraint violations and residuals are acceptably small.

  9. Continuous optimal-control theory is essential for validating direct numerical solutions.

Connection. Path-constrained trajectory optimization remains tied to a nominal initial condition; dynamic programming instead asks for optimal cost from every state and time.