Source code for opfunu.name_based.i_func

#!/usr/bin/env python
# Created by "Thieu" at 18:46, 22/07/2022 ----------%                                                                               
#       Email: nguyenthieu2102@gmail.com            %                                                    
#       Github: https://github.com/thieu1995        %                         
# --------------------------------------------------%

import numpy as np
from opfunu.benchmark import Benchmark


[docs]class Infinity(Benchmark): """ .. [1] Jamil, M. & Yang, X.-S. A Literature Survey of Benchmark Functions For Global Optimization Problems Int. Journal of Mathematical Modelling and Numerical Optimisation, 2013, 4, 150-194. """ name = "Hansen Function" latex_formula = r'f(x) = \sum_{i=1}^{n} x_i^{6} \left [ \sin\left ( \frac{1}{x_i} \right ) + 2 \right ]' latex_formula_dimension = r'd \in N^+' latex_formula_bounds = r'x_i \in [-1, 1], \forall i \in \llbracket 1, d\rrbracket' latex_formula_global_optimum = r'f(0,..,0) = 0' continuous = True linear = False convex = True unimodal = False separable = True differentiable = True 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([[-1., 1.] for _ in range(self.dim_default)])) self.f_global = 0. self.x_global = 1e-16 * np.zeros(self.ndim)
[docs] def evaluate(self, x, *args): self.check_solution(x) self.n_fe += 1 return np.sum(x ** 6.0 * (np.sin(1.0 / (x + self.epsilon)) + 2.0))