Direct Collocation with Euler Discretization
The purpose of this section is to move from an abstract description of direct methods to a concrete nonlinear programming formulation. The focus is not on software syntax, but on the mathematical structure that must be created before an NLP solver can be used.
The main topics are:
Euler forward in collocation form;
simultaneous solution of discrete dynamics;
root finding for differential-equation residuals;
transcription of a nonlinear optimal-control problem;
discretization of time, state, control, and cost;
treatment of boundary conditions;
counting variables, constraints, and degrees of freedom; and
interpretation of the resulting nonlinear program.
Euler Forward: Time-Marching and Collocation Forms¶
For the ordinary differential equation
Euler forward gives
This is the time-marching form.
The same equation can be written as a residual:
This is the collocation or defect form.
Mesh and Discrete State Vector¶
Let
with
Define
Collect all state approximations into
The Euler residuals form a nonlinear system:
Initial Conditions as Algebraic Constraints¶
Suppose
where is known.
One may either substitute
directly or add the residual equation
The second form is common in collocation because it keeps all conditions in one residual system.
Newton’s Method for the Global Residual System¶
To solve
consider
Setting this approximation equal to zero gives
Hence,
The Newton iteration is
In implementation, one solves the linear system rather than explicitly forming the inverse.
A Nonlinear Optimal-Control Example¶
Consider
subject to
with
and fixed .
This problem is nonlinear because of the term .
Uniform Time Mesh¶
Choose intervals:
The mesh points are
There are:
intervals;
mesh points.
State and Control Discretization¶
For Euler forward, the state is defined at all mesh points:
The control is required only at the beginning of each interval:
There is no in this transcription because the final node does not begin another interval.
Discrete Dynamics¶
Euler forward gives
The defect equation is
for
Equivalently,
Discretization of the Cost¶
The running cost is
Using a left-rectangle rule consistent with Euler forward,
Therefore,
The original functional has become an ordinary function of finitely many variables.
Boundary Conditions¶
The continuous boundary conditions map to
These are equality constraints in the NLP.
Decision Vector¶
Define the decision vector
The total number of variables is
Complete NLP Formulation¶
The Euler direct-collocation problem is
This is a nonlinear programming problem.
Variables, Constraints, and Degrees of Freedom¶
The number of variables is
The number of equality constraints is
Therefore,
The problem must have degrees of freedom because the optimizer must choose among many feasible trajectories.
Why the System Is Underdetermined Before Optimization¶
The defect equations and boundary conditions alone do not uniquely determine all state and control values.
There are many controls that may approximately transfer the state from to .
The objective selects the one that minimizes
Thus:
the constraints define feasibility;
the objective selects optimality.
Generalization to Multiple States and Controls¶
For
with
Euler forward gives
The number of variables becomes
The number of dynamic constraints becomes
Endpoint and path constraints are added separately.
Forward Versus Backward Euler Indexing¶
Euler forward uses
Backward Euler uses
Hence:
forward Euler naturally uses control values ;
backward Euler naturally uses control values .
The quadrature indexing should be consistent with the dynamic discretization.
Accuracy of the Transcription¶
Euler forward is first-order accurate.
Therefore, the discrete optimal-control solution is expected to converge at first order under appropriate regularity and stability assumptions.
A valid numerical study should compare solutions for:
and monitor:
objective convergence;
state convergence;
control convergence;
defect residuals;
endpoint residuals.
Implementation Workflow¶
Select .
Compute .
Create an initial guess for all states and controls.
Build the objective function.
Build the Euler defect constraints.
Add endpoint constraints.
Supply bounds if needed.
Call an NLP solver.
Reconstruct the trajectories.
Refine the mesh and repeat.
Common Errors¶
Using state points instead of .
Including in an Euler-forward transcription without a reason.
Summing the quadrature from 0 to instead of 0 to .
Forgetting the endpoint constraints.
Counting variables or constraints incorrectly.
Solving the defect equations without including the objective.
Calling the discrete solution exact.
Failing to refine the mesh.
Summary¶
Euler forward can be written as collocation defects.
The state and control values become NLP decision variables.
The running cost becomes a finite quadrature sum.
Endpoint conditions become algebraic constraints.
The resulting finite-dimensional problem is an NLP.
The example contains variables and equality constraints.
The remaining degrees of freedom are optimized through the cost.
Mesh refinement is required to assess accuracy.
Connection. Once collocation has produced an NLP, its usefulness depends on exploiting local dependence, sparse derivatives, and a fixed normalized time interval.