1
|
|
|
# encoding=utf8 |
2
|
|
|
|
3
|
|
|
"""Implementations of High Conditioned Elliptic functions.""" |
4
|
|
|
|
5
|
|
|
from NiaPy.benchmarks.benchmark import Benchmark |
6
|
|
|
|
7
|
|
|
__all__ = ['Elliptic'] |
8
|
|
|
|
9
|
|
View Code Duplication |
class Elliptic(Benchmark): |
|
|
|
|
10
|
|
|
r"""Implementations of High Conditioned Elliptic functions. |
11
|
|
|
|
12
|
|
|
Date: 2018 |
13
|
|
|
|
14
|
|
|
Author: Klemen Berkovič |
15
|
|
|
|
16
|
|
|
License: MIT |
17
|
|
|
|
18
|
|
|
Function: |
19
|
|
|
**High Conditioned Elliptic Function** |
20
|
|
|
|
21
|
|
|
:math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` |
22
|
|
|
|
23
|
|
|
**Input domain:** |
24
|
|
|
The function can be defined on any input domain but it is usually |
25
|
|
|
evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. |
26
|
|
|
|
27
|
|
|
**Global minimum:** |
28
|
|
|
:math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` |
29
|
|
|
|
30
|
|
|
LaTeX formats: |
31
|
|
|
Inline: |
32
|
|
|
$f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$ |
33
|
|
|
|
34
|
|
|
Equation: |
35
|
|
|
\begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2 \end{equation} |
36
|
|
|
|
37
|
|
|
Domain: |
38
|
|
|
$-100 \leq x_i \leq 100$ |
39
|
|
|
|
40
|
|
|
Reference: |
41
|
|
|
http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf |
42
|
|
|
""" |
43
|
|
|
Name = ['Elliptic'] |
44
|
|
|
|
45
|
|
|
def __init__(self, Lower=-100.0, Upper=100.0): |
46
|
|
|
r"""Initialize of High Conditioned Elliptic benchmark. |
47
|
|
|
|
48
|
|
|
Args: |
49
|
|
|
Lower (Optional[float]): Lower bound of problem. |
50
|
|
|
Upper (Optional[float]): Upper bound of problem. |
51
|
|
|
|
52
|
|
|
See Also: |
53
|
|
|
:func:`NiaPy.benchmarks.Benchmark.__init__` |
54
|
|
|
""" |
55
|
|
|
Benchmark.__init__(self, Lower, Upper) |
56
|
|
|
|
57
|
|
|
@staticmethod |
58
|
|
|
def latex_code(): |
59
|
|
|
r"""Return the latex code of the problem. |
60
|
|
|
|
61
|
|
|
Returns: |
62
|
|
|
str: Latex code |
63
|
|
|
""" |
64
|
|
|
return r'''$f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$''' |
65
|
|
|
|
66
|
|
|
def function(self): |
67
|
|
|
r"""Return benchmark evaluation function. |
68
|
|
|
|
69
|
|
|
Returns: |
70
|
|
|
Callable[[int, Union[int, float, List[int, float], numpy.ndarray]], float]: Fitness function |
71
|
|
|
""" |
72
|
|
|
def evaluate(D, sol): |
73
|
|
|
r"""Fitness function. |
74
|
|
|
|
75
|
|
|
Args: |
76
|
|
|
D (int): Dimensionality of the problem |
77
|
|
|
sol (Union[int, float, List[int, float], numpy.ndarray]): Solution to check. |
78
|
|
|
|
79
|
|
|
Returns: |
80
|
|
|
float: Fitness value for the solution. |
81
|
|
|
""" |
82
|
|
|
val = 0.0 |
83
|
|
|
for i in range(D): val += (10 ** 6) ** (i / (D - 1)) * sol[i] |
84
|
|
|
return val |
85
|
|
|
return evaluate |
86
|
|
|
|
87
|
|
|
# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 |
88
|
|
|
|