GithubHelp home page GithubHelp logo

thieu1995 / opfunu Goto Github PK

View Code? Open in Web Editor NEW
112.0 3.0 39.0 20.68 MB

A collection of Benchmark functions for numerical optimization problems

Home Page: https://opfunu.readthedocs.io

License: GNU General Public License v3.0

Python 100.00%
benchmark-functions soft-computing global-optimization convex-optimization non-convex-optimization unimodal-functions multimodal-functions cec-2014 cec-2017 cec-2019

opfunu's Introduction

OPFUNU


GitHub release Wheel PyPI version PyPI - Python Version PyPI - Status PyPI - Downloads Downloads Tests & Publishes to PyPI GitHub Release Date Documentation Status Chat Average time to resolve an issue Percentage of issues still open GitHub contributors GitTutorial DOI License: GPL v3

OPFUNU (OPtimization benchmark FUnctions in NUmpy) is the largest python library for cutting-edge numerical optimization benchmark functions. Contains all CEC competition functions from 2005, 2008, 2010, 2013, 2014, 2015, 2017, 2019, 2020, 2021, 2022. Besides, more than 300 traditional functions with different dimensions are implemented.

  • Free software: GNU General Public License (GPL) V3 license
  • Total problems: > 500 problems
  • Documentation: https://opfunu.readthedocs.io
  • Python versions: >= 3.7.x
  • Dependencies: numpy, matplotlib

Citation Request

Please include these citations if you plan to use this library:

  • LaTeX:
  @article{Van_Thieu_2024_Opfunu,
      author = {Van Thieu, Nguyen},
      title = {Opfunu: An Open-source Python Library for Optimization Benchmark Functions},
      doi = {10.5334/jors.508},
      journal = {Journal of Open Research Software},
      month = {May},
      year = {2024}
  }
  • APA:

    Van Thieu, N. (2024). Opfunu: An Open-source Python Library for Optimization Benchmark Functions. Journal of Open Research Software, 12(1), 8. https://doi.org/10.5334/jors.508

Installation and Usage

Install with pip

Install the current PyPI release:

$ pip install opfunu

After installation, you can import and check version of Opfunu:

$ python
>>> import opfunu
>>> opfunu.__version__

>>> dir(opfunu)
>>> help(opfunu)

>>> opfunu.FUNC_DATABASE      # List all name_based functions
>>> opfunu.CEC_DATABASE       # List all cec_based functions
>>> opfunu.ALL_DATABASE       # List all functions in this library

>>> opfunu.get_functions_by_classname("MiShra04")
>>> opfunu.get_functions_based_classname("2015")
>>> opfunu.get_functions_by_ndim(2)
>>> opfunu.get_functions_based_ndim(50)

>>> opfunu.get_name_based_functions(ndim=10, continuous=True)
>>> opfunu.get_cec_based_functions(ndim=2)

Let's go through some examples.

Examples

How to get the function and use it

1st way

from opfunu.cec_based.cec2014 import F12014

func = F12014(ndim=30)
func.evaluate(func.create_solution())

## or

from opfunu.cec_based import F102014

func = F102014(ndim=50)
func.evaluate(func.create_solution())

2nd way

import opfunu

funcs = opfunu.get_functions_by_classname("F12014")
func = funcs[0](ndim=10)
func.evaluate(func.create_solution())

## or

all_funcs_2014 = opfunu.get_functions_based_classname("2014")
print(all_funcs_2014)

How to draw 2D, 3D

Two ways if you want to draw functions that available in Opfunu.

from opfunu.cec_based import F12010
f0 = F12010()

# Visualize opfunu function using method in object
f0.plot_2d(selected_dims=(2, 3), n_points=300, ct_cmap="viridis", ct_levels=30, ct_alpha=0.7,
           fixed_strategy="mean", fixed_values=None, title="Contour map of the F1 CEC 2010 function",
           x_label=None, y_label=None, figsize=(10, 8), filename="2d-f12010", exts=(".png", ".pdf"), verbose=True)

f0.plot_3d(selected_dims=(1, 6), n_points=500, ct_cmap="viridis", ct_levels=30, ct_alpha=0.7,
           fixed_strategy="mean", fixed_values=None, title="3D visualization of the F1 CEC 2010 function",
           x_label=None, y_label=None, figsize=(10, 8), filename="3d-f12010", exts=(".png", ".pdf"), verbose=True)

## Visualize opfunu function using utility function
from opfunu import draw_2d, draw_3d

draw_2d(f0.evaluate, f0.lb, f0.ub, selected_dims=(2, 3), n_points=300)
draw_3d(f0.evaluate, f0.lb, f0.ub, selected_dims=(2, 3), n_points=300)
F1-2010 CEC 2D

F1-2010 CEC 2D

F1-2010 CEC 3D

F1-2010 CEC 3D

How to draw Latex

Two ways if you want to draw latex equation.

from opfunu.cec_based import F12010
from opfunu.name_based import Ackley02
from opfunu.utils.visualize import draw_latex

f0 = F12010()
f1 = Ackley02()

## Plot using function inside the object
f0.plot_latex(f0.latex_formula, figsize=(8, 3), dpi=500, title="Latex equation", exts=(".png", ".pdf"), verbose=True)
f1.plot_latex(f1.latex_formula_global_optimum, figsize=(8, 3), dpi=500, title="Global optimum", verbose=True)

## Plot using module
draw_latex(f0.latex_formula_bounds, title="Boundary for Function")
draw_latex(f1.latex_formula_dimension, title=None)

For more usage examples please look at examples folder.

Contributing

There are lots of ways how you can contribute to Permetrics's development, and you are welcome to join in! For example, you can report problems or make feature requests on the issues pages. To facilitate contributions, please check for the guidelines in the CONTRIBUTING.md file.

Official channels


Developed by: Thieu @ 2023

opfunu's People

Contributors

dependabot[bot] avatar firestrand avatar mcrimi avatar skylull avatar thieu1995 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

opfunu's Issues

latex formula miss for Ackley02

Description of the bug

latex_formula = r'f_{\text{Ackley02}(x) = -200 e^{-0.02 \sqrt{x_1^2 + x_2^2}}'

it should be r'f_{\text{Ackley02}}(x) = -200 e^{-0.02 \sqrt{x_1^2 + x_2^2}' ?

Steps To Reproduce

latex_formula = r'f_{\text{Ackley02}(x) = -200 e^{-0.02 \sqrt{x_1^2 + x_2^2}}'

Additional Information

No response

[BUG]: python 3.12 import failed

Description of the bug

python 3.12 import opfunu
from . import cec_based
from .cec2005 import *
from opfunu.cec_based.cec import CecBenchmark
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
how to fix it ?

Steps To Reproduce

python3.12
import opfunu
error!

Additional Information

No response

LennardJones raises Error when initialized without specified `ndim`

The problem

  • The LennardJones Function has a dim_default of 2, but an ValueError is raised when the dimensionality that is given upon construction is nog in `range(6, 61)
  • This check is specified right after construction, before setting the default dimensionality. Therefore providing no argument (ndim=None) will raise the ValueError. This is inconsistant with the interface of the other named functions.

self.dim_default = 2

Minimal reproducible example

from opfunu.name_based.l_func import LennardJones
f = LennardJones(ndim=None)

will raise:

ValueError                                Traceback (most recent call last)
Cell In[13], [line 3](vscode-notebook-cell:?execution_count=13&line=3)
      [1](vscode-notebook-cell:?execution_count=13&line=1) from opfunu.name_based.l_func import LennardJones
----> [3](vscode-notebook-cell:?execution_count=13&line=3) f = LennardJones(ndim=None)

File [~/Documents/GitHub/opfunu/opfunu/name_based/l_func.py:110](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/l_func.py:110), in LennardJones.__init__(self, ndim, bounds)
    [108](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/l_func.py:108) def __init__(self, ndim=None, bounds=None):
    [109](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/l_func.py:109)     if ndim not in range(6, 61):
--> [110](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/l_func.py:110)         raise ValueError("LennardJones dimensions must be in (6, 60)")
    [111](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/l_func.py:111)     super().__init__()
    [112](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/l_func.py:112)     self.dim_changeable = True

ValueError: LennardJones dimensions must be in (6, 60)

[BUG]: Different results in CEC2015 series of benchmark functions compared with the original Matlab implementation!

Description of the bug

Hi, I was benchmarking results on CEC2015 problems. The implementation of the methods I selected is via Matlab and python. For python codes, I followed your implementation of CEC2015. For Matlab codes, I followed the zip file provided by the competition authors (https://github.com/P-N-Suganthan/CEC2015), and when I compared optimization results of the selected methods, I found that on some CEC2015 problems, these two implementations returned different results.
I am looking forward to the bug fixation!

Steps To Reproduce

Here are the ones with problems: F4, F6, F7, F11, F12, F13, F14, and F15. Among them, some result in minor differences, like 1~2. Even so, it does influence the comparison. Others (e.g., F12) result in a huge gap in the order of magnitudes.
Currently, I have not found the right way to fix this, but I do find mistakes in CEC2015 problems, such as on F12, the leveraged input file is mistaken from the ones of F10.

Additional Information

No response

[BUG]: A bug in cec2020.F82020(ndim=10)

Description of the bug

Dear Thieu
I hope to find you well.
cec2020.F82020(ndim=10) seems to have a bug that the fitness value may be smaller than 0
and in the official technical report, the minimum is 2100.
Best wishes

Steps To Reproduce

You can directly copy the following code:

from opfunu.cec_based import cec2020

func = cec2020.F82020(ndim=10)
print(func.evaluate([90.75118764, 97.00278372, 76.1721669, 99.96999972, -11.39271999, 89.5915097, 76.24025183, 83.30977968, 23.79283718, 37.22928422]))

where the 10-D solution [90.75118764, 97.00278372, 76.1721669, 99.96999972, -11.39271999, 89.5915097, 76.24025183, 83.30977968, 23.79283718, 37.22928422] is within the search space in [-100, 100]

Additional Information

No response

[BUG]: opfunu install in mac

Description of the bug

hi i cant install opfunu . i installed before but now in visual studio i cant use it does any one have a solution?

Steps To Reproduce

i install step by step to read me file

Additional Information

No response

[BUG]: An error has been identified in the configuration parameters of Opfunu library.

Description of the bug

In cec2017.py, the parameter setting of the test function F10: Hybrid Function 1 is erroneous. The parameter $p$ should be set to $[0.2, 0.4, 0.4]$.In a similar manner, the parameter $p$ in F17: Hybrid Function 8 should be set to $[0.2, 0.2, 0.2, 0.2, 0.2, 0.2]$.

As not all test functions in the Opfunu library have been individually verified, it is not possible to ascertain whether there are other errors of a similar nature. Consequently, it is necessary to perform the requisite verification when the library is actually being utilized.

Steps To Reproduce

Please review the description of the bug content and forgive me for my poor English

Additional Information

No response

New feature: database API

I really like this repository and used it in my Computational Intelligence course back in university. However, I wish that it also included a database for each benchmark method.

This would be really useful if someone would like to use and compare benchmark methods, but want to know how to draw meaningful conclusions from their tests. For instance, knowing what tags a benchmark method has (e.g. continuous vs discontinuous, non-convex vs convex etc) and knowing the dimension of the benchmark on hand would speed up the process of say concluding whether an algorithm performs better in lower dimensions, on convex landscapes etc.

Would you be interested if I attempted to add such a thing? This can either be by csv or by physically adding a list of dictionaries.
Here is a preview of what I suggest:

api.py:

# this snippet only includes benchmarks from the multi_modal file for now
from opfunu.type_based import multi_modal

""" Links are retrieved from the following name spaces: 
    (ordered from most useful links to lease useful)
- https://www.sfu.ca/~ssurjano/optimization.html
- http://infinity77.net/global_optimization/test_functions.html
- https://github.com/mazhar-ansari-ardeh/BenchmarkFcns/blob/gh-pages/benchmarkfcns/
- http://benchmarkfcns.xyz
- https://www.indusmic.com/post/


A Literature Survey of Benchmark Functions For Global Optimization Problems (2013):
    https://arxiv.org/pdf/1308.4008.pdf
"""


data = [
    # Ackley
    dict(
        dimensions='d',
        domain=[-32.768, 32.768],
        latex=r"f(\textbf{x}) = f(x_1, ..., x_n)= -a.exp(-b\sqrt{\frac{1}{n}\sum_{i=1}^{n}x_i^2})-exp(\frac{1}{d}\sum_{i=1}^{n}cos(cx_i))+ a + exp(1)",
        links=[
            'http://benchmarkfcns.xyz/benchmarkfcns/ackleyfcn.html',
            'https://github.com/mazhar-ansari-ardeh/BenchmarkFcns/blob/gh-pages/benchmarkfcns/ackleyfcn.markdown',
            'https://www.sfu.ca/~ssurjano/ackley.html',
        ],
        method=multi_modal.Functions()._ackley__,
        minima=[dict(fx=0, x=0)],
        name='Ackley',
        references=[
            '''Adorio, E. P., & Diliman, U. P. MVF - Multivariate Test Functions Library in C for Unconstrained Global Optimization (2005). Retrieved June 2013, from http://http://www.geocities.ws/eadorio/mvf.pdf.''',
            '''Molga, M., & Smutnicki, C. Test functions for optimization needs (2005). Retrieved June 2013, from http://www.zsd.ict.pwr.wroc.pl/files/docs/functions.pdf.''',
            '''Back, T. (1996). Evolutionary algorithms in theory and practice: evolution strategies, evolutionary programming, genetic algorithms. Oxford University Press on Demand.''',
        ],
        tags=[
            'continuous',
            'non-convex',
            'differentiable',
        ],
    ),
    # Ackley N. 4
    dict(
        dimensions='d',
        domain=[-35, 35],
        latex=r"f(\textbf{x})=\sum_{i=1}^{n-1}\left( e^{-0.2}\sqrt{x_i^2+x_{i+1}^2} + 3\left( cos(2x_i) + sin(2x_{i+1}) \right) \right)",
        links=[
            'http://benchmarkfcns.xyz/benchmarkfcns/ackleyn4fcn.html',
            'https://github.com/mazhar-ansari-ardeh/BenchmarkFcns/blob/gh-pages/benchmarkfcns/ackleyn4fcn.markdown',
        ],
        method=multi_modal.Functions()._ackley_4__,
        minima=[dict(fx=-4.590101633799122, x=[-1.51, -0.755])],
        name='Ackley N. 4',
        references=[
            '''Momin Jamil and Xin-She Yang, A literature survey of benchmark functions for global optimization problems, Int. Journal of Mathematical Modelling and Numerical Optimisation}, Vol. 4, No. 2, pp. 150--194 (2013), arXiv:1308.4008''',
        ],
        tags=[
            'continuous',
            'differentiable',
            'non-separable',
            'scalable',
        ],
    ),
    # Alpine 1
    dict(
        dimensions='d',
        domain=[-10, 10],
        latex=r"f(\mathbf x)=f(x_1, ..., x_n)=\sum_{i=1}^{n}|x_i sin(x_i) + 0.1x_i|",
        links=[
            'http://benchmarkfcns.xyz/benchmarkfcns/alpinen1fcn.html'
            'https://github.com/mazhar-ansari-ardeh/BenchmarkFcns/blob/gh-pages/benchmarkfcns/alpinen1fcn.markdown',
            'http://infinity77.net/global_optimization/test_functions_nd_A.html#go_benchmark.Alpine01',
        ],
        method=multi_modal.Functions()._alpine_1__,
        minima=[dict(fx=0, x=0)],
        name='Alpine 1',
        references=[
            '''Momin Jamil and Xin-She Yang, A literature survey of benchmark functions for global optimization problems, Int. Journal of Mathematical Modelling and Numerical Optimisation}, Vol. 4, No. 2, pp. 150--194 (2013), arXiv:1308.4008''',
            '''M. Clerc, “The Swarm and the Queen, Towards a Deterministic and Adaptive Particle Swarm Optimization, ” IEEE Congress on Evolutionary Computation, Washington DC, USA, pp. 1951-1957, 1999.''',
        ],
        tags=[
            'continuous',
            'non-differentiable',
            'separable',
            'non-scalable',
        ],
    ),
    # Alpine 2
    dict(
        dimensions='d',
        domain=[0, 10],
        latex=r"f(\mathbf x)=f(x_1, ..., x_n) = \prod_{i=1}^{n}\sqrt{x_i}sin(x_i)",
        links=[
            'http://infinity77.net/global_optimization/test_functions_nd_A.html#go_benchmark.Alpine02',
            'https://github.com/mazhar-ansari-ardeh/BenchmarkFcns/blob/gh-pages/benchmarkfcns/alpinen2fcn.markdown',

        ],
        method=multi_modal.Functions()._alpine_2__,
        minima=[dict(fx=-6.1295, x=7.917)],
        name='Alpine 2',
        references=[
            '''Momin Jamil and Xin-She Yang, A literature survey of benchmark functions for global optimization problems, Int. Journal of Mathematical Modelling and Numerical Optimisation}, Vol. 4, No. 2, pp. 150--194 (2013), arXiv:1308.4008''',
            '''M. Clerc, “The Swarm and the Queen, Towards a Deterministic and Adaptive Particle Swarm Optimization, ” IEEE Congress on Evolutionary Computation, Washington DC, USA, pp. 1951-1957, 1999.''',
        ],
        tags=[
            'multi-modal'
            'differentiable',
            'non-convex',
            'non-separable',
        ],
    ),
    # Cosine Mixture
    dict(
        dimensions='d',
        domain=[-1, 1],
        latex=r"f(\mathbf{x})=-0.1\sum_{i=1}^n\cos(5\pix_i)-\sum_{i=1}^{n}x_i^2",
        links=[
            'http://infinity77.net/global_optimization/test_functions_nd_C.html#go_benchmark.CosineMixture',
        ],
        method=multi_modal.Functions()._cosine_mixture__,
        minima=[dict(fx=lambda x: 0.1*len(x), x=0)],
        name='Cosine Mixture',
        references=[
            'A Literature Survey of Benchmark Functions For Global Optimization Problems (2013)'
        ],
        tags=[
            'discontinuous',
            'non-differentiable',
            'separable',
            'scalable',
            'multi-modal',
        ],
    ),
    # Csendes
    dict(
        dimensions=2,
        domain=[-1, 1],
        latex=r"f(\mathbf{x})=\sum_{i=1}^n x_i^6\left[2+\sin\left(\frac{1}{x_i}\right)\right]",
        links=[
            'http://infinity77.net/global_optimization/test_functions_nd_C.html#go_benchmark.Csendes',
        ],
        method=multi_modal.Functions()._csendes__,
        minima=[dict(fx=0, x=0)],
        name='Csendes',
        references=[
            'A Literature Survey of Benchmark Functions For Global Optimization Problems (2013)'
        ],
        tags=[
            'continuous',
            'differentiable',
            'separable',
            'scalable',
            'multi-modal',
        ],
    ),


    # TODO: add the methods in benchmark2d.py
    # TODO: add the methods in benchmark3d.py
    # TODO: add the methods in benchmarknd.py
    # TODO: add the methods in multi_modal.py
    # TODO: add the methods in uni_modal.py

whereafter one would use the data list of dictionaries to build a dataframe for instance, using

import pandas as pd
df = pd.DataFrame(data)

[BUG]: Wrong `self._bounds` index used for setting `self._ndim`

Problem

When presented a funciton where ndim cannot be 2 (if dim_changeable=False and default_dim != 2) and ndim=None is given upon initialization, this function makes it so the dimension is set to 2, because the wrong index is given when setting self._ndim = self._bounds.shape[1].

self._ndim = self._bounds.shape[1]

Possible solution

This should be the first index (self._bounds.shape[0]). This is correctly implemented in the cec_based submodule

[BUG]: Mishra07 function: np has no method factorial

Description of the bug

The Mishra Function has an operation calling np.factorial. This method does not exist

Steps To Reproduce

  1. Create an instance of the opfunu.name_based.m_func.Mishra07 function
  2. evaluate the function

Additional Information

No response

[BUG]: Use visualize.py failed

Description of the bug

When I want to draw a 2d or 3d image by plot_2d or plot_3d in visualize.py, it will report an error.
Error Message : "ValueError: too many values to unpack (expected 2). "
It happens on the first line of both two functions: X_domain, Y_domain = func.bounds.
Here is my guess about cause of the error:
The variable "func.bounds" has dimension "dim_default", it will be given to variable "X_domain" and "Y_domain".

Steps To Reproduce

1.run visualize.plot_2d(cec2017.F12017())
2.ValueError: too many values to unpack (expected 2)

Additional Information

No response

[BUG]: check pip installation

Description of the bug

I made a clean installation with pip, but I got a library requirements message.

# ModuleNotFoundError: No module named 'requests'
# ModuleNotFoundError: No module named 'pandas'

Steps To Reproduce

in a clean environment, with this code:

from opfunu.cec_based.cec2022 import *
func = F12022(ndim=10)
func.evaluate(func.create_solution())

error:

# ModuleNotFoundError: No module named 'requests'
# ModuleNotFoundError: No module named 'pandas'

solution:
pip install requests
pip install pandas

Additional Information

No response

[BUG]: Function 14 from CEC2014

Description of the bug

Hi! I was using function 14 (F14: Shifted and Rotated HGBat Function) from CEC2014 and found that evaluating the x_global gives a different result from what is expected. So, this gives a False output when we use problem.is_succeed(problem.x_global).

The expected value of problem.evaluate(problem.x_global) is 1400 (based on the document from CEC2014), but it is giving 1400.5, which explains the abovementioned issue.

Steps To Reproduce

import opfunu

problem = opfunu.cec_based.F142014(ndim=10)
problem.evaluate(problem.x_global) # expected to be 1400.0
problem.is_succeed(problem.x_global) # expected to be True

Additional Information

No response

[BUG]: cec2021 F2 has abnormal optimal value.

Description of the bug

In short:

F22021 should have a global optimal value = 1100.0, but I found much more space that has even lower values.


In detail:

The plotted function of F22021 looked like this:
螢幕擷取畫面 2023-12-15 155906
The very little red dot near the middle (located at (2.0990197e+01, -2.3188216e+01), right as provided) should have the global optimal value of 1100.0 (equals bias), but as the plot clearly showed, much more space has a value lower than 1100.0.
For example, the red dot located at (94.14767894, 2.33460048) near the right side solved for a value of 23.98, there even exists a point (99.31320785, -0.51136206) that solved for a value of -32.35

I suppose this is not the intended outcome?

In case I did something wrong that I couldn't find myself due to the lack of domain knowledge, here is the same plot from other angles:
圖片
螢幕擷取畫面 2023-12-15 160801
螢幕擷取畫面 2023-12-15 163427

Steps To Reproduce

I use this code to draw the plot:

import numpy as np
import matplotlib.pyplot as plt
import opfunu.cec_based


if __name__ == '__main__':
    dim = 2
    eval_func = opfunu.cec_based.F22021(ndim=2)
    bound = {"upper": 100.0,
             "lower": -100.0}

    # Create a meshgrid for visualization
    x = np.linspace(bound["lower"], bound["upper"], 300)
    y = np.linspace(bound["lower"], bound["upper"], 300)
    X, Y = np.meshgrid(x, y)

    Z = np.zeros_like(X)
    for i in range(len(x)):
        for j in range(len(y)):
            Z[i, j] = eval_func.evaluate([X[i, j], Y[i, j]])

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.plot_surface(X, Y, Z, cmap='viridis')
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')

    print("f_global = ", eval_func.f_global)

    ax.scatter(2.0990197e+01, -2.3188216e+01, 1100., color='red')

    plt.show()

Additional Information

The version of main packages:
Python 3.9.13
Cython 3.0.6
matplotlib 3.8.2
numpy 1.26.2
opfunu 1.0.1

using Windows 11 22H2

CEC 2017

Thank you for providing CEC benchmark.

I cant find the CEC 2017 benchmark. I appreciate it if you put it in the library. thank you so much

[BUG]: Dolan function has wrong default dimensionality

Description of the bug

The default dimensionality of the Dolan function is 2, but the function is only defined for a dimensionality of 5
Also the dim_interchangeable=True, but this should be False

Steps To Reproduce

g = opfunu.name_based.d_func.Dolan(ndim=None)
x = np.random.rand(g.ndim)
g.evaluate(x)

Gives

[476](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/d_func.py:476) self.check_solution(x)
    [477](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/d_func.py:477) self.n_fe += 1
--> [478](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/d_func.py:478) return (abs((x[0] + 1.7 * x[1]) * np.sin(x[0]) - 1.5 * x[2]
    [479](https://file+.vscode-resource.vscode-cdn.net/home/martin/Documents/GitHub/opfunu/notebooks/~/Documents/GitHub/opfunu/opfunu/name_based/d_func.py:479)             - 0.1 * x[3] * np.cos(x[3] + x[4] - x[0]) + 0.2 * x[4] ** 2 - x[1] - 1))

IndexError: index 2 is out of bounds for axis 0 with size 2

Additional Information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.