Skip to content

Commit

Permalink
Add Y functions
Browse files Browse the repository at this point in the history
  • Loading branch information
thieu1995 committed Sep 26, 2023
1 parent 53dfaa7 commit d16d7d7
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions opfunu/name_based/y_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,54 @@
# Email: [email protected] %
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

import numpy as np
from opfunu.benchmark import Benchmark


class YaoLiu04(Benchmark):
"""
.. [1] Yao X., Liu Y. (1997) Fast evolution strategies. In: Angeline P.J., Reynolds R.G., McDonnell J.R., Eberhart R. (eds)
Evolutionary Programming VI. EP 1997. Lecture Notes in Computer Science, vol 1213. Springer, Berlin, Heidelberg
.. [2] Mishra, S. Global Optimization by Differential Evolution and Particle Swarm Methods: Evaluation
on Some Benchmark Functions. Munich Personal RePEc Archive, 2006, 1005
.. math::
f(x) = {max}_i \left\{ \left | x_i \right | , 1 \leq i \leq n \right\}
Here, :math:`n` represents the number of dimensions and :math:`x_i \in [-10, 10]` for :math:`i = 1, ..., n`.
*Global optimum*: :math:`f(x) = 0` for :math:`x_i = 0` for :math:`i = 1, ..., n`
"""
name = "Yao-Liu 4 Function"
latex_formula = r'f(x) = {max}_i \left\{ \left | x_i \right | , 1 \leq i \leq n \right\}'
latex_formula_dimension = r'd = n'
latex_formula_bounds = r'x_i \in [-10, 10, ..., 10]'
latex_formula_global_optimum = r'f(0, 0, ...,0) = 1.0'
continuous = True
linear = False
convex = True
unimodal = False
separable = True

differentiable = False
scalable = True
randomized_term = False
parametric = False

modality = False # Number of ambiguous peaks, unknown # peaks

def __init__(self, ndim=None, bounds=None):
super().__init__()
self.dim_changeable = True
self.dim_default = 2
self.check_ndim_and_bounds(ndim, bounds, np.array([[-10., 10.] for _ in range(self.dim_default)]))
self.f_global = 0.
self.x_global = np.zeros(self.ndim)

def evaluate(self, x, *args):
self.check_solution(x)
self.n_fe += 1
return np.abs(x).max()

0 comments on commit d16d7d7

Please sign in to comment.