## Installation Guide

Let us help you setup ICLOCS2 and get it working in no time.

### Prerequisite

For proper functioning of ICLOCS2, you will need to have **Mathworks MATLAB** version **2017a or later** installed.

### Configure the NLP Solver

ICLOCS2 will transcrible the optimal control problems into nonlinear programming (NLP) problems. Current version of ICLOCS2 supports the use of IPOPT, fmincon and WORHP for solving the NLP problems.

#### IPOPT

Interior point based solver IPOPT is the prefered solver for ICLOCS2, and can be obtained freely from **HERE** toghether with the MATLAB interface.

Windows users are recommened to install **OPTI Toolbox** which will have IPOPT included.

Another option is to refer to **THIS**
installation guide from ETH to compile the latest version of IPOPT, however note that the document may become outdated and modifications in the steps may be needed.

Also, there are pre-compiled (despite earlier version) IPOPT mex files availble for MATLAB from **HERE**.

Licenced users are recommeded to obtain the **HSL library** for use of the MA57 linear solver.

#### WORHP

WORHP, also referred to as eNLP (European NLP solver) by ESA, is a sequential quadratic programming (SQP) based NLP solver. This proprietary software is available **HERE** and
academic users may be able to obtain a free license. The **matlab** directory containing the MATLAB interface need to be added to MATLAB's path directory (can easily acess throuth the *Set Path* botton).
**Note that many (latest) versions of WORHP no longer include the MATLAB interface and is not supported. **

#### fmincon

ICLOCS2 also support the use the builtin **fmincon** function from MATLAB. However this is not recommonded
because the solution speed can be significantly slower with a higher chance of failure. Therefore, we would recommend to use fmincon only for sanity checks. ** To enable the use of fmincon in ICLOCS2, please adapt the following settings **

`options.NLPsolver='fmincon';`

and add the **configurations** accrodingly. For example,

```
options.fmincon=optimset;
options.fmincon.MaxIter=5000;
options.fmincon.MaxFunEvals=1e08;
options.fmincon.Display='iter';
```

### Install ICLOCS2

Unzip the ICLOCS2 source files into the desired folder, and add the included *src* folder and its all subfolders to MATLAB's path directory (can easily acess throuth the *Set Path* botton).

### Optional Toolboxes

Here are some of the additional toolboxes that may be used together with ICLOCS2 (not mandatory).

#### SUNDIALS (for version 2.0 only)

SUNDIALS is a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. ICLOCS2 utilizes the sensitivity solver CVODES in the direct multiple shooting formulation.
The lastest releases of SUNDIALS does not contain the MATLAB interface anymore, thus it is recommended to download version 2.6.2 from **HERE**
and add folder **sundialsTB** to the MATLAB's path directory (can easily acess throuth the *Set Path* botton).

#### Adigator

Adigator is a toolbox in MATLAB that uses forward mode automatic differentiation to compute the numeric derivatives of user functions. Despite being computationally more expensive than fintie differences, the accuracy will be exact up to machine precision.

**Version 2.0:** For use of Adigator with ICLOCS2 version 2, first download and install the toolbax from **HERE**. Then run *startupadigator.m* in the Adigator directory and select **'adigator'** for *options.derivatives* in the option file for the problem in ICLOCS2. Next is to ensure you supply a standalone dynamic file (e.g. *BangBangPlant.m*) and is correctly referenced in the problem formulation file with *problem.data.plantmodel*. Note that you will need to re-run *startupadigator.m* in the Adigator directory __everytime__ MATLAB has been restarted.

**Version 2.5:** For use of Adigator with ICLOCS2 version 2.5, first download and install the toolbax from **HERE**. Then run *startupadigator.m* in the Adigator directory, and select **'adigator'** for *options.derivatives* in the option file for the problem in ICLOCS2. Ensure you also supply the directory of the file *startupadigator.m* in *options.adigatorPath*.