Costate Estimation Using the Legendre–Gauss Method
This section begins the derivation of costate estimates from the dual variables of a Legendre–Gauss (LG) pseudospectral nonlinear programming problem. The central task is to connect the continuous-time first-order optimality conditions with the Karush–Kuhn–Tucker conditions of the discretized nonlinear program.
The chapter develops:
the continuous Hamiltonian optimality conditions;
the LG pseudospectral nonlinear program;
the NLP Lagrangian;
the KKT stationarity conditions;
a separate polynomial approximation for the costate;
the adjoint differentiation matrix D † \boldsymbol{D}^\dagger D † ; and
the matrix identities needed for the costate mapping theorem.
Simplified Mayer Optimal-Control Problem ¶ Consider
min x ( ⋅ ) , u ( ⋅ ) Φ ( x ( 1 ) ) , \min_{\boldsymbol{x}(\cdot),\boldsymbol{u}(\cdot)}
\Phi\bigl(\boldsymbol{x}(1)\bigr), x ( ⋅ ) , u ( ⋅ ) min Φ ( x ( 1 ) ) , subject to
x ˙ ( τ ) = f ( x ( τ ) , u ( τ ) ) , τ ∈ [ − 1 , 1 ] , \dot{\boldsymbol{x}}(\tau)
=
\boldsymbol{f}\bigl(\boldsymbol{x}(\tau),\boldsymbol{u}(\tau)\bigr),
\qquad
\tau\in[-1,1], x ˙ ( τ ) = f ( x ( τ ) , u ( τ ) ) , τ ∈ [ − 1 , 1 ] , and
x ( − 1 ) = x 0 . \boldsymbol{x}(-1)=\boldsymbol{x}_0. x ( − 1 ) = x 0 . No Lagrange running cost is included, so the Hamiltonian is
H ( x , u , λ ) = λ T f ( x , u ) . H(\boldsymbol{x},\boldsymbol{u},\boldsymbol{\lambda})
=
\boldsymbol{\lambda}^{\mathsf{T}}\boldsymbol{f}(\boldsymbol{x},\boldsymbol{u}). H ( x , u , λ ) = λ T f ( x , u ) . Continuous-Time Optimality Conditions ¶ The first-order necessary conditions are:
Terminal Transversality ¶ λ ( 1 ) = ∇ x Φ ( x ( 1 ) ) . \boxed{
\boldsymbol{\lambda}(1)
=
\nabla_{\boldsymbol{x}}\Phi\bigl(\boldsymbol{x}(1)\bigr).
} λ ( 1 ) = ∇ x Φ ( x ( 1 ) ) . Costate Equation ¶ λ ˙ ( τ ) = − ∇ x H = − ∇ x [ λ ( τ ) T f ( x ( τ ) , u ( τ ) ) ] . \boxed{
\dot{\boldsymbol{\lambda}}(\tau)
=
-
\nabla_{\boldsymbol{x}}H
=
-
\nabla_{\boldsymbol{x}}
\left[
\boldsymbol{\lambda}(\tau)^{\mathsf{T}}
\boldsymbol{f}\bigl(\boldsymbol{x}(\tau),\boldsymbol{u}(\tau)\bigr)
\right].
} λ ˙ ( τ ) = − ∇ x H = − ∇ x [ λ ( τ ) T f ( x ( τ ) , u ( τ ) ) ] . Stationarity with Respect to Control ¶ ∇ u H = ∇ u [ λ ( τ ) T f ( x ( τ ) , u ( τ ) ) ] = 0 . \boxed{
\nabla_{\boldsymbol{u}}H
=
\nabla_{\boldsymbol{u}}
\left[
\boldsymbol{\lambda}(\tau)^{\mathsf{T}}
\boldsymbol{f}\bigl(\boldsymbol{x}(\tau),\boldsymbol{u}(\tau)\bigr)
\right]
=
\boldsymbol{0}.
} ∇ u H = ∇ u [ λ ( τ ) T f ( x ( τ ) , u ( τ ) ) ] = 0 . The objective is to recover approximations of λ ( τ ) \boldsymbol{\lambda}(\tau) λ ( τ ) from the KKT multipliers of the LG transcription.
LG Grid and State Approximation ¶ Let
τ 1 , … , τ N \tau_1,\ldots,\tau_N τ 1 , … , τ N be the LG points, with
− 1 < τ 1 < ⋯ < τ N < 1. -1<\tau_1<\cdots<\tau_N<1. − 1 < τ 1 < ⋯ < τ N < 1. Define
τ 0 = − 1 , τ N + 1 = 1. \tau_0=-1,
\qquad
\tau_{N+1}=1. τ 0 = − 1 , τ N + 1 = 1. Approximate the state as
X ( τ ) = ∑ i = 0 N X i L i ( τ ) , \boldsymbol{X}(\tau)
=
\sum_{i=0}^{N}\boldsymbol{X}_iL_i(\tau), X ( τ ) = i = 0 ∑ N X i L i ( τ ) , where
L i ( τ ) = ∏ j = 0 j ≠ i N τ − τ j τ i − τ j . L_i(\tau)
=
\prod_{\substack{j=0\\j\neq i}}^{N}
\frac{\tau-\tau_j}{\tau_i-\tau_j}. L i ( τ ) = j = 0 j = i ∏ N τ i − τ j τ − τ j . Differentiation gives
X ˙ ( τ ) = ∑ i = 0 N X i L i ′ ( τ ) . \dot{\boldsymbol{X}}(\tau)
=
\sum_{i=0}^{N}\boldsymbol{X}_iL_i'(\tau). X ˙ ( τ ) = i = 0 ∑ N X i L i ′ ( τ ) . LG Differentiation Matrix ¶ Define
D j i = L i ′ ( τ j ) , j = 1 , … , N , i = 0 , … , N . D_{ji}=L_i'(\tau_j),
\qquad
j=1,\ldots,N,
\qquad
i=0,\ldots,N. D ji = L i ′ ( τ j ) , j = 1 , … , N , i = 0 , … , N . Thus,
D ∈ R N × ( N + 1 ) . \boldsymbol{D}\in\mathbb{R}^{N\times(N+1)}. D ∈ R N × ( N + 1 ) . The collocation equations are
D X 0 : N = F 1 : N , \boxed{
\boldsymbol{D}\boldsymbol{X}_{0:N}
=
\boldsymbol{F}_{1:N},
} D X 0 : N = F 1 : N , where
F j = f ( X j , U j ) . \boldsymbol{F}_j
=
\boldsymbol{f}(\boldsymbol{X}_j,\boldsymbol{U}_j). F j = f ( X j , U j ) . The terminal state is estimated by LG quadrature:
X N + 1 = X 0 + w T F 1 : N . \boxed{
\boldsymbol{X}_{N+1}
=
\boldsymbol{X}_0+\boldsymbol{w}^{\mathsf{T}}\boldsymbol{F}_{1:N}.
} X N + 1 = X 0 + w T F 1 : N . The LG Nonlinear Program ¶ The discretized NLP is
min X , U Φ ( X N + 1 ) subject to F 1 : N − D X 0 : N = 0 , w T F 1 : N + X 0 − X N + 1 = 0 , X 0 − x 0 = 0 . \boxed{
\begin{aligned}
\min_{\boldsymbol{X},\boldsymbol{U}}\quad
&
\Phi(\boldsymbol{X}_{N+1})
\\
\text{subject to}\quad
&
\boldsymbol{F}_{1:N}-\boldsymbol{D}\boldsymbol{X}_{0:N}
=
\boldsymbol{0},
\\
&
\boldsymbol{w}^{\mathsf{T}}\boldsymbol{F}_{1:N}
+\boldsymbol{X}_0-\boldsymbol{X}_{N+1}
=
\boldsymbol{0},
\\
&
\boldsymbol{X}_0-\boldsymbol{x}_0
=
\boldsymbol{0}.
\end{aligned}
} X , U min subject to Φ ( X N + 1 ) F 1 : N − D X 0 : N = 0 , w T F 1 : N + X 0 − X N + 1 = 0 , X 0 − x 0 = 0 . Because X 0 \boldsymbol{X}_0 X 0 is fixed, it may be removed from the optimization vector after substitution.
KKT Multipliers ¶ Let
Λ 1 : N = [ Λ 1 ⋮ Λ N ] \boldsymbol{\Lambda}_{1:N}
=
\begin{bmatrix}
\boldsymbol{\Lambda}_1\\
\vdots\\
\boldsymbol{\Lambda}_N
\end{bmatrix} Λ 1 : N = ⎣ ⎡ Λ 1 ⋮ Λ N ⎦ ⎤ denote the multipliers associated with the collocation equations.
Let
Λ N + 1 \boldsymbol{\Lambda}_{N+1} Λ N + 1 denote the multiplier associated with the terminal quadrature equation.
These are NLP multipliers, not yet costate estimates.
NLP Lagrangian ¶ Define
L = Φ ( X N + 1 ) + ⟨ Λ 1 : N , F 1 : N − D X 0 : N ⟩ + ⟨ Λ N + 1 , w T F 1 : N + X 0 − X N + 1 ⟩ . \begin{aligned}
\mathcal{L}
={}&
\Phi(\boldsymbol{X}_{N+1})
+
\left\langle
\boldsymbol{\Lambda}_{1:N},
\boldsymbol{F}_{1:N}-\boldsymbol{D}\boldsymbol{X}_{0:N}
\right\rangle
\nonumber\\
&+
\left\langle
\boldsymbol{\Lambda}_{N+1},
\boldsymbol{w}^{\mathsf{T}}\boldsymbol{F}_{1:N}
+\boldsymbol{X}_0-\boldsymbol{X}_{N+1}
\right\rangle.
\end{aligned} L = Φ ( X N + 1 ) + ⟨ Λ 1 : N , F 1 : N − D X 0 : N ⟩ + ⟨ Λ N + 1 , w T F 1 : N + X 0 − X N + 1 ⟩ . The angle brackets denote the appropriate Euclidean or Frobenius inner product.
Stationarity Conditions of the NLP ¶ Differentiation with respect to the discrete state variables at the LG points yields
D 1 : N T Λ 1 : N = ∇ X ⟨ Λ 1 : N + W 1 Λ N + 1 , F 1 : N ⟩ . \boxed{
\boldsymbol{D}_{1:N}^{\mathsf{T}}
\boldsymbol{\Lambda}_{1:N}
=
\nabla_{\boldsymbol{X}}
\left\langle
\boldsymbol{\Lambda}_{1:N}
+
\boldsymbol{W}\boldsymbol{1}\,\boldsymbol{\Lambda}_{N+1},
\boldsymbol{F}_{1:N}
\right\rangle.
} D 1 : N T Λ 1 : N = ∇ X ⟨ Λ 1 : N + W 1 Λ N + 1 , F 1 : N ⟩ . Here,
W = diag ( w 1 , … , w N ) . \boldsymbol{W}
=
\operatorname{diag}(w_1,\ldots,w_N). W = diag ( w 1 , … , w N ) . Differentiation with respect to the terminal state gives
Λ N + 1 = ∇ X Φ ( X N + 1 ) . \boxed{
\boldsymbol{\Lambda}_{N+1}
=
\nabla_{\boldsymbol{X}}
\Phi(\boldsymbol{X}_{N+1}).
} Λ N + 1 = ∇ X Φ ( X N + 1 ) . Differentiation with respect to the controls gives
0 = ∇ U ⟨ W − 1 Λ 1 : N + 1 Λ N + 1 , F 1 : N ⟩ . \boxed{
\boldsymbol{0}
=
\nabla_{\boldsymbol{U}}
\left\langle
\boldsymbol{W}^{-1}\boldsymbol{\Lambda}_{1:N}
+
\boldsymbol{1}\,\boldsymbol{\Lambda}_{N+1},
\boldsymbol{F}_{1:N}
\right\rangle.
} 0 = ∇ U ⟨ W − 1 Λ 1 : N + 1 Λ N + 1 , F 1 : N ⟩ . These equations already resemble the continuous costate, transversality, and stationarity conditions.
Why a Second Polynomial Space Is Needed ¶ The state approximation uses
τ 0 , τ 1 , … , τ N , \tau_0,\tau_1,\ldots,\tau_N, τ 0 , τ 1 , … , τ N , that is, the initial point plus the LG points.
The costate approximation must instead use
τ 1 , … , τ N , τ N + 1 , \tau_1,\ldots,\tau_N,\tau_{N+1}, τ 1 , … , τ N , τ N + 1 , that is, the LG points plus the final point.
This shift is essential because the terminal costate is specified by the transversality condition.
Costate Approximation ¶ Approximate the costate by
Λ ( τ ) = ∑ i = 1 N + 1 λ i L i † ( τ ) , \boxed{
\boldsymbol{\Lambda}(\tau)
=
\sum_{i=1}^{N+1}
\boldsymbol{\lambda}_i
L_i^\dagger(\tau),
} Λ ( τ ) = i = 1 ∑ N + 1 λ i L i † ( τ ) , where
L i † ( τ ) = ∏ j = 1 j ≠ i N + 1 τ − τ j τ i − τ j . L_i^\dagger(\tau)
=
\prod_{\substack{j=1\\j\neq i}}^{N+1}
\frac{\tau-\tau_j}{\tau_i-\tau_j}. L i † ( τ ) = j = 1 j = i ∏ N + 1 τ i − τ j τ − τ j . This is a polynomial of degree N N N .
Its derivative is
Λ ˙ ( τ ) = ∑ i = 1 N + 1 λ i ( L i † ) ′ ( τ ) . \dot{\boldsymbol{\Lambda}}(\tau)
=
\sum_{i=1}^{N+1}
\boldsymbol{\lambda}_i
\left(L_i^\dagger\right)'(\tau). Λ ˙ ( τ ) = i = 1 ∑ N + 1 λ i ( L i † ) ′ ( τ ) . Adjoint Differentiation Matrix ¶ Define
D j i † = ( L i † ) ′ ( τ j ) , j = 1 , … , N , i = 1 , … , N + 1. D^\dagger_{ji}
=
\left(L_i^\dagger\right)'(\tau_j),
\qquad
j=1,\ldots,N,
\qquad
i=1,\ldots,N+1. D ji † = ( L i † ) ′ ( τ j ) , j = 1 , … , N , i = 1 , … , N + 1. Then
D † ∈ R N × ( N + 1 ) . \boxed{
\boldsymbol{D}^\dagger
\in
\mathbb{R}^{N\times(N+1)}.
} D † ∈ R N × ( N + 1 ) . Partition it as
D † = [ D 1 : N † d N + 1 † ] . \boldsymbol{D}^\dagger
=
\begin{bmatrix}
\boldsymbol{D}^\dagger_{1:N}
&
\boldsymbol{d}^\dagger_{N+1}
\end{bmatrix}. D † = [ D 1 : N † d N + 1 † ] . Relationship Between the State and Costate Differentiation Matrices ¶ The crucial weighted transpose relation is
D 1 : N T = − W D 1 : N † W − 1 . \boxed{
\boldsymbol{D}_{1:N}^{\mathsf{T}}
=
-
\boldsymbol{W}
\boldsymbol{D}^\dagger_{1:N}
\boldsymbol{W}^{-1}.
} D 1 : N T = − W D 1 : N † W − 1 . Equivalently,
D 1 : N † = − W − 1 D 1 : N T W . \boxed{
\boldsymbol{D}^\dagger_{1:N}
=
-
\boldsymbol{W}^{-1}
\boldsymbol{D}_{1:N}^{\mathsf{T}}
\boldsymbol{W}.
} D 1 : N † = − W − 1 D 1 : N T W . This identity provides the bridge between the KKT system and the discrete costate equation.
Derivative of a Constant ¶ Because a differentiation matrix must annihilate a constant polynomial,
D † 1 N + 1 = 0 . \boldsymbol{D}^\dagger\boldsymbol{1}_{N+1}
=
\boldsymbol{0}. D † 1 N + 1 = 0 . Therefore,
D 1 : N † 1 + d N + 1 † = 0 , \boldsymbol{D}^\dagger_{1:N}\boldsymbol{1}
+
\boldsymbol{d}^\dagger_{N+1}
=
\boldsymbol{0}, D 1 : N † 1 + d N + 1 † = 0 , and
d N + 1 † = − D 1 : N † 1 . \boxed{
\boldsymbol{d}^\dagger_{N+1}
=
-
\boldsymbol{D}^\dagger_{1:N}\boldsymbol{1}.
} d N + 1 † = − D 1 : N † 1 . This relation is needed to incorporate the terminal costate into the discrete adjoint equation.
Preview of the Costate Mapping ¶ Define the interior costate estimate by
λ 1 : N = W − 1 Λ 1 : N + 1 Λ N + 1 . \boxed{
\boldsymbol{\lambda}_{1:N}
=
\boldsymbol{W}^{-1}\boldsymbol{\Lambda}_{1:N}
+
\boldsymbol{1}\,\boldsymbol{\Lambda}_{N+1}.
} λ 1 : N = W − 1 Λ 1 : N + 1 Λ N + 1 . Define the terminal costate by
λ N + 1 = Λ N + 1 . \boxed{
\boldsymbol{\lambda}_{N+1}
=
\boldsymbol{\Lambda}_{N+1}.
} λ N + 1 = Λ N + 1 . Substitution into the KKT equations produces a discrete analogue of
λ ˙ = − ∇ x ( λ T f ) . \dot{\boldsymbol{\lambda}}
=
-
\nabla_{\boldsymbol{x}}
\left(
\boldsymbol{\lambda}^{\mathsf{T}}\boldsymbol{f}
\right). λ ˙ = − ∇ x ( λ T f ) . The detailed transformation is developed in Session 22B.
Summary ¶ The continuous costate equation follows from the Hamiltonian.
The LG transcription produces collocation and terminal quadrature constraints.
Each constraint has an associated KKT multiplier.
The NLP Lagrangian yields discrete stationarity conditions.
The state and costate use different Lagrange polynomial bases.
The costate basis uses the LG points plus the final point.
The weighted transpose relation between D \boldsymbol{D} D and D † \boldsymbol{D}^\dagger D † is the key algebraic identity.
These results prepare the costate mapping theorem.
Connection. The LG KKT equations provide the raw multiplier relations; the next step completes their transformation into endpoint and interior costate estimates.