To set up an external optimization problem in MANATEE, three files are required:

- The MANATEE project file, in this tutorial, the project is
*OP_001.m* - An Optimization problem file, in this tutorial, the input file is
*OP_001_prob.m* - The file containing the objective function, in this tutorial, the objective function is in
*objfunc_ZDT1.m*

For each file, a description of the inputs will be presented below. The values of the parameters will be those of the demo project. To build a new project, it is recommended to use the demo project as a basis.

### The Project File

The Project File is necessary to run any MANATEE case. For external optimization, the project files are very simple: only the fields related to optimization are required. You can see the structure of the project by opening *OP_001.m*. The different parameters will be examined here.

`Input.Simu.names_var={'X1';'X2';'X3';'X4';'X5';'X6';'X7';'X8';'X9';'X10'};`

**names_var ** is a cell containing all the variable names. Here, we have 10 variables named X1 to X10.

`Input.Simu.types_var=zeros(1,10);`

Input.Simu.types_val=zeros(1,10);

**types_var** and **types_val** are two vectors describing the nature of the variables (discrete or continuous) and their values (are they set or in an interval?). Here, we only have continuous values in intervals. Thus, the values for each ten variables are 0.

`Input.Simu.bds_contvar={[0 1];[0 1];[0 1];[0 1];[0 1];[0 1];[0 1];[0 1];[0 1];[0 1]};`

**bds_contvar** is an array defining all the boundaries for each variable. Here, each variable is taken in the interval [0, 1].

`Input.Simu.names_resp={'ZDT1 f1';'ZDT1 f2'};`

**names_resp** is an array containing the names of the different objectives. Here, we have two objectives corresponding to the two outputs of the ZDT1 function.

`Input.Simu.type_optim = 1;`

**type_optim** allows to choose which type of optimization algorithm is used. Three different methods exist in MANATEE:

- Genetic Algorithm NSGA-2
- Local search algorithm
- Hybrid version using both methods

Here, we are using the NSGA-2.

`Input.Simu.opt_name = 'OP_001_prob';`

**opt_name ** is the Optimization Inputs File name containing the different optimization inputs.

### Optimization Inputs File

The Optimization Inputs File (OIF) is specific to the optimization cases. It contains the different parameters used for the optimization. In this tutorial, the OIF is OP_001_prob.m. It is divided in two parts: the basic parameters and the advanced parameters. The basic parameters should be modified for each new case. The advanced parameters are here for more advanced users and will not be discussed in this tutorial.

The Basic Parameters are grouped in several categories which will be described below. They are stored in the **Input.Simu.Opt** structure in the workspace.

* Objective function *

The three parameters are essential for the optimization project: they define the objective function of the problem.

`Input.Simu.Opt.is_external_opt = 1;`

This line defines if the project is external. Here, we use an external function. If the value was 0, the objective function would be extracted from MANATEE results.

`Input.Simu.Opt.fileobjname='objfunc_ZDT1';`

This line defines the file where the objective function is located. More details on how this file is built are given in next section.

`Input.Simu.Opt.type_fobj=3; `

This line defines the type of objective:

- Single scalar
- Aggregate multiple-objective function
- Vector for an independent multi-objective function

Here, the choice is 3, since the problem has two different objectives.

* Outputs *

`Input.Simu.Opt.is_plot = 1;`

Input.Simu.Opt.is_com = 1;

The two parameters in this section determines the graphical outputs of the optimization.

If *is_plot* is on (equals to 1), plots post-processing the optimization results will be shown.

If *is_com* is on (equals to 1), comments will be displayed in the Matlab prompt during optimization.

`Input.Simu.Opt.type_plots={'plot_OP_pareto_front2';};`

This parameter allows to choose the plots displayed at the end of optimization. Here, the *plot_OP_pareto_front2* has been chosen, displaying the 2D pareto front.

* Constraints *

`Input.Simu.Opt.nbcont = 0; `

This variable defines the number of constraints. Here, we have no constraint.

* Normalization of objectives *

`Input.Simu.Opt.is_autonorm=0;`

Input.Simu.Opt.normfact=[1 1];

These lines define how the objectives are normalized and weighted. If is_autonorm is on, MANATEE will automatically normalize the objectives. If it is off, the normalization factors will be defined in normfact. Here, we don’t need a particular normalization, the factors are set at 1.

`Input.Simu.Opt.weighfact=[1 1];`

The weights defined in weighfact are used in case of an aggregate objective functions. Each weight factor will be affected to an objective. If the weights have the same value, all the objectives have an equal importance.

* Algorithms Parameters *

`Input.Simu.Opt.npop = 100;`

Input.Simu.Opt.ngen = 200;

These two parameters define two key elements for a Genetic Algorithm: the number of elements in the population and the number of generations. The rule of thumb for the number of elements is to take ten times the number of parameters. The number of generations can be increased or decreased depending on the complexity of the problem and the computational resources.

`Input.Simu.Opt.x0=[];`

This parameter is the starting point in case of a local search. Here, as we are using NSGA-2, it is not needed.

### Objective Function File

The Objective Function File has the form of a Matlab function. Its input is a vector **X** of all the variables. Its output is a structure **F. F{1}** contains the vector of all the objectives and **F{2}** contains the vector of all the constraints.
In this tutorial, the objective function file is *objfunc_ZDT1.m*. The vector **X** can have any size as the ZDT1 function is defined for any number of elements. The objectives and are defined by analytical expressions. Here, **F{2}** is empty as we don’t have any constraint.

Now, that the files are ready, the optimization process can be run.