pymoo
Latest Version: pymoo==0.4.1

RastriginΒΆ

The Rastrigin function has several local minima. It is highly multimodal, but locations of the minima are regularly distributed. It is shown in the plot above in its two-dimensional form.

Definition

\begin{align} \begin{split} f(x) &=& 10n + \sum\limits_{i=1}^n {[x_i^2 - 10 \cos{(2 \pi x_i)}]} \\[2mm] && -5.12 \leq x_i \leq 5.12 \quad i=1,\ldots,n \end{split} \end{align}

Optimum

\[f(x^*) = 0 \; \text{at} \; x^* = (0,\ldots,0)\]

Contour

[1]:
import numpy as np
from pymoo.factory import get_problem, get_visualization

problem = get_problem("rastrigin", n_var=2)
get_visualization("fitness-landscape", problem, angle=(45, 45), _type="surface").show()
get_visualization("fitness-landscape", problem, _type="contour", colorbar=True).show()
../../_images/problems_single_rastrigin_7_0.png
../../_images/problems_single_rastrigin_7_1.png
[ ]: