Rastrigin function

Function used as a performance test problem for optimization algorithms
title: "Rastrigin function" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["test-functions-for-optimization"] description: "Function used as a performance test problem for optimization algorithms" topic_path: "general/test-functions-for-optimization" source: "https://en.wikipedia.org/wiki/Rastrigin_function" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Function used as a performance test problem for optimization algorithms ::
| direction = vertical | width = 300 | header = Rastrigin function of two variables | image1 = Rastrigin_function.png | caption1 = In 3D | image2 = Rastrigin-smooth-contour.svg | caption2 = Contour
In mathematical optimization, the Rastrigin function is a non-convex function used as a performance test problem for optimization algorithms. It is a typical example of non-linear multimodal function. It was first proposed in 1974 by Rastrigin as a 2-dimensional function and has been generalized by Rudolph. The generalized version was popularized by Hoffmeister & Bäck and Mühlenbein et al. Finding the minimum of this function is a fairly difficult problem due to its large search space and its large number of local minima.
On an n-dimensional domain it is defined by: : f(\mathbf{x}) = A n + \sum_{i=1}^n \left[x_i^2 - A\cos(2 \pi x_i)\right] where A=10 and x_i\in[-5.12,5.12] . There are many extrema:
- The global minimum is at \mathbf{x} = \mathbf{0} where f(\mathbf{x})=0.
- The maximum function value for x_i\in[-5.12,5.12] is located at \mathbf{x} = (\pm4.52299366..., ..., \pm4.52299366...):
::data[format=table] | Number of dimensions | Maximum value at \pm4.52299366 | |---|---| | 1 | 40.35329019 | | 2 | 80.70658039 | | 3 | 121.0598706 | | 4 | 161.4131608 | | 5 | 201.7664509 | | 6 | 242.1197412 | | 7 | 282.4730314 | | 8 | 322.8263216 | | 9 | 363.1796117 | ::
Here are all the values at 0.5 interval listed for the 2D Rastrigin function with x_i\in[-5.12,5.12] :
::data[format=table]
| f(x) | x_1 |
|---|---|
| 0 | \pm0.5 |
| x_2 | 0 |
| \pm0.5 | 20.25 |
| \pm1 | 1 |
| \pm1.5 | 22.25 |
| \pm2 | 4 |
| \pm2.5 | 26.25 |
| \pm3 | 9 |
| \pm3.5 | 32.25 |
| \pm4 | 16 |
| \pm4.5 | 40.25 |
| \pm5 | 25 |
| \pm5.12 | 28.92 |
| :: |
The abundance of local minima underlines the necessity of a global optimization algorithm when needing to find the global minimum. Local optimization algorithms are likely to get stuck in a local minimum.
Notes
References
- Rastrigin, L. A. "Systems of extremal control." Mir, Moscow (1974).
- G. Rudolph. "Globale Optimierung mit parallelen Evolutionsstrategien". Diplomarbeit. Department of Computer Science, University of Dortmund, July 1990.
- F. Hoffmeister and T. Bäck. "Genetic Algorithms and Evolution Strategies: Similarities and Differences", pages 455–469 in: H.-P. Schwefel and R. Männer (eds.): Parallel Problem Solving from Nature, [[Parallel Problem Solving from Nature. PPSN]] I, Proceedings, Springer, 1991.
- H. Mühlenbein, D. Schomisch and J. Born. "The Parallel Genetic Algorithm as Function Optimizer ". Parallel Computing, 17, pages 619–632, 1991.
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::