# Convergence

Convergence criteria can be specified for each optimization algorithm by setting `metrics`

parameter with an array of `ConvergenceMetric`

`-derived objects, e.g.

`Evolutionary.optimize( f, x0, CMAES(metrics=[Evolutionary.AbsDiff(1e-5)]) )`

Use `Evolutionary.converged(result)`

to check convergence of the optimization algorithm. It is possible to access a minimizer using `Evolutionary.minimizer(result)`

even if all convergence flags are `false`

. This means that the user has to be a bit careful when using the output from the solvers. It is advised to include checks for convergence if the minimizer or minimum is used to carry out further calculations.

## Convergence Metrics

`Evolutionary.AbsDiff`

— TypeAbsolute difference convergence for single objective optimization.

This convergence metric allows to estimate an absolute difference between consecutive states of the optimization algorithm, and triggers convergence when,

`|f(x) - f(x')| < ε`

where `ε`

is a tolerance value, `x`

and `x'`

are previous and current minimizers found by the optimization algorithm.

`Evolutionary.RelDiff`

— TypeRelative difference convergence metric for single objective optimization.

This convergence metric allows to estimate a relative difference between consecutive states of the optimization algorithm, and triggers convergence when,

`|f(x) - f(x')|/|f(x')| < ε`

where `ε`

is a tolerance value, `x`

and `x'`

are previous and current minimizers found by the optimization algorithm.

`Evolutionary.GD`

— Type(Inverse) generational distance convergence metric for multi-objective optimization.

This convergence metric allows to estimate a (inverse) generational distance between consecutive states of the multi-objective optimization algorithm, and triggers convergence when,

- $GD(S,R) = \frac{1}{|S|}\left(\sum_{s \in S} \min_{r \in R}||f(s) - f(r)||^2\right)^{1/2} < \varepsilon$

where `ε`

is a tolerance value, `S`

and `R`

are discrete Pareto front approximations for previous and current state of the optimization algorithm.

The inverse generational distance calculated as `IGD(S,R) = GR(R,S)`

. To use, `IGD`

metric pass `true`

value to the metric constructor argument, e.g.

`GD()`

create a generational distance metric`GD(true)`

create an inverse generational metric

## Auxiliary Functions

`Evolutionary.gd`

— Function`gd(A,R)`

Calculate a generational distance between set `A`

and the reference set `R`

. This metric measures the convergence, i.e. closeness of the non-dominated solutions to the Pareto front, of a population.

*Note:* Parameters are column-major matrices.

`Evolutionary.igd`

— Function`igd(S,R)`

Calculate an inverted generational distance, `gd`

, between set `S`

and the reference set `R`

. Parameters are column-major matrices.

`Evolutionary.spread`

— Function`spread(S,R)`

Returns a diversity metric of a population of set `S`

to the reference set `R`

.