rastrigin


The Rastrigin function has several local minima. It is highly multimodal, but locations of the minima are regularly distributed [1].

of = rastrigin(x)

Input variables

Name Description Type
x Current design variables of the i agent. List

Output variables

Name Description Type
of Objective function value of the i agent. Float

Problem

\[f(\mathbf{x}) = 10d + \sum_{i=1}^{d} \left [ x_{i}^{2} -10 \cos{(2\pi x_{i})} \right ] \]

(1)

\[ x_{i} \in [-5.12, 5.12], i=1, ... , d; \;...\; f(\mathbf{x}^*) = 0, \; \mathbf{x}^* = (0,...,0) \]

(2)

Example 1

Considering the design variable \(\mathbf{x} = [0,0]\), what value does the objective function expect?

# Data
x = [0, 0]

# Call function
of = rastrigin(x)

# Output details
print("of_best rastrigin: of = {:.4f}".format(of))
of_best rastrigin: of = 0.0000

Reference list