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.

Neighboring Optimal Control

Suppose an optimal state, control, and costate trajectory have already been computed:

x(t),u(t),λ(t).\boldsymbol{x}^*(t),\qquad \boldsymbol{u}^*(t),\qquad \boldsymbol{\lambda}^*(t).

During implementation, disturbances, model mismatch, sensor error, and imperfect actuation may move the system away from this nominal optimal trajectory. One response is to solve the original nonlinear optimal control problem again. However, repeated nonlinear optimization may be too computationally expensive for real-time implementation.

Neighboring optimal control provides a local alternative. It constructs an approximately optimal correction near the nominal solution by:

  1. linearizing the dynamics about the nominal optimal trajectory;

  2. approximating the cost to second order;

  3. solving the resulting time-varying linear-quadratic problem;

  4. applying a feedback correction to the nominal control.

Nominal Optimal Control Problem

Consider the fixed-time problem

minu()J=Φ(x(tf))+t0tfL(x(t),u(t))dt\min_{\boldsymbol{u}(\cdot)} J = \Phi\bigl(\boldsymbol{x}(t_f)\bigr) + \int_{t_0}^{t_f} L\bigl(\boldsymbol{x}(t),\boldsymbol{u}(t)\bigr)\,\mathrm{d} t

subject to

x˙(t)=f(x(t),u(t)),x(t0)=x0.\begin{aligned} \dot{\boldsymbol{x}}(t) &= \boldsymbol{f}\bigl(\boldsymbol{x}(t),\boldsymbol{u}(t)\bigr),\\ \boldsymbol{x}(t_0) &= \boldsymbol{x}_0. \end{aligned}

For clarity, explicit time dependence, path constraints, and free-final-time terms are omitted. The neighboring-optimal-control idea extends to more general formulations.

Assume

(x(t),u(t),λ(t))\left( \boldsymbol{x}^*(t), \boldsymbol{u}^*(t), \boldsymbol{\lambda}^*(t) \right)

satisfies the first-order necessary conditions.

Neighboring Trajectories

Define perturbed trajectories:

x(t)=x(t)+δx(t),u(t)=u(t)+δu(t),λ(t)=λ(t)+δλ(t).\begin{aligned} \boldsymbol{x}(t) &= \boldsymbol{x}^*(t)+\delta\boldsymbol{x}(t),\\ \boldsymbol{u}(t) &= \boldsymbol{u}^*(t)+\delta\boldsymbol{u}(t),\\ \boldsymbol{\lambda}(t) &= \boldsymbol{\lambda}^*(t)+\delta\boldsymbol{\lambda}(t). \end{aligned}

The quantities

δx(t),δu(t),δλ(t)\delta\boldsymbol{x}(t),\qquad \delta\boldsymbol{u}(t),\qquad \delta\boldsymbol{\lambda}(t)

are neighboring variations.

If the actual initial condition differs from the nominal one,

x(t0)=x0+δx0,\boldsymbol{x}(t_0) = \boldsymbol{x}_0+\delta\boldsymbol{x}_0,

then

δx(t0)=δx0.\boxed{ \delta\boldsymbol{x}(t_0)=\delta\boldsymbol{x}_0. }

Why a Second-Order Cost Approximation Is Required

At an optimal solution, the first variation of the cost vanishes:

δJ=0.\delta J=0.

Therefore, a first-order cost approximation cannot distinguish neighboring directions. The leading nonzero local change in cost is generally the second variation:

JJ+12δ2J.J \approx J^* + \frac{1}{2}\delta^2J.

This is analogous to a static minimization problem.

Static Second-Order Expansion

For a scalar function g(z)g(\boldsymbol{z}),

g(z+Δz)g(z)+gz(z)Δz+12ΔzTgzz(z)Δz.\begin{aligned} g(\boldsymbol{z}^*+\Delta\boldsymbol{z}) \approx{}& g(\boldsymbol{z}^*) + g_{\boldsymbol{z}}(\boldsymbol{z}^*)\Delta\boldsymbol{z} \nonumber\\ &+ \frac{1}{2} \Delta\boldsymbol{z}^{\mathsf{T}} g_{\boldsymbol{z}\boldsymbol{z}}(\boldsymbol{z}^*) \Delta\boldsymbol{z}. \end{aligned}

At a local minimum,

gz(z)=0,g_{\boldsymbol{z}}(\boldsymbol{z}^*)=\boldsymbol{0},

so

g(z+Δz)g(z)+12ΔzTgzz(z)Δz.g(\boldsymbol{z}^*+\Delta\boldsymbol{z}) \approx g(\boldsymbol{z}^*) + \frac{1}{2} \Delta\boldsymbol{z}^{\mathsf{T}} g_{\boldsymbol{z}\boldsymbol{z}}(\boldsymbol{z}^*) \Delta\boldsymbol{z}.

The neighboring optimal control derivation follows the same principle for functions of time.

Second Variation of the Cost Functional

The terminal contribution is

12δxT(tf)Φxxδx(tf),\frac{1}{2} \delta\boldsymbol{x}^{\mathsf{T}}(t_f) \Phi_{\boldsymbol{x}\boldsymbol{x}}^* \delta\boldsymbol{x}(t_f),

where

Φxx=2Φx2x(tf).\Phi_{\boldsymbol{x}\boldsymbol{x}}^* = \left. \frac{\partial^2\Phi}{\partial\boldsymbol{x}^2} \right|_{\boldsymbol{x}^*(t_f)}.

The running-cost contribution is

12t0tf[δxδu]T[LxxLxuLuxLuu][δxδu]dt.\frac{1}{2} \int_{t_0}^{t_f} \begin{bmatrix} \delta\boldsymbol{x}\\ \delta\boldsymbol{u} \end{bmatrix}^{\mathsf{T}} \begin{bmatrix} L_{\boldsymbol{x}\boldsymbol{x}}^* & L_{\boldsymbol{x}\boldsymbol{u}}^*\\ L_{\boldsymbol{u}\boldsymbol{x}}^* & L_{\boldsymbol{u}\boldsymbol{u}}^* \end{bmatrix} \begin{bmatrix} \delta\boldsymbol{x}\\ \delta\boldsymbol{u} \end{bmatrix} \,\mathrm{d} t.

Define

Pf=Φxx,Q(t)=Lxx,M(t)=Lxu,R(t)=Luu.\begin{aligned} \boldsymbol{P}_f &= \Phi_{\boldsymbol{x}\boldsymbol{x}}^*,\\ \boldsymbol{Q}(t) &= L_{\boldsymbol{x}\boldsymbol{x}}^*,\\ \boldsymbol{M}(t) &= L_{\boldsymbol{x}\boldsymbol{u}}^*,\\ \boldsymbol{R}(t) &= L_{\boldsymbol{u}\boldsymbol{u}}^*. \end{aligned}

Then

δ2J=12δxT(tf)Pfδx(tf)+12t0tf[δxTQδx+2δxTMδu+δuTRδu]dt.\begin{aligned} \delta^2J ={}& \frac{1}{2} \delta\boldsymbol{x}^{\mathsf{T}}(t_f) \boldsymbol{P}_f \delta\boldsymbol{x}(t_f) \nonumber\\ &+ \frac{1}{2} \int_{t_0}^{t_f} \left[ \delta\boldsymbol{x}^{\mathsf{T}}\boldsymbol{Q}\delta\boldsymbol{x} + 2\delta\boldsymbol{x}^{\mathsf{T}}\boldsymbol{M}\delta\boldsymbol{u} + \delta\boldsymbol{u}^{\mathsf{T}}\boldsymbol{R}\delta\boldsymbol{u} \right]\,\mathrm{d} t. \end{aligned}

Linearized Neighboring Dynamics

Expand the nonlinear dynamics:

x˙+δx˙f(x,u)+fxδx+fuδu.\begin{aligned} \dot{\boldsymbol{x}}^*+\delta\dot{\boldsymbol{x}} \approx{}& \boldsymbol{f}(\boldsymbol{x}^*,\boldsymbol{u}^*) + \boldsymbol{f}_{\boldsymbol{x}}^*\delta\boldsymbol{x} + \boldsymbol{f}_{\boldsymbol{u}}^*\delta\boldsymbol{u}. \end{aligned}

Because

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

the nominal terms cancel.

Define

F(t)=fx(x,u),G(t)=fu(x,u).\begin{aligned} \boldsymbol{F}(t) &= \left. \frac{\partial\boldsymbol{f}}{\partial\boldsymbol{x}} \right|_{(\boldsymbol{x}^*,\boldsymbol{u}^*)},\\ \boldsymbol{G}(t) &= \left. \frac{\partial\boldsymbol{f}}{\partial\boldsymbol{u}} \right|_{(\boldsymbol{x}^*,\boldsymbol{u}^*)}. \end{aligned}

The neighboring dynamics are

δx˙=F(t)δx+G(t)δu.\boxed{ \delta\dot{\boldsymbol{x}} = \boldsymbol{F}(t)\delta\boldsymbol{x} + \boldsymbol{G}(t)\delta\boldsymbol{u}. }

Neighboring Optimal Control Problem

The local correction problem is therefore

minδu()δ2J\min_{\delta\boldsymbol{u}(\cdot)} \delta^2J

subject to

δx˙=Fδx+Gδu,δx(t0)=δx0.\begin{aligned} \delta\dot{\boldsymbol{x}} &= \boldsymbol{F}\delta\boldsymbol{x}+\boldsymbol{G}\delta\boldsymbol{u},\\ \delta\boldsymbol{x}(t_0) &= \delta\boldsymbol{x}_0. \end{aligned}

This is a finite-horizon, time-varying linear-quadratic optimal control problem with state–control coupling.

Neighboring Hamiltonian

The Hamiltonian for the neighboring problem is

HN=12δxTQδx+δxTMδu+12δuTRδu+δλT(Fδx+Gδu).\begin{aligned} \mathcal{H}_N ={}& \frac{1}{2} \delta\boldsymbol{x}^{\mathsf{T}}\boldsymbol{Q}\delta\boldsymbol{x} + \delta\boldsymbol{x}^{\mathsf{T}}\boldsymbol{M}\delta\boldsymbol{u} + \frac{1}{2} \delta\boldsymbol{u}^{\mathsf{T}}\boldsymbol{R}\delta\boldsymbol{u} \nonumber\\ &+ \delta\boldsymbol{\lambda}^{\mathsf{T}} \left( \boldsymbol{F}\delta\boldsymbol{x}+\boldsymbol{G}\delta\boldsymbol{u} \right). \end{aligned}

Neighboring Costate Equation

The costate dynamics satisfy

δλ˙=HNδx.\delta\dot{\boldsymbol{\lambda}} = -\frac{\partial\mathcal{H}_N}{\partial\delta\boldsymbol{x}}.

Hence,

δλ˙=QδxMδuFTδλ.\boxed{ \delta\dot{\boldsymbol{\lambda}} = -\boldsymbol{Q}\delta\boldsymbol{x} -\boldsymbol{M}\delta\boldsymbol{u} -\boldsymbol{F}^{\mathsf{T}}\delta\boldsymbol{\lambda}. }

The terminal boundary condition is

δλ(tf)=Pfδx(tf).\boxed{ \delta\boldsymbol{\lambda}(t_f) = \boldsymbol{P}_f\delta\boldsymbol{x}(t_f). }

Stationarity and Neighboring Optimal Control

The stationarity condition is

HNδu=0.\frac{\partial\mathcal{H}_N}{\partial\delta\boldsymbol{u}} = \boldsymbol{0}.

Therefore,

MTδx+Rδu+GTδλ=0.\boldsymbol{M}^{\mathsf{T}}\delta\boldsymbol{x} + \boldsymbol{R}\delta\boldsymbol{u} + \boldsymbol{G}^{\mathsf{T}}\delta\boldsymbol{\lambda} = \boldsymbol{0}.

Assuming R\boldsymbol{R} is invertible,

δu=R1(MTδx+GTδλ).\boxed{ \delta\boldsymbol{u}^* = -\boldsymbol{R}^{-1} \left( \boldsymbol{M}^{\mathsf{T}}\delta\boldsymbol{x} + \boldsymbol{G}^{\mathsf{T}}\delta\boldsymbol{\lambda} \right). }

Coupled State–Costate System

Substituting the stationarity condition into the state dynamics gives

δx˙=(FGR1MT)δxGR1GTδλ.\boxed{ \delta\dot{\boldsymbol{x}} = \left( \boldsymbol{F} - \boldsymbol{G}\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}} \right)\delta\boldsymbol{x} - \boldsymbol{G}\boldsymbol{R}^{-1}\boldsymbol{G}^{\mathsf{T}}\delta\boldsymbol{\lambda}. }

Substitution into the costate equation gives

δλ˙=(QMR1MT)δx(FTMR1GT)δλ.\boxed{ \delta\dot{\boldsymbol{\lambda}} = - \left( \boldsymbol{Q} - \boldsymbol{M}\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}} \right)\delta\boldsymbol{x} - \left( \boldsymbol{F}^{\mathsf{T}} - \boldsymbol{M}\boldsymbol{R}^{-1}\boldsymbol{G}^{\mathsf{T}} \right)\delta\boldsymbol{\lambda}. }

The boundary conditions are split:

δx(t0)=δx0,δλ(tf)=Pfδx(tf).\begin{aligned} \delta\boldsymbol{x}(t_0)&=\delta\boldsymbol{x}_0,\\ \delta\boldsymbol{\lambda}(t_f)&=\boldsymbol{P}_f\delta\boldsymbol{x}(t_f). \end{aligned}

Thus, the neighboring necessary conditions form a linear two-point boundary-value problem.

Riccati Transformation

Assume a linear relationship between neighboring costate and neighboring state:

δλ(t)=P(t)δx(t).\boxed{ \delta\boldsymbol{\lambda}(t)=\boldsymbol{P}(t)\delta\boldsymbol{x}(t). }

Differentiating,

δλ˙=P˙δx+Pδx˙.\delta\dot{\boldsymbol{\lambda}} = \dot{\boldsymbol{P}}\delta\boldsymbol{x} + \boldsymbol{P}\delta\dot{\boldsymbol{x}}.

Substituting the state and costate equations and requiring the result to hold for all δx\delta\boldsymbol{x} yields a matrix Riccati differential equation.

Generalized Riccati Differential Equation

The resulting equation is

P˙=Q+MR1MT(FTMR1GT)PP(FGR1MT)+PGR1GTP.\begin{aligned} \dot{\boldsymbol{P}} ={}& -\boldsymbol{Q} + \boldsymbol{M}\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}} \nonumber\\ &- \left( \boldsymbol{F}^{\mathsf{T}} - \boldsymbol{M}\boldsymbol{R}^{-1}\boldsymbol{G}^{\mathsf{T}} \right)\boldsymbol{P} \nonumber\\ &- \boldsymbol{P} \left( \boldsymbol{F} - \boldsymbol{G}\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}} \right) \nonumber\\ &+ \boldsymbol{P}\boldsymbol{G}\boldsymbol{R}^{-1}\boldsymbol{G}^{\mathsf{T}}\boldsymbol{P}. \end{aligned}

Equivalently,

P˙=Q+FTP+PF(PG+M)R1(GTP+MT).\begin{aligned} -\dot{\boldsymbol{P}} ={}& \boldsymbol{Q} + \boldsymbol{F}^{\mathsf{T}}\boldsymbol{P} + \boldsymbol{P}\boldsymbol{F} \nonumber\\ &- \left( \boldsymbol{P}\boldsymbol{G}+\boldsymbol{M} \right) \boldsymbol{R}^{-1} \left( \boldsymbol{G}^{\mathsf{T}}\boldsymbol{P}+\boldsymbol{M}^{\mathsf{T}} \right). \end{aligned}

The terminal condition is

P(tf)=Pf.\boxed{ \boldsymbol{P}(t_f)=\boldsymbol{P}_f. }

This equation is integrated backward from tft_f to t0t_0.

Neighboring Optimal Feedback Law

Using

δλ=Pδx\delta\boldsymbol{\lambda}=\boldsymbol{P}\delta\boldsymbol{x}

in the stationarity condition,

δu=R1(MT+GTP)δx.\begin{aligned} \delta\boldsymbol{u}^* &= -\boldsymbol{R}^{-1} \left( \boldsymbol{M}^{\mathsf{T}} + \boldsymbol{G}^{\mathsf{T}}\boldsymbol{P} \right)\delta\boldsymbol{x}. \end{aligned}

Define the time-varying gain

K(t)=R1(t)[MT(t)+GT(t)P(t)].\boxed{ \boldsymbol{K}(t) = \boldsymbol{R}^{-1}(t) \left[ \boldsymbol{M}^{\mathsf{T}}(t) + \boldsymbol{G}^{\mathsf{T}}(t)\boldsymbol{P}(t) \right]. }

Then

δu(t)=K(t)δx(t).\boxed{ \delta\boldsymbol{u}^*(t) = -\boldsymbol{K}(t)\delta\boldsymbol{x}(t). }

The implemented control becomes

u(t)=u(t)K(t)[x(t)x(t)].\boxed{ \boldsymbol{u}(t) = \boldsymbol{u}^*(t) - \boldsymbol{K}(t) \left[ \boldsymbol{x}(t)-\boldsymbol{x}^*(t) \right]. }

This is a trajectory-tracking feedback law centered on the nonlinear optimal solution.

Closed-Loop Neighboring Dynamics

Substituting the feedback law into the linearized dynamics gives

δx˙=[FGK]δx.\delta\dot{\boldsymbol{x}} = \left[ \boldsymbol{F} - \boldsymbol{G}\boldsymbol{K} \right]\delta\boldsymbol{x}.

Hence,

δx˙=[FGR1(MT+GTP)]δx.\boxed{ \delta\dot{\boldsymbol{x}} = \left[ \boldsymbol{F} - \boldsymbol{G}\boldsymbol{R}^{-1} \left( \boldsymbol{M}^{\mathsf{T}} + \boldsymbol{G}^{\mathsf{T}}\boldsymbol{P} \right) \right]\delta\boldsymbol{x}. }

Block-Diagram Interpretation

Neighboring optimal feedback around the nominal trajectory.

Figure 1:Neighboring optimal feedback around the nominal trajectory.

Interpretation of the Cross Matrix M\boldsymbol{M}

The matrix

M=Lxu\boldsymbol{M} = L_{\boldsymbol{x}\boldsymbol{u}}^*

captures local coupling between state and control variations in the running cost.

When M=0\boldsymbol{M}=\boldsymbol{0}, the generalized Riccati equation reduces to the standard finite-horizon time-varying LQR equation:

P˙=Q+FTP+PFPGR1GTP.-\dot{\boldsymbol{P}} = \boldsymbol{Q} + \boldsymbol{F}^{\mathsf{T}}\boldsymbol{P} + \boldsymbol{P}\boldsymbol{F} - \boldsymbol{P}\boldsymbol{G}\boldsymbol{R}^{-1}\boldsymbol{G}^{\mathsf{T}}\boldsymbol{P}.

The feedback gain becomes

K=R1GTP.\boldsymbol{K} = \boldsymbol{R}^{-1}\boldsymbol{G}^{\mathsf{T}}\boldsymbol{P}.

Completing the Square

The running quadratic form can be written as

δxTQδx+2δxTMδu+δuTRδu=(δu+R1MTδx)TR(δu+R1MTδx)+δxT(QMR1MT)δx.\begin{aligned} &\delta\boldsymbol{x}^{\mathsf{T}}\boldsymbol{Q}\delta\boldsymbol{x} + 2\delta\boldsymbol{x}^{\mathsf{T}}\boldsymbol{M}\delta\boldsymbol{u} + \delta\boldsymbol{u}^{\mathsf{T}}\boldsymbol{R}\delta\boldsymbol{u} \nonumber\\ ={}& \left( \delta\boldsymbol{u}+\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}}\delta\boldsymbol{x} \right)^{\mathsf{T}} \boldsymbol{R} \left( \delta\boldsymbol{u}+\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}}\delta\boldsymbol{x} \right) \nonumber\\ &+ \delta\boldsymbol{x}^{\mathsf{T}} \left( \boldsymbol{Q} - \boldsymbol{M}\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}} \right) \delta\boldsymbol{x}. \end{aligned}

This shows why the effective state penalty is

Qeff=QMR1MT.\boxed{ \boldsymbol{Q}_{\mathrm{eff}} = \boldsymbol{Q} - \boldsymbol{M}\boldsymbol{R}^{-1}\boldsymbol{M}^{\mathsf{T}}. }

Conditions for a Well-Defined Neighboring Controller

Several assumptions are important.

Positive Definiteness of R\boldsymbol{R}

Because the feedback law requires R1\boldsymbol{R}^{-1},

R(t)0\boxed{ \boldsymbol{R}(t)\succ\boldsymbol{0} }

is commonly imposed.

Positive semidefiniteness is insufficient when R\boldsymbol{R} becomes singular.

State Penalty

Typically,

Q(t)0,Pf0.\boldsymbol{Q}(t)\succeq\boldsymbol{0}, \qquad \boldsymbol{P}_f\succeq\boldsymbol{0}.

With a cross term, a stronger convexity condition may be expressed through the block Hessian:

[QMMTR]0.\begin{bmatrix} \boldsymbol{Q} & \boldsymbol{M}\\ \boldsymbol{M}^{\mathsf{T}} & \boldsymbol{R} \end{bmatrix} \succeq\boldsymbol{0}.

Controllability or Stabilizability

The pair

(F(t),G(t))(\boldsymbol{F}(t),\boldsymbol{G}(t))

should be controllable or at least stabilizable over the interval.

Otherwise, some deviations cannot be corrected.

Observability or Detectability

The state penalty and system dynamics should provide adequate detectability. In standard LQR language, an appropriate pair related to

(F,Q1/2)(\boldsymbol{F},\boldsymbol{Q}^{1/2})

should be detectable.

Small Perturbations

The method relies on local approximations:

f(x,u)f+Fδx+Gδu,JJ+12δ2J.\begin{aligned} \boldsymbol{f}(\boldsymbol{x},\boldsymbol{u}) &\approx \boldsymbol{f}^* + \boldsymbol{F}\delta\boldsymbol{x} + \boldsymbol{G}\delta\boldsymbol{u},\\ J &\approx J^* + \frac{1}{2}\delta^2J. \end{aligned}

Therefore,

δx,δu\|\delta\boldsymbol{x}\|, \qquad \|\delta\boldsymbol{u}\|

must remain sufficiently small.

Neighboring Control versus Reoptimization

Two correction strategies are possible after a disturbance.

Neighboring-Control Correction

Use

δu=Kδx.\delta\boldsymbol{u}=-\boldsymbol{K}\delta\boldsymbol{x}.

Advantages include:

The limitation is local validity.

Full Reoptimization

Resolve the nonlinear optimal control problem from the new state.

Advantages include:

The limitation is computational cost.

Offline and Online Computation

A practical implementation can separate computation into two stages.

Offline Stage

  1. solve the nonlinear optimal control problem;

  2. store x(t)\boldsymbol{x}^*(t) and u(t)\boldsymbol{u}^*(t);

  3. compute F\boldsymbol{F}, G\boldsymbol{G}, Q\boldsymbol{Q}, M\boldsymbol{M}, and R\boldsymbol{R};

  4. integrate the Riccati equation backward;

  5. store P(t)\boldsymbol{P}(t) or K(t)\boldsymbol{K}(t).

Online Stage

At each control update:

  1. estimate the current state x^(t)\hat{\boldsymbol{x}}(t);

  2. compute

δx(t)=x^(t)x(t);\delta\boldsymbol{x}(t)=\hat{\boldsymbol{x}}(t)-\boldsymbol{x}^*(t);
  1. evaluate the stored gain K(t)\boldsymbol{K}(t);

  2. compute

δu=K(t)δx;\delta\boldsymbol{u}=-\boldsymbol{K}(t)\delta\boldsymbol{x};
  1. apply

u=u+δu.\boldsymbol{u}=\boldsymbol{u}^*+\delta\boldsymbol{u}.

The Riccati equation need not be integrated online if the nominal trajectory and gain schedule are known in advance.

Parallel-Processor Interpretation

In some architectures, one processor may compute or update the Riccati solution while another applies the real-time feedback law. However, for a fixed nominal trajectory, it is often preferable to compute the gain schedule offline and store it.

Parallel online computation may be useful when:

Relation to Time-Varying LQR

Neighboring optimal control is closely related to trajectory linearization followed by finite-horizon time-varying LQR.

The distinction is that its weighting matrices are not chosen arbitrarily. They arise from the second derivatives of the original nonlinear optimal control problem:

Q=Lxx,M=Lxu,R=Luu,Pf=Φxx.\begin{aligned} \boldsymbol{Q}&=L_{\boldsymbol{x}\boldsymbol{x}}^*,\\ \boldsymbol{M}&=L_{\boldsymbol{x}\boldsymbol{u}}^*,\\ \boldsymbol{R}&=L_{\boldsymbol{u}\boldsymbol{u}}^*,\\ \boldsymbol{P}_f&=\Phi_{\boldsymbol{x}\boldsymbol{x}}^*. \end{aligned}

Thus, the local controller is tied directly to the original nonlinear objective.

Connection to Differential Dynamic Programming

Neighboring optimal control and differential dynamic programming share the use of:

Differential dynamic programming goes further by iteratively updating the nominal trajectory and repeating the local approximation.

Implementation Workflow

A complete workflow is:

  1. solve the nominal nonlinear optimal control problem;

  2. verify the nominal state, control, and constraints;

  3. compute first derivatives of the dynamics;

  4. compute second derivatives of terminal and running costs;

  5. construct the neighboring LQ problem;

  6. check symmetry and definiteness;

  7. solve the generalized Riccati equation backward;

  8. construct the gain schedule;

  9. simulate the perturbed nonlinear system;

  10. compare neighboring feedback with open-loop execution;

  11. determine the perturbation range over which the approximation remains accurate.

MATLAB Skeleton

t = linspace(t0,tf,N);

% F(:,:,k), G(:,:,k), Q(:,:,k), M(:,:,k), and R(:,:,k)
% are evaluated along x_star(t), u_star(t).

% Integrate P backward from P(tf) = Pf.
P = zeros(nx,nx,N);
P(:,:,N) = Pf;

for k = N:-1:2
    dt = t(k)-t(k-1);

    Fk = F(:,:,k);
    Gk = G(:,:,k);
    Qk = Q(:,:,k);
    Mk = M(:,:,k);
    Rk = R(:,:,k);
    Pk = P(:,:,k);

    Pdot = -Qk ...
        + Mk*(Rk\Mk') ...
        - (Fk' - Mk*(Rk\Gk'))*Pk ...
        - Pk*(Fk - Gk*(Rk\Mk')) ...
        + Pk*Gk*(Rk\Gk')*Pk;

    % Backward Euler illustration.
    P(:,:,k-1) = Pk - dt*Pdot;
end

% Gain schedule.
K = zeros(nu,nx,N);
for k = 1:N
    K(:,:,k) = R(:,:,k) \ ...
        (M(:,:,k)' + G(:,:,k)'*P(:,:,k));
end

% Online correction:
% delta_x = x_measured - x_star;
% delta_u = -K(:,:,k)*delta_x;
% u = u_star + delta_u;

For high-quality computation, use a suitable ODE solver rather than the illustrative backward-Euler update.

Verification Tests

A neighboring optimal controller should be tested for:

Common Errors

Summary

  1. Neighboring optimal control begins with a nominal nonlinear optimal trajectory.

  2. The state, control, and costate are perturbed around that trajectory.

  3. The first variation vanishes on the optimal solution.

  4. Therefore, the cost must be retained to second order.

  5. The dynamics are linearized to first order.

  6. The result is a time-varying LQ problem with a state–control cross term.

  7. The neighboring Hamiltonian produces linear state and costate equations.

  8. A Riccati transformation converts the two-point boundary-value problem into a backward matrix differential equation.

  9. The optimal correction is a time-varying feedback law.

  10. The total control is the nominal optimal control plus the neighboring correction.

  11. The method is appropriate for small perturbations.

  12. Large deviations generally require nonlinear reoptimization.