How to run an optimization project using an external function?

Before running an optimization, you have to define your optimization problem and set up the files in MANATEE.

Running the Reference Case

project can be run using MANATEE. To run it, type:

run_MANATEE('OP_001')

The value in the command is the name of the Project File.

The optimization process is now running and can take from a few seconds to several minutes or hours depending on all the parameters. Here, for the tutorial case, the total time of the optimization should be less than a minute depending on the computer. At the end of the optimization process, various plots are displayed. We will focus only on the Pareto front obtained. The result of the optimization is shown in the figure below. It is very close to the theoretical Pareto front described in the introduction. Your results can differ slightly from the one presented in the figure: Genetic Algorithms use random parameters and each run is different. You can notice that all the elements are well distributed along the Pareto front.

200. Optimization results with MANATEE vs theoritical results
Optimization results with MANATEE vs theoritical results

Changing the population and the number of generations

To change the population and the number of generations, simply change the values of npop and ngen in the OIF. After each change, the optimization process can be restarted by using:

run_MANATEE('OP_001')

For example, the Pareto front obtained for only 10 elements in the population is shown in the figure below. The solutions are very close to the optimal Pareto front. However, the number of elements is not enough to describe fully the Pareto front.

200. Optimization Results with 10 individuals
Optimization Results with 10 individuals

The number of generation is important for the convergence to the optimal Pareto front. For example, the figure below shows the results with 100 individuals but only 20 generations.

200. Optimization Results with 20 generations
Optimization Results with 20 generations

The elements are getting close to Pareto front but are still far from the solution. It is important to have enough generations to insure a good convergence.

Adding Constraints

In the following section, the number of elements has been fixed at 100 and the number of generations at 200.
In MANATEE, the constraints are defined as inequalities in the form:

C(X_i,f_i )<0

To add a constraint, its expression must be added in the objective function file. For example, if we want to have a constraint f_2<0.5, we will add in the objective function file:

F{2}=[f2-0.5];

The OIF must also be modified to take into account the new number of constraints:

nbcont = 1;

By using run_MANATEE, we can generate the new Pareto front:

200. Optimization Results with 1 constraint
Optimization Results with 1 constraint

The new Pareto front considers the new constraint: no value of f2 is over 0.5.

To add a second constraint, for example f_1>2f_2, just add a new line in the F{2} vector in the objective function file and increase the number of variables in the OIF:

F{2}=[f2-0.5; 2*f2-f1]
nbcont = 2;

The results should be similar to the figure below:

200. Optimization Results with 2 constraints
Optimization Results with 2 constraints

Variable Outputs

In the workspace, run_MANATEE generates a structure output with the results of the optimization. They can be found in Output.MultSim.Xconf. This matrix has a number of rows equal to the number of elements (npop) and a number of columns equal to the sum of the number of parameters, the number of objectives and the number of constraints.

In this example, the first 10 columns are the Xi values of each optimal point. Columns 11 and 12 are respectively the values of f1 and f2. And, in case of two constraints, their values will be in columns 13 and 14.

After each run, MANATEE saves the complete results in the Results folder. All the variables computed during the optimization are saved in a file whose format is “Date_Time_Project-name.mat”. For example, in this file, you can find the variables “data” which contains every element calculated for each generation.

This article concludes the series of article on how to run an external optimization problem in MANATEE. The next article will focus on how to run an optimization problem on a MANATEE case.

Previous Next