Get Started

Configuration Options: hp methods

This guide will help you configure ICLOCS2 for solving optimal control problems with variable order pseudo spectral (p/hp-typed: Legendre-Gauss-Radau) direct collocation method.


Transcription and Discretization Methods

First we define the transcription and discretization methods in

options.transcription='...';

with

  • globalLGR: using a single global LGR polynomial of high orders
  • hpLGR: using multiple LGR polynomials of various orders

Result Representation

Next, we can specify how will the sampled time solution be constructed into continuous time trajectories. This can be done in

options.resultRep='...';

with

  • default: as recommanded.
  • direct: direct reconstrunction in correspondance with the transcription method
  • manual: manually select in the options below. For state trajectory
    options.stateRep='...';
    • Barycentric: Represent by barycentric Lagrange interpolation
    • Legendre: Represent by Legnedre polynomial fitting
    • pchip: Piecewise Cubic Hermite Interpolating Polynomial with Matlab pchip function
    For input trajectory
    options.inputRep='...';
    • constant: Piecewise constant interpolation
    • linear: Piecewise linear interpolation
    • Barycentric: Represent by barycentric Lagrange interpolation
    • Legendre: Represent by Legnedre polynomial fitting
    • pchip: Piecewise Cubic Hermite Interpolating Polynomial with Matlab pchip function

Derivative generation

The derivative information can be supplied to ICLOCS2 via a number of different ways by setting

options.resultRep='...';

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.
  • 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.

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.
  • worhp: ICLOCS2 also support the sequential quadratic programming (SQP) solver WORHP. The settings of WORHP solver should be configured with the .xml file in the WORHP package.

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;

Alternative ordering of LGR method

By default, when using LGR collocation, the same variables of different time instances are grouped together. Alternatively, one may group different variables at the same time instance together leading to a different sparsity pattern. Although sparse NLP solvers such as IPOPT can exploit the sparsity patterns of the Jacobian and Hessian matrices for both formulations, it has been observed that the computational cost may not always be the same. Thus in ICLOCS2, we also allow the user to use the alternative formulation by setting

options.reorderLGR=1;

Flexible hp mesh

In many problems, time-optimal solutions exhibit a discontinuity, often in the form of a "bang-bang" input. With the new flexible mesh method in ICLOCS2, the placement of intervals can be automatically adjusted during the optimization process to accommodate this discontinuity. To use the flexible mesh, set

options.adaptseg=1;

Constraint on mesh interval sizes

Here you can define the minimum mesh interval size (in terms of actual time) that will be allowed for the flexible mesh or the mesh refinement process, and the maximum mesh size allowed for the flexible mesh.

options.mintimeinterval=...; 
options.maxtimeinterval=...;