Exercises
LG nonlinear-programming Lagrangian and KKT equations
Consider the simplified Mayer problem on ,
subject to
Use Legendre–Gauss points, the noncollocated initial state , the collocated states , and the recovered terminal state .
(a) Write the LG defect equations.
(b) Write the terminal quadrature equation.
(c) Introduce KKT multipliers for the defect equations, terminal quadrature equation, and initial condition.
(d) Write the complete NLP Lagrangian using explicit summations.
(e) Differentiate with respect to , , , and the multiplier of the initial condition.
(f) Identify the discrete equations corresponding to continuous control stationarity, costate dynamics, terminal transversality, and initial feasibility.
LG costate mapping
Let denote the multipliers of the LG defect equations and let denote the multiplier of the terminal quadrature equation.
Starting from the LG KKT equations, derive
and
(a) State the dimensions of every matrix and vector.
(b) Explain why the terminal quadrature multiplier appears in every interior costate value.
(c) Show that the mapped multipliers satisfy the discrete terminal transversality condition.
(d) Explain how the initial costate estimate can be checked against the multiplier of the initial condition.
LGR KKT equations and interior costate mapping
Consider a left-LGR transcription with collocation points and the noncollocated terminal state .
The defect equations are written using the convention
(a) Write the NLP Lagrangian for the simplified Mayer problem.
(b) Differentiate with respect to each control vector .
(c) Differentiate with respect to the interior state vectors , .
(d) Show that the control KKT condition can be written as
(e) Derive the interior costate mapping
(f) Explain why this mapping is algebraically simpler than the LG mapping.
LGR endpoint costates
For the same LGR transcription, let
(a) Differentiate the NLP Lagrangian with respect to .
(b) Derive
(c) Conclude that the terminal costate estimate is
(d) Derive the KKT equation associated with .
(e) Show how the initial-condition multiplier provides the consistency check
LGL discrete adjoint system
Let be the LGL differentiation matrix and
Define
(a) Starting from the LGL KKT equations, derive the off-diagonal entries of the adjoint differentiation matrix
(b) Derive the modified endpoint diagonal entries.
(c) Show that the compact discrete adjoint equation is
(d) Explain why the two endpoint residuals remain coupled to the LGL costate dynamics.
(e) Relate this coupling to the singularity of the LGL differentiation matrix.
Comparison of LG, LGR, and LGL costate recovery
Construct a comparison for the three Legendre pseudospectral schemes.
For each method, determine:
(a) which endpoints are collocation points;
(b) whether a terminal quadrature equation is required;
(c) the mapping from defect multipliers to interior costates;
(d) the formula for the initial costate;
(e) the formula for the terminal costate;
(f) whether endpoint transversality residuals are decoupled from or coupled to the discrete costate dynamics;
(g) whether a full-rank square submatrix of the state differentiation matrix exists;
(h) which method has the simplest multiplier-to-costate mapping.
Then explain why accurate state and control trajectories do not automatically imply accurate recovered costates.
General LGR Bolza transcription
Consider
subject to
endpoint constraints
and path bounds
(a) Derive the affine map from to .
(b) Derive
(c) Derive the LGR quadrature approximation of the running cost.
(d) Write the LGR defect matrix.
(e) Write the discrete endpoint constraints.
(f) State precisely where the path constraints are imposed.
(g) Identify every expression in which a free appears.
(h) Assemble the complete finite-dimensional NLP.
Solver-ready decision vector and constraint assembly
Consider an LGR transcription with collocation points, states, controls, and free final time.
(a) Define one decision vector containing all state values, control values, and .
(b) Derive its total dimension.
(c) Give explicit reshape operations that recover the state and control arrays.
(d) Write the defect matrix for the linear dynamics
(e) Show how to vectorize the defect matrix into one column vector.
(f) Add endpoint constraints and two-sided path constraints.
(g) Write the complete equality- and inequality-constraint vectors passed to an NLP solver.
(h) Explain how the ordering of constraint blocks determines the interpretation of the returned KKT multipliers.
Sign conventions and multiplier recovery
Suppose one implementation uses
while another uses
(a) Write the NLP Lagrangian under each convention.
(b) Show how the defect multipliers are related.
(c) Determine how the recovered costates are affected if the same mapping formula is used without correcting the sign.
(d) Derive a practical sign check using the terminal transversality condition.
(e) Derive a second sign check using the control-stationarity residual.
(f) Explain why the exact solver convention must be documented before interpreting multiplier values physically.
Primal and dual verification study
Use an LGR transcription for
subject to
with fixed .
(a) Write the complete LGR NLP.
(b) Recover the interior and terminal costates from the KKT multipliers.
(c) Compute the maximum dynamic-defect residual.
(d) Compute the maximum control-stationarity residual.
(e) Compute the maximum discrete-adjoint residual.
(f) Check the terminal transversality residual.
(g) Check the initial-costate consistency residual.
(h) Repeat the solution for increasing polynomial order.
(i) Compare convergence of the state, control, objective, and costate.
(j) Explain how primal convergence can occur before dual convergence.