1
|
|
|
# encoding=utf8 |
2
|
|
|
|
3
|
|
|
"""Implementation of SchumerSteiglitz function.""" |
4
|
|
|
|
5
|
|
|
import math |
6
|
|
|
from NiaPy.benchmarks.benchmark import Benchmark |
7
|
|
|
|
8
|
|
|
__all__ = ['SchumerSteiglitz'] |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class SchumerSteiglitz(Benchmark): |
12
|
|
|
r"""Implementation of Schumer Steiglitz function. |
13
|
|
|
|
14
|
|
|
Date: 2018 |
15
|
|
|
|
16
|
|
|
Author: Lucija Brezočnik |
17
|
|
|
|
18
|
|
|
License: MIT |
19
|
|
|
|
20
|
|
|
Function: **Schumer Steiglitz function** |
21
|
|
|
|
22
|
|
|
:math:`f(\mathbf{x}) = \sum_{i=1}^D x_i^4` |
23
|
|
|
|
24
|
|
|
**Input domain:** |
25
|
|
|
The function can be defined on any input domain but it is usually |
26
|
|
|
evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. |
27
|
|
|
|
28
|
|
|
**Global minimum** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` |
29
|
|
|
|
30
|
|
|
LaTeX formats: |
31
|
|
|
Inline: |
32
|
|
|
$f(\mathbf{x}) = \sum_{i=1}^D x_i^4$ |
33
|
|
|
|
34
|
|
|
Equation: |
35
|
|
|
\begin{equation} f(\mathbf{x}) = \sum_{i=1}^D x_i^4 \end{equation} |
36
|
|
|
|
37
|
|
|
Domain: |
38
|
|
|
$-100 \leq x_i \leq 100$ |
39
|
|
|
|
40
|
|
|
Reference paper: |
41
|
|
|
Jamil, M., and Yang, X. S. (2013). |
42
|
|
|
A literature survey of benchmark functions for global optimisation problems. |
43
|
|
|
International Journal of Mathematical Modelling and Numerical Optimisation, |
44
|
|
|
4(2), 150-194. |
45
|
|
|
""" |
46
|
|
|
Name = ['SchumerSteiglitz'] |
47
|
|
|
|
48
|
|
|
def __init__(self, Lower=-100.0, Upper=100.0): |
49
|
|
|
r"""Initialize of Schumer Steiglitz benchmark. |
50
|
|
|
|
51
|
|
|
Args: |
52
|
|
|
Lower (Optional[float]): Lower bound of problem. |
53
|
|
|
Upper (Optional[float]): Upper bound of problem. |
54
|
|
|
|
55
|
|
|
See Also: |
56
|
|
|
:func:`NiaPy.benchmarks.Benchmark.__init__` |
57
|
|
|
""" |
58
|
|
|
Benchmark.__init__(self, Lower, Upper) |
59
|
|
|
|
60
|
|
|
@staticmethod |
61
|
|
|
def latex_code(): |
62
|
|
|
r"""Return the latex code of the problem. |
63
|
|
|
|
64
|
|
|
Returns: |
65
|
|
|
str: Latex code |
66
|
|
|
""" |
67
|
|
|
return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^4$''' |
68
|
|
|
|
69
|
|
|
def function(self): |
70
|
|
|
r"""Return benchmark evaluation function. |
71
|
|
|
|
72
|
|
|
Returns: |
73
|
|
|
Callable[[int, Union[int, float, List[int, float], numpy.ndarray]], float]: Fitness function |
74
|
|
|
""" |
75
|
|
|
def evaluate(D, sol): |
76
|
|
|
r"""Fitness function. |
77
|
|
|
|
78
|
|
|
Args: |
79
|
|
|
D (int): Dimensionality of the problem |
80
|
|
|
sol (Union[int, float, List[int, float], numpy.ndarray]): Solution to check. |
81
|
|
|
|
82
|
|
|
Returns: |
83
|
|
|
float: Fitness value for the solution. |
84
|
|
|
""" |
85
|
|
|
val = 0.0 |
86
|
|
|
|
87
|
|
|
for i in range(D): |
88
|
|
|
val += math.pow(sol[i], 4) |
89
|
|
|
|
90
|
|
|
return val |
91
|
|
|
|
92
|
|
|
return evaluate |
93
|
|
|
|