The problem was originally presented by .
Consider the following optimal control problem
subject to dynamics constraint
and boundary conditions
We require the numerical solution to fulfill the following accuracy criteria
Despite the simple formulation, the problem is actually extremely difficult to solve using an indirect method. The state and control near the initial and terminal times experience dramatic changes thus requiring very small stepsizes locally for numerical methods.
We can specify the system dynamics in function Hypersensitive_Dynamics_Internal with
For this example problem, we do not have any path constraints, so function Hypersensitive_Dynamics_Internal only need to return the value of variable dx .
Similarly, the (optional) simulation dynamics can be specifed in function Hypersensitive_Dynamics_Sim.m .
First we provide the function handles for system dynamics with
The optional files providing analytic derivatives can be left empty as we demonstrate the use of finite difference this time
and finally the function handle for the settings file is given as.
Next we define the time variables with
For state variables, we need to provide the initial conditions
bounds on intial conditions
bounds on the absolute local and global (integrated) discretization error of state variables
tolerance for state variable box constraint violation
terminal state bounds
and an initial guess of the state trajectory (optional but recommended)
Lastly for control variables, we need to define simple bounds
bounds on the first control action
tolerance for control variable box constraint violation
as well as an initial guess of the input trajectory (optional but recommended)
Since this problem only has a Lagrange (stage) cost , and no Mayer (boundary) cost ,we simply have
for sub-function L_unscaled and E_unscaled respectively.
For this example problem, we do not have additional boundary constraints. Thus we can leave sub-routines b_unscaled as they are.
Now we can fetch the problem and options, solve the resultant NLP, and generate some plots for the solution.
Note the last line of code will generate an open-loop simulation, applying the obtained input trajectory to the dynamics defined in Hypersensitive_Dynamics_Sim.m , using the Matlab builtin ode113 ODE solver with a step size of 0.01.
Using the hp-LGR discretization scheme of ICLOCS2, the following state and input trajectories are obtained under a mesh refinement scheme starting with 1 mesh interval with polynomial order of 8. The computation time with IPOPT (NLP convergence tol set to 1e-09) is about 1 seconds for 4 mesh refinement iterations together, using finite difference derivative calculations on an Intel i7-6700 desktop computer. The final mesh have 43 intervals with polynomial orders ranging from 3 to 8. Subsequent recomputation using the same mesh and warm starting will take on average 0.1 seconds and about 3 iterations.
It is interesting to note that if this problem is to be solved without the mesh refinement scheme using equally spaced mesh, even 1000 grid intervals with the same polynomial order can only bring down the maximum absolute local error to 0.6273, far larger than the required 0.0000001. The computation time in this case is about 15 seconds (14900% higher). This clearly demonstrated the benefit and necessity of mesh refinement .
 A.V. Rao, and K.D. Mease, Eigenvector approximate dichotomic basis method for solving hyper-sensitive optimal control problems, Optimal Control Applications and Methods, 21(1), pp.1-19, 2000.