最適化手法を試したいときに使える試行関数覚え書き


# この記事は何？

最適化手法を考えたり、最適化手法を試したい時に使える関数の個人用メモ
[Virtual Library of Simulation Experiments: Test Functions and Datasets](https://www.sfu.ca/~ssurjano/optimization.html) より独断と偏見で選出

描画は[WolframAlphaのonline版](https://www.wolframalpha.com/input/?i=3d+plot)を使用

# お椀型関数

## SPHERE FUNCTION

https://www.sfu.ca/~ssurjano/spheref.html

```math
f(x) = \sum_{i=1}^d x_i^2
```

最小点：$x=(0,0,...,0)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 121928.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/d62b5cfe-a183-c40c-4872-6040d919ff6a.png)

## SUM SQUARES FUNCTION

https://www.sfu.ca/~ssurjano/sumsqu.html

```math
f(x) = \sum_{i=1}^d ix_i^2
```

最小点：$x=(0,0,...,0)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 122015.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/fd9f507f-5bbf-cd47-c62c-7077ad81441e.png)

## SUM OF DIFFERENT POWERS FUNCTION

https://www.sfu.ca/~ssurjano/sumpow.html

```math
f(x) = \sum_{i=1}^d | x_i |^{i+1}
```

最小点：$x=(0,0,...,0)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 122516.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/4eff5434-c17b-db7b-66f8-a4d642491a19.png)

<!--
## ROTATED HYPER-ELLIPSOID FUNCTION

https://www.sfu.ca/~ssurjano/rothyp.html

```math
f(x) = \sum_{i=1}^d \sum_{j=1}^i x_j^2
```
-->

## PERM FUNCTION 0, D, BETA

https://www.sfu.ca/~ssurjano/perm0db.html

```math
f(x) = \sum_{i=1}^d \left( \sum_{j=1}^d (j+\beta)\left(x^i_j - \frac{1}{j^i}\right) \right)^2
```

最小点：$x=(1,1/2,...,1/d)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 123951.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/d71b32f7-601f-e56f-2389-b46a7c86df62.png)

## TRID FUNCTION

https://www.sfu.ca/~ssurjano/trid.html

```math
f(x) = \sum_{i=1}^d (x_i-1)^2 - \sum_{i=2}^d x_i x_{i-1}
```
最小点：$x_i=i(d+1-i)$のとき$f(x)=-d(d+4)(d-1)/6$

![スクリーンショット 2022-09-23 124207.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/4b51339c-74b1-d8ce-8c5e-027a367432b2.png)

# local minimum がいっぱいある関数

## ACKLEY FUNCTION

https://www.sfu.ca/~ssurjano/ackley.html

```math
f(x) = -a \text{exp} \left( -b\sqrt{\frac{1}{d} \sum_{i=1}^d x_i^2} \right) -\text{exp}\left(\frac{1}{d} \sum_{i=1}^d \text{cos}(cx_i) \right) + a + \text{exp}(1)
```

推奨値：$a = 20, b = 0.2, c = 2\pi$

最小点：$x=(0,0,...,0)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 124552.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/45f64010-5265-6c27-3d1a-ae2d6e6df4c0.png)

## GRIEWANK FUNCTION

https://www.sfu.ca/~ssurjano/griewank.html

```math
f(x) = \sum_{i=1}^d \frac{x_i^2}{4000} - \prod_{i=1}^d \text{cos}\left(\frac{x_i}{\sqrt{i}}\right)+1
```

最小点：$x=(0,0,...,0)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 124856.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/b3c561e7-8f27-4a5e-9805-90471bfaaa6c.png)

## LEVY FUNCTION

https://www.sfu.ca/~ssurjano/levy.html

```math
f(x) = \text{sin}^2(\pi \omega_1) + \sum_{i=1}^{d-1}(\omega_i-1)^2(1+10\text{sin}^2(\pi \omega_i+1)) + (w_d-1)^2(1+\text{sin}^2(2\pi\omega_d)) \\
\text{for  } \omega_i = 1 + \frac{x_i-1}{4}
```

最小点：$x=(1,1,...,1)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 130509.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/9360365b-ab4e-1b03-ab4f-cafd7a3ba33b.png)

## RASTRIGIN FUNCTION

https://www.sfu.ca/~ssurjano/rastr.html

```math
f(x) = 10d + \sum_{i=1}^d(x_i^2-10\cos(2\pi x_i)) \
```

最小点：$x=(0,0,...,0)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 130724.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/baf43557-cb44-2348-16a2-b3dbf7acc870.png)

# 板状関数

## ZAKHAROV FUNCTION

https://www.sfu.ca/~ssurjano/zakharov.html

```math
f(x) = \sum_{i=1}^d x_i^2 + \left(\sum_{i=1}^d 0.5ix_i \right)^2 + \left( \sum_{i=1}^d 0.5ix_i \right)^4
```

![スクリーンショット 2022-09-23 130919.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/ce8939ef-82d9-8429-806a-df7b7961638e.png)


# 崖状関数

## DIXON-PRICE FUNCTION

https://www.sfu.ca/~ssurjano/dixonpr.html

```math
f(x) = (x_1-1)^2 + \sum_{i=2}^d i(2x_i^2-x_{i-1})^2
```

最小点：$x=(0,0,...,0)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 131512.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/91ffeef5-ca22-769a-57a0-1de9d9b4d98d.png)

## ROSENBROCK FUNCTION

https://www.sfu.ca/~ssurjano/rosen.html

```math
f(x) = \sum_{i=1}^{d-1} \left( 100(x_{i+1}-x_i^2 )^2 + (x_i-1)^2 \right)
```

最小点：$x=(1,1,...,1)$のとき$f(x)=0$

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/5111a834-2b1d-c0c2-b5a2-de5e43dbcde5.png)
 
# その他

## PERM FUNCTION D, BETA

https://www.sfu.ca/~ssurjano/permdb.html

```math
f(x) = \sum_{i=1}^d \left( \sum_{j=1}^d (j^i+\beta) \left(\left(\frac{x_j}{j}\right)^i-1\right)\right)^2
```

最小：$x=(1,2,...,d)$のとき$f(x)=0$

![スクリーンショット 2022-09-23 132959.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/328786/9d3247df-842f-046a-2778-3474b8b2dbc1.png)