# How to optimize an electrical machine using MANATEE? Part 2 - Running the Optimization and Analyzing the results

This is the part 2 of the tutorial on How to optimize an electrical machine using MANATEE? You can find the part 1 here.

### Running the simulation

The default OIF uses a population of 40 elements and 30 generations. You can change these settings by modifying the values npop and ngen. All the files being ready, the optimization can start by using:

`run_MANATEE('demo_optim')`

Depending on your machine, the optimization process should take less than 5 min. For each generation, MANATEE displays the stats of the current population. For example:

```9/30 generations completed: best fitnesses: 54.13629     -126.6751 worst fitnesses: 63.0038     -115.4187 Pareto front deviation: 29.9999, 674.2363 feasible individuals: 40/40 min / avg / max of geometrical constraints: -0.26508 / -0.084275 / -0.00023002 min / avg / max of design constraints: -0.0029403 / -0.001226 / -0.00050563 maximum design constraints: -0.00050563 minimum design constraints: -0.0029403```

Here we can see that the best fitness for each objective is 54.1 dB and 126.6 N.m. The worst values for both objectives are 63 dB and 115.4 N.m. We can also see that all the individuals respect our constraints. All the population is feasible and all the values of constraints are negative.

### Analyzing the results

When the optimization process is over, all the post-processing plots are displayed. We will focus here only on a couple of them.

First the Pareto front of the optimal configurations can be displayed. It should be similar to the figure below. The figures can be slightly different: the Genetic Algorithm is a stochastic method using random numbers. The Pareto front is divided in two parts. The first half correspond to low noise machine and low torque. The second half has higher sound level and a better torque. A discontinuity seems to appear in the middle of the front.

2D Pareto Front

To investigate the discontinuity, the plot showing the evolution of parameters along the generations can be examined (in the figure below). All the parameters started well distributed when the optimization started. In the end, two groups appear corresponding most likely to the two parts of the Pareto front. At generation 30, only two numbers of slots in the rotor exist: 24 or 26.

Evolution of the design variables

To investigate further the discontinuity, the variable Output.MultSim.Xconf can be open. This the variable containing all the optimization results. The first two columns are the values of the parameters. The third and the fourth columns correspond to the two objectives. The rest of the columns are the values of the design and geometric constraints for each element. By analyzing the data, we can see that the configurations with 24 slots are the ones with low torque and low noise levels. The configurations with 26 slots are the ones with higher torque and higher noise levels. These results show the importance of number of slots in the rotor and its impact on the noise and the performances of the machine.

To further explore the results, one can also use MANATEE’s 5D visualization tool.