# Genetic Algorithm (GA)

Genetic algorithm (GA) optimisers are robust, stochastic search methods modelled on the Darvinian principles and concepts of natural selection and evolution. Like the particle swarm optimisation (PSO) method, GA’s are classified as global optimisers. Feko employs a real genetic algorithm (RGA).

GA optimisation borrows from the natural world in a number of ways. Conceptually, during a GA optimisation, a set of trial solutions (a generation) is chosen. This generation is assigned the role of “parents”, from which a new generation of “children” are derived. In an evolutionary “survival-of-the-fittest process”, each consecutive generation moves toward an optimal solution under the selective pressure of the fitness/goal function criteria.

## Population size and number of iterations

As a default, the generation size for the GA method is set to 20 and the maximum number of iterations to 50, resulting in a maximum allowed number of Feko solver runs of 1000.

If the user specifies the maximum number of solver runs (), this needs to be converted into a generation size () and number of iterations (), with A*B C. A is selected as a function of the number of parameters in the optimisation problem (Np), with an internal upper limit. It is also internally required that B be chosen such that B 5.

## Error treatment and termination

The GA algorithm terminates naturally when:
• The maximum number of Feko solver runs has been reached
• The standard deviation between the current generation chromosomes is small enough
• The optimisation goal has been reached

Failure during re-evaluation and meshing (in the CADFEKO batch meshing tool or in PREFEKO) for a specific set of parameters is treated by writing an appropriate error message to the .log file before computing a new random parameter set to replace the failed one. Due to the nature of the technique, the parameters naturally adhere to boundaries defined in the parameter space.

## The text log of the GA method

During an optimisation, OPTFEKO maintains a text log of the optimisation process in the project .log file. The structure of this file is primarily determined by the optimisation method.

Section 1: General information regarding the optimisation setup.

=========================  L O G - FILE - OPTFEKO  =========================

Version: 13.22 of 2007-05-08
Date: 2007-06-06 16:32:51
File: test

OPTIMISATION WITH Feko

=============== Optimisation variables ===============

No.  Name                                  Beg.value          Minimum          Maximum
1 zf0                              2.000000000e+00  1.000000000e+00  1.000000000e+01

=============== Optimisation goals ===============

No.  Name                            Expression
1 search1.goals.farfieldgoal1     farfieldgoal1
Section 2: Information regarding the GA method parameters.
=============== Optimisation method: RGA ===============

Maximum number of iterations:                             3
Population size:                                          1
Creep mutation with probability:            5.000000000e-01
Elitism, i.e. best individual replicated into next generation
Enforce niching
Uniform crossover with probability:         5.000000000e-01
Termination at standard deviation:          1.000000000e-04
Pseudorandom number generator seed:                       1\
Section 3: Information regarding the parameter values, goal values and GA aims at each iteration.
=============== RGA: Intermediate results ===============

No.  zf0              search1.goals.f  global goal      global best aim
1  2.000000000e+00  2.267123373e-01  7.732876627e-01  7.732876627e-01
2  1.357202892e+00  2.267123373e-01  7.732876627e-01
3  1.095988516e+00  2.267123373e-01  7.732876627e-01
Section 4: Information regarding the termination reason and optimisation results. If sufficient information was available for a sensitivity analysis to be completed, the results of the sensitivity analysis are also given.
=============== RGA: Finished ===============

Optimisation finished (Maximum number of analyses reached: 3)

Optimum found for these parameters:
zf0                            =   2.000000000e+00

Optimum aim function value (at no. 1):   7.732876627e-01
No. of the last analysis: 3

Sensitivity of optimum value with respect to each optimisation parameter,
i.e. the gradient of the aim function at 1% variation from the optimum:
Parameter                          Sensitivity
zf0                              8.344260771e-01