---
# System prepended metadata

title: 常見23種群智能演算法測試函數整理
tags: [群智能演算法]

---

{%hackmd @themes/orangeheart %}
# 常見23種群智能演算法測試函數整理
## 目錄
[TOC]
## 前言
最近在改良演算法，但是套用在工程模型上測試一次就要4個小時才知道結果，沒效果又要再改，然後+4hr，所以就在網路上找一些Benchmark來測試，但是網路上的資源比較零散，所以就寫篇文整理一下。
## Function
## unimodal
### Sphere
![](https://i.imgur.com/9Yym87o.png)
$$
f(x) = \sum\limits_{i = 1}^{30} {\mathop x\nolimits_i^2 } \quad\quad - 100 \le {x_i} \le 100 \\
\ \quad \quad \quad  min (f) = f(0, \ldots ,0) = 0.
$$
### Schwefel’s 2.22
![](https://i.imgur.com/KOBdSUC.png)
$$
f(x) = \sum\limits_{i = 1}^{30} {\left| {\mathop x\nolimits_i^2 } \right|}  + \prod\limits_{i = 1}^{30} {\left| {\mathop x\nolimits_i } \right|}  \quad \quad - 10 \le {x_i} \le 10\\
\quad \quad \quad {\rm{m}}in(f) = f(0, \ldots ,0) = 0.
$$
### Schwefel’s 1.20
![](https://i.imgur.com/0nzf8gG.png)
$$
f(x) = {\sum\limits_{i = 1}^{30} {\left( {\sum\limits_{j = 1}^i {\mathop x\nolimits_j } } \right)} ^2} \quad \quad - 100 \le x_i^{} \le 100\\
\quad \quad \quad\min (f) = f(0, \ldots ,0) = 0.
$$
### Schwefel’s 2.21
![](https://i.imgur.com/yVDAkiN.png)
$$
f(x) = \max \{ \left| {\mathop x\nolimits_i } \right|,1 \le i \le 30\} \quad \quad - 100 \le \mathop x\nolimits_i  \le 100\\
\quad \quad \quad\min (f) = f(0, \ldots ,0) = 0.
$$
### Generalized Rosenbrock
![](https://i.imgur.com/4kmVerw.png)

$$
f(x) = \sum\limits_{i = 1}^{29} {\left[ {100{{\left( {\mathop x\nolimits_{i + 1}  - \mathop x\nolimits_i^2 } \right)}^2}} \right]}\quad \quad  - 30 \le \mathop x\nolimits_i  \le 30\\
\min (f) = f(1, \ldots ,1) = 0.
$$
### Step
![](https://i.imgur.com/c94RZ1N.png)

$$
f(x) = \sum\limits_{i = 1}^{30} {{{\left( {\left\lfloor {\mathop x\nolimits_i  + 0.5} \right\rfloor } \right)}^2}}\quad \quad - 100 \le \mathop x\nolimits_i  \le 100\\
\ \quad \quad \quad min (f) = f(0, \ldots ,0) = 0.
$$
### Quartic Noise
![](https://i.imgur.com/payhYXQ.png)

$$
f(x) = \sum\limits_{i = 1}^{30} {i\mathop x\nolimits_i^4 }  + random\left[ {0,1} \right) \quad \quad - 128 \le \mathop x\nolimits_i  \le 128\\
\ \quad \quad \quad min (f) = f(0, \ldots ,0) = 0.
$$
## multimodal
### Generalized Schwefel's Problem 2.26
![](https://i.imgur.com/SIhOGLG.png)

$$
f(x) =  - \sum\limits_{i = 1}^{30} {\left( {\mathop x\nolimits_i \sin \left( {\sqrt {\left| {\mathop x\nolimits_i } \right|} } \right)} \right)} \quad \quad  - 500 \le \mathop x\nolimits_i  \le 500 \\ \quad \\
\ \quad \quad \quad min (f) = f(420.9687, \ldots ,420.8687) = -12569.5.
$$
### Generalized Rastrigin
![](https://i.imgur.com/HRf208N.png)

$$
f(x) = \sum\limits_{i = 1}^{30} {\left[ {\mathop x\nolimits_i^2  - 10\cos \left( {2\pi \mathop x\nolimits_i } \right) + 10} \right]} \quad \quad - 5.12 \le \mathop x\nolimits_i  \le 5.12\\ \quad
\\ \quad \quad \quad min (f) = f(0, \ldots ,0) = 0.
$$
### Ackley
![](https://i.imgur.com/77v47gj.png)

$$
f(x) =  - 20\exp \left( { - 0.2\sqrt {\frac{1}{{30}}\sum\limits_{i = 1}^{30} {\mathop x\nolimits_i^2 } } } \right) \\- \exp \left( {\frac{1}{{30}}\sum\limits_{i = 1}^{30} {\cos 2\pi \mathop x\nolimits_i } } \right) + 20 + e \\ \quad \\ - 32 \le \mathop x\nolimits_i  \le 32 \quad
\min (f) = f(0, \ldots ,0) = 0.
$$
### Generalized Griewank
![](https://i.imgur.com/0fF39uT.png)

$$
f(x) = \frac{1}{{4000}}\sum\limits_{i = 1}^{30} {\mathop x\nolimits_i^2 }  - \prod\limits_{i = 1}^{30} {\cos \left( {\frac{{\mathop x\nolimits_i }}{{\sqrt i }}} \right) + 1}
\\ \quad \\ - 600 \le \mathop x\nolimits_i  \le 600 \quad
\min (f) = f(0, \ldots ,0) = 0.
$$
### Generalized Penalized 1
![](https://i.imgur.com/bVSNezD.png)

$$
f(x) = \frac{\pi }{{30}}\left\{ {10{{\sin }^2}\left( {\pi \mathop y\nolimits_1 } \right) +  {{\sum\limits_{i = 1}^{29} {{{\left( {\mathop y\nolimits_i  - 1} \right)}^2}\cdot 
  \left[ {1 + 10{{\sin }^2}\left( {\pi \mathop y\nolimits_1  + 1} \right)} \right] + \left( {\mathop y\nolimits_n  - 1} \right)} }^2}} \right\} \\ + \sum\limits_{i = 1}^{30} {u\left( {\mathop x\nolimits_i ,10,100,4} \right)} 
\\
\quad \\ - 50 \le \mathop x\nolimits_i  \le 50 \quad
\min (f) = f(1, \ldots ,1) = 0.
$$
### Generalized Penalized 2
![](https://i.imgur.com/036nmnl.png)

$$
f(x) = 0.1\left\{ {{{\sin }^2}\left( {\pi 3\mathop x\nolimits_1 } \right) + \sum\limits_{i = 1}^{29} {{{\left( {\mathop x\nolimits_i  - 1} \right)}^2}\left[ {1 + {{\sin }^2}\left( {3\pi \mathop x\nolimits_{i + 1} } \right)} \right]} } \right\} \\+ {\left( {\mathop x\nolimits_n  - 1} \right)^2}\left[ {1 + {{\sin }^2}\left( {2\pi \mathop x\nolimits_{30} } \right)} \right]+\sum\limits_{i = 1}^{30} {u\left( {\mathop x\nolimits_i ,5,100,4} \right)}\\
\quad \\ - 50 \le \mathop x\nolimits_i  \le 50 \quad
\min (f) = f(1, \ldots ,1) = 0.
$$

where

$$
u\left( {\mathop x\nolimits_i ,a,k,m} \right) = \left\{ \begin{array}{l}
k{\left( {{x_i} - a} \right)^m},\quad \quad{\rm{   }}\mathop x\nolimits_i  > a\\
0, \quad \quad \quad \quad \quad {\rm{        }} - a \le \mathop x\nolimits_i  \le a\\
k{\left( { - {x_i} - a} \right)^m}\quad \quad {\rm{       }}\mathop x\nolimits_i {\rm{ < }} - a{\rm{ }}
\end{array} \right.
\\
\quad \\
{\mathop y\nolimits_i  = 1 + \frac{1}{4}}\left( {\mathop x\nolimits_i  + 1} \right)
$$
## fixed-dimenstion multimodal
### Shekel’s Foxholes
![](https://i.imgur.com/KpSuNJH.png)

$$
f(x) = {\left[ {\frac{1}{{500}} + \sum\limits_{j = 1}^{25} {\frac{1}{{j + \sum\nolimits_{i = 1}^2 {{{\left( {\mathop x\nolimits_i  - \mathop a\nolimits_{ij} } \right)}^6}} }}} } \right]^{ - 1}}\\ \quad\\- 65.536 \le \mathop x\nolimits_i  \le 65.536 \quad \min \left( f \right) = \left( { - 32,32} \right) \approx 1
$$
where
$$
\left( {\mathop a\nolimits_{ij} } \right)=
\left( \begin{array}{l}-32 \quad-16\quad\quad0\quad\quad\quad16\quad\quad32\quad-32\quad\cdots\quad0\quad16\quad32 \\-32 \quad-32\quad-32\quad-32\quad-32\quad-16\quad\cdots\quad32\quad32\quad32
 \end{array} \right)
$$

### Kowalik
![](https://i.imgur.com/TrpyiOD.png)

$$
f(x) = \sum\limits_{i = 1}^{11} {{{\left[ {\mathop a\nolimits_i  - \frac{{\mathop x\nolimits_{1\left( {\mathop b\nolimits_i^2  + \mathop b\nolimits_i \mathop x\nolimits_2 } \right)} }}{{\mathop b\nolimits_i^2  + \mathop b\nolimits_i \mathop x\nolimits_3  + \mathop x\nolimits_4 }}} \right]}^2}} \quad  - 5 \le \mathop x\nolimits_i  \le 5 \\ \quad \\
\quad \min (f) \approx f\left( {0.1928,0.1908,0.1231,0.1358} \right) \approx 0.0003075
$$
### Six-Hump Camel-Back
![](https://i.imgur.com/geZKVrK.png)

$$
f = 4\mathop x\nolimits_1^2  - 2.1\mathop x\nolimits_1^4  + \frac{1}{3}\mathop x\nolimits_1^6  + \mathop x\nolimits_1 \mathop x\nolimits_2  - 4\mathop x\nolimits_2^2  + 4\mathop x\nolimits_2^4 \\- 5 \le \mathop x\nolimits_i  \le 5\\\mathop x\nolimits_{\min }  = \left( {0.08983, - 0.7126} \right),\left( { - 0.08983,0.7126} \right)\\\min (f) =  - 1.0316285.
$$
### Branin
![](https://i.imgur.com/Ugixn1y.png)

$$
f(x) = {\left( {\mathop x\nolimits_2  - \frac{{5.1}}{{4{\pi ^2}}}\mathop x\nolimits_1^2  + \frac{5}{\pi }\mathop x\nolimits_1  - 6} \right)^2} + 10\left( {1 - \frac{1}{{8\pi }}} \right)\cos \mathop x\nolimits_1  + 10\\
\quad\\ \quad  - 5 \le \mathop x\nolimits_1  \le 10 \quad \quad 0 \le \mathop x\nolimits_1  \le 15\\
{x_{\min }} = \left( { - 3.142,12.275} \right),(3.142,2.275),(9.425,2.425)\\
\min (f) = 0.398.
$$
### Goldstein-Price
![](https://i.imgur.com/rH3aVzd.png)

$$
f(x) = \left[ {1{\rm{ + }}{{\left( {\mathop x\nolimits_1  + \mathop x\nolimits_2  + 1} \right)}^2}\left( {19 - 14\mathop x\nolimits_1  + 3\mathop x\nolimits_1^2  - 14\mathop x\nolimits_2  + 6\mathop x\nolimits_1 \mathop x\nolimits_2  + 3\mathop x\nolimits_2^2 } \right)} \right]\\
 \times \left[ {30 + {{\left( {2\mathop x\nolimits_1  - 3\mathop x\nolimits_2 } \right)}^2} \times \left( {18 - 32\mathop x\nolimits_1  + 12\mathop x\nolimits_1^2  + 48\mathop x\nolimits_2  - 36\mathop x\nolimits_1 \mathop x\nolimits_2  + 27\mathop x\nolimits_2^2 } \right)} \right]\\ - 2 \le \mathop x\nolimits_i  \le 2,\quad \min (f) = f(0, - 1) = 3.
$$
### Hartman Family
![](https://i.imgur.com/pcVqK5j.png)
![](https://i.imgur.com/3mtsNdd.png)
### Shekel Family
![](https://i.imgur.com/MivAOau.png)
![](https://i.imgur.com/g2SORpb.png)
![](https://i.imgur.com/3ytDPGT.png)
