Get Started
Configuration Options: multi-phase problems
This guide will help you configure ICLOCS2 for solving optimal control problems direct collocation method with a multi-phase formulation.
In the setting file of the multi-phase problem
Transcription Method
First we define the transcription methods in
options.transcription='...';
with
- direct_collocation: Direct collocation method
Note: support for integrated residual minimization method for multiphase problem will be added in future updates. For current version of ICLOCS, please use direct collocation for multiphase problems.
Derivative generation
The derivative information can be supplied to ICLOCS2 via a number of different ways by setting
options.derivatives='...';
with
- analytic: For simple problems, analytic differentiation may be used for the best computation speed. When this option is selected, the user must additionally supply the following file containing the derived analytical derivatives
- gradCost.m: The gradient of the cost in analytic form
- jacConst.m: The gradient of the plant model, path constraints and boundary constraints (constraint Jacobian)
- hessianLagrangian.m: The Hessian of the Lagrangian
- numeric: For many practical problems, obtaining analytical derivative expressions can be challenging (for example, when look-up tables are used). For these problems, numerical means of supplying the derivative information may be used. When this option is used in ICLOCS2, the Jacobian information will always be calculated with finite difference approximations. As for the Hessian update, the user may futher specify (in the settings later) whether it should supplied with finite differences in ICLOCS2 or fast Hessian update methods (e.g. BFGS) from the NLP solver. The perturbation sizes for numerical differentiation can be (optionally) defined in options.perturbation.J and options.perturbation.H.
-
adigator: When using finite difference, degradation in accuracy may occur due to numerical errors. One alternative is to
use algorithmic differentiation which is accurate up machine precision. Adigator is a forward-mode algorithmic differentiation toolbox that may be used
for supplying derivative information in ICLOCS2, at a computation cost slightly higher than finite difference. See HERE
for details on obtaining and configuring Adigator. You will need to provide the intallation route of Adigator in
which can be either relative (e.g. '../../adigator') or exact (e.g. 'D:\adigator').
options.adigatorPath='...';
problem.analyticDeriv.gradCost=@gradCost;
problem.analyticDeriv.hessianLagrangian=@hessianLagrangian;
problem.analyticDeriv.jacConst=@jacConst;
NLP solver
Next is to specify the NLP solver
options.NLPsolver='...';
with
- ipopt: The interior-point-method based IPOPT solver (recommanded). You may further specify the solver settings (see IPOPT documentations), here we just detail on a few important ones
- options.ipopt.tol: Desired convergence tolerance (relative).
- options.ipopt.max_iter: The maximum number of iterations.
- options.ipopt.hessian_approximation: Indicates what information for the Hessian of the Lagrangian function is used by the solver. Set it to 'exact' to use second derivatives provided by ICLOCS2 (exact Hessian, finite difference and algorithmic differentiation). Alternatively, set it to 'limited-memory to use the built-in limited memory BFGS update by IPOPT (this is mandatory when multiple shooting method is used).
- fmincon: Use of fmincon is supported but not recommmanded as the solution speed can be significantly slower with a higher chance of failure. Read HERE for further details, otherwise the option will not run!.
- worhp: ICLOCS2 also support the sequential quadratic programming (SQP) solver WORHP up to version 1780 (Later ones do not have Matlab interface). The settings of WORHP solver should be configured with the .xml file in the WORHP package.
Meshing Strategy
For multi-phase problems, ICLOCS 2.5 supports the following options as meshing strategy spcified in
options.meshstrategy='...';
with
- fixed: a fixed mesh
- mesh_refinement: with local refinement of mesh using mesh refinement iterations.
For mesh refinement, it is possible to provide a preference in
options.MRstrategy='...';
with
- aggressive: a relative aggressive scheme that aim to reduce the number of MR iterations and the total MR time
- efficient: a relative aggressive scheme that aim to reduce the size of the problem at the end of MR iterations, making it potentially more efficient for online re-computations.
Other Settings
Hot start
The initial guess of the solving process can be selected by
options.start='...';
with
- Cold: Linear interpolation between the initial point and the final point for the state and input trajectory. No costate/multiplier information supplied.
- Warm: Initial guess of the state and input trajectory interpolated from the solution of previous solve. No costate/multiplier information supplied.
- Hot: Initial guess of the state and input trajectory as well as costate/multipliers interpolated from the solution of previous solve.
Automatic scaling
For problems that contain variables of drastically different numerical ranges (e.g. altitude from 0 to 20000 m but angles only from -6 to 6 rad), automatic scaling is recommanded which may significantly reduce the number of iterations and computation time needed.
options.scaling=1;
In the setting file for each phases
Discretization Method
We can define the discretization methods in
options.discretization='...';
with
- discrete: MPC implementation with discrete time model
- euler: euler discretization
- trapezoidal: trapezoidal discretization
- hermite: Hermite-Simpson discretization
- globalLGR: using a single global LGR polynomial of high orders
- hpLGR: using multiple LGR polynomials of various orders
- AutoDirect: Automatic chosen method for direct collocation
Result Representation
Here, we can specify how will the sampled time solution be represented into continuous time trajectories. This can be done in
options.resultRep='...';
with
-
default: direct reconstrunction in correspondance with the transcription method (see table for details)
-
manual: manually select in the options below. For state trajectory
options.stateRep='...';
- linear: Piecewise linear interpolation, available for Euler transcription method only
- quadratic: Piecewise quadratic interpolation, available for Euler and Trapezoidal transcription methods
- cubic: Piecewise cubic interpolation, available for Hermite-Simpson transcription method only
- pchip: Piecewise Cubic Hermite Interpolating Polynomial with Matlab pchip function, available for all transcription methods
options.inputRep='...';
- constant: Piecewise constant interpolation, available for all transcription methods
- linear: Piecewise linear interpolation, available for all transcription methods
- quadratic: Piecewise quadratic interpolation, available for Hermite-Simpson transcription method only
- pchip: Piecewise Cubic Hermite Interpolating Polynomial with Matlab pchip function, available for all transcription methods
Meshing Strategy
The maximum and minimum time interval (in terms of actual time) alled defined in options.mintimeinterval and options.maxtimeinterval repectively.
The distribution of integration steps for the fixed mesh or the first iteration of mesh refinement can be spcified in
options.tau='...';
with
- options.tau=0: for equispaced steps
- a vector of length M-1 with 0<tau(i)<1 and sum(tau)=1: for a non-uniform mesh.