Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	ChangeLog.md
  • Loading branch information
firestrand committed Oct 21, 2024
2 parents a193538 + 61a79f4 commit 86f5cec
Show file tree
Hide file tree
Showing 44 changed files with 996 additions and 1,325 deletions.
Binary file added .github/img/2d-f12010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img/3d-f12010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
given-names: "Nguyen"
orcid: "https://orcid.org/0000-0001-9994-8747"
title: "Opfunu: An Open-source Python Library for Optimization Benchmark Functions"
version: 1.0.1
version: 1.0.4
doi: 10.5281/zenodo.3620960
date-released: 2022-07-13
url: "https://github.com/thieu1995/opfunu"
95 changes: 95 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Contributing to Opfunu

We appreciate your interest in contributing to Opfunu! This guide details how to contribute in a way that is efficient
for everyone.

## Table of Contents

- [Code of Conduct](#code-of-conduct)
- [Getting Started](#getting-started)
- [How Can I Contribute?](#how-can-i-contribute)
- [Pull Requests](#pull-requests)
- [Issue Tracking](#issue-tracking)

## Code of Conduct

All contributors are expected to adhere to the project's [Code of Conduct](CODE_OF_CONDUCT.md). Please read the document before contributing.

## Getting Started

1. Fork the project repository and clone your fork:

```
git clone https://github.com/thieu1995/opfunu.git
```

2. Create a new branch for your changes:

```
git checkout -b name-of-your-branch
```

3. Make your changes and commit them:

```
git commit -m "Detailed commit message"
```

4. Push your changes to your fork:

```
git push origin name-of-your-branch
```

5. Create a pull request from your branch to the Opfunu main branch.

## How Can I Contribute?

Here are some ways to contribute:

- Improve documentation
- Fix bugs or add new features
- Write tutorials or blog posts
- Review code submissions
- Test the application and report issues

However, before contributing, make sure that the unit tests pass and that new functionality is covered by unit tests.
The unit tests can be run using `pytest`. Change working directory to opfunu and then use:

```python
# Test CEC-based functions
python -m pytest tests/cec_based

# Test Name-based functions
python -m pytest tests/name_based
```

Or you can test all files by:

```python
python -m pytest
```


## Pull Requests

[Pull requests](https://github.com/thieu1995/opfunu/pulls) are the best way to propose changes to the codebase. We
actively welcome your pull requests:

1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Issue that pull request!

## Issue Tracking

We use [GitHub issues](https://github.com/thieu1995/opfunu/issues) to track public bugs and requests. Please ensure
your description is clear and has sufficient instructions to be able to reproduce the issue.

## Any questions?

Don't hesitate to contact us if you have any questions. Contact [@thieu1995](mailto:[email protected])
or ask your question on issues.

Thank you for your contributions!
17 changes: 16 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# Version 1.0.4
# Version 1.0.5

+ Fix schaffer_f7_func to match the cec implementation and reference document
+ Fix zakharov_func to match the cec implementation and reference document
+ Added a direct conversion of the lunacek_bi_rastrigin_cec_func
+ Added tests for cec functions comparing outputs to the reference implementations
---------------------------------------------------------------------
# Version 1.0.4

+ Fix p value in F10 and F17 of CEC-2017
+ Add plot_latex to Benchmark class.
+ User can use draw_latex from opfunu to draw their latex equation.
+ Update examples for draw latex function

---------------------------------------------------------------------

# Version 1.0.3

+ Optimized katsuura_func performance, at 1M ndim > 80x speedup
+ Add plot_2d, plot_3d to Benchmark class.
+ User can use draw_2d, draw_3d from opfunu to draw their function.
+ Add tutorial on how to integrate with other optimization frameworks like Mealpy, Opytimizer, Niapy
+ Update examples and update documentations
+ Update citation and paper (Got published at Journal of Open Research Software)

---------------------------------------------------------------------

# Version 1.0.2

+ Fix modified_schwefel_func() in operator.py
Expand Down
178 changes: 101 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
---


[![GitHub release](https://img.shields.io/badge/release-1.0.2-yellow.svg)](https://github.com/thieu1995/opfunu/releases)
[![GitHub release](https://img.shields.io/badge/release-1.0.4-yellow.svg)](https://github.com/thieu1995/opfunu/releases)
[![Wheel](https://img.shields.io/pypi/wheel/gensim.svg)](https://pypi.python.org/pypi/opfunu)
[![PyPI version](https://badge.fury.io/py/opfunu.svg)](https://badge.fury.io/py/opfunu)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/opfunu.svg)
Expand Down Expand Up @@ -34,6 +34,28 @@ optimization benchmark functions. Contains all CEC competition functions from 20
* **Dependencies:** numpy, matplotlib


# Citation Request

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

- LaTeX:

```bibtex
@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. <i>Journal of Open Research Software</i>, <i>12</i>(1), 8. https://doi.org/10.5334/jors.508


# Installation and Usage

### Install with pip
Expand All @@ -57,44 +79,13 @@ $ python
>>> opfunu.CEC_DATABASE # List all cec_based functions
>>> opfunu.ALL_DATABASE # List all functions in this library

>>> opfunu.get_functions_by_classname("CEC2014")
>>> opfunu.get_functions_by_classname("MiShra04")
>>> opfunu.get_functions_based_classname("2015")
>>> opfunu.get_functions_by_ndim(30)
>>> opfunu.get_functions_based_ndim(2)
>>> opfunu.get_all_named_functions()
>>> opfunu.get_all_cec_functions()
>>> opfunu.get_functions()
>>> opfunu.get_cecs()
```
>>> opfunu.get_functions_by_ndim(2)
>>> opfunu.get_functions_based_ndim(50)

### Lib's structure

```code
docs
examples
opfunu
cec_based
cec.py
cec2005.py
cec2008.py
...
cec2021.py
cec2022.py
name_based
a_func.py
b_func.py
...
y_func.py
z_func.py
utils
operator.py
validator.py
visualize.py
__init__.py
benchmark.py
README.md
setup.py
>>> opfunu.get_name_based_functions(ndim=10, continuous=True)
>>> opfunu.get_cec_based_functions(ndim=2)
```

Let's go through some examples.
Expand Down Expand Up @@ -124,7 +115,6 @@ func.evaluate(func.create_solution())
#### 2nd way

```python

import opfunu

funcs = opfunu.get_functions_by_classname("F12014")
Expand All @@ -135,57 +125,91 @@ func.evaluate(func.create_solution())

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

```

For more usage examples please look at [examples](/examples) folder.

### How to draw 2D, 3D

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

```python
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)

# Get helps (questions, problems)
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)

* Official source code repo: https://github.com/thieu1995/opfunu
* Official document: https://opfunu.readthedocs.io/
* Download releases: https://pypi.org/project/opfunu/
* Issue tracker: https://github.com/thieu1995/opfunu/issues
* Notable changes log: https://github.com/thieu1995/opfunu/blob/master/ChangeLog.md
* Examples with different version: https://github.com/thieu1995/opfunu/blob/master/examples.md
* Official chat group: https://t.me/+fRVCJGuGJg1mNDg1
## Visualize opfunu function using utility function
from opfunu import draw_2d, draw_3d

* This project also related to our another projects which are optimization and machine learning. Check it here:
* https://github.com/thieu1995/metaheuristics
* https://github.com/thieu1995/mealpy
* https://github.com/thieu1995/mafese
* https://github.com/thieu1995/pfevaluator
* https://github.com/thieu1995/MetaCluster
* https://github.com/thieu1995/enoppy
* https://github.com/thieu1995/permetrics
* https://github.com/aiir-team
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)
```

<table>
<tr>
<td style="text-align: center;">
<img src=".github/img/2d-f12010.png" alt="F1-2010 CEC 2D" style="width: 100%;">
<p style="text-align: center;">F1-2010 CEC 2D</p>
</td>
<td style="text-align: center;">
<img src=".github/img/3d-f12010.png" alt="F1-2010 CEC 3D" style="width: 100%;">
<p style="text-align: center;">F1-2010 CEC 3D</p>
</td>
</tr>
</table>

## Cite Us

If you are using opfunu in your project, we would appreciate citations:
### How to draw Latex

```code
@software{thieu_nguyen_2020_3711682,
author = {Nguyen Van Thieu},
title = {Opfunu: An Open-source Python Library for Optimization Benchmark Functions},
year = 2020,
publisher = {Zenodo},
doi = {10.5281/zenodo.3620960},
url = {https://doi.org/10.5281/zenodo.3620960.}
}
```
Two ways if you want to draw latex equation.

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

## References
f0 = F12010()
f1 = Ackley02()

```code
1. http://benchmarkfcns.xyz/fcns
2. https://en.wikipedia.org/wiki/Test_functions_for_optimization
3. https://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/
4. http://www.sfu.ca/~ssurjano/optimization.html
5. A Literature Survey of Benchmark Functions For Global Optimization Problems (2013)
6. Problem Definitions and Evaluation Criteria for the CEC 2014 Special Session and Competition on Single Objective Real-Parameter Numerical Optimization
## 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](/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](/issues) pages. To facilitate contributions,
please check for the guidelines in the [CONTRIBUTING.md](/CONTRIBUTING.md) file.


# Official channels

* [Official source code repository](https://github.com/thieu1995/opfunu)
* [Official document](https://opfunu.readthedocs.io/)
* [Download releases](https://pypi.org/project/opfunu/)
* [Issue tracker](https://github.com/thieu1995/opfunu/issues)
* [Notable changes log](/ChangeLog.md)
* [Official discussion group](https://t.me/+fRVCJGuGJg1mNDg1)


---

Developed by: [Thieu](mailto:[email protected]?Subject=Opfunu_QUESTIONS) @ 2023
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
author = 'Thieu'

# The full version, including alpha/beta/rc tags
release = '1.0.3'
release = '1.0.4'


# -- General configuration ---------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Welcome to OPFUNU's documentation!
==================================

.. image:: https://img.shields.io/badge/release-1.0.2-yellow.svg
.. image:: https://img.shields.io/badge/release-1.0.4-yellow.svg
:target: https://github.com/thieu1995/opfunu/releases

.. image:: https://img.shields.io/pypi/wheel/gensim.svg
Expand Down Expand Up @@ -74,7 +74,9 @@ traditional functions with different dimensions are implemented.
:caption: Introduction:

pages/quick_start.rst
pages/notes.rst
pages/integrated.rst
pages/visualization.rst
pages/categories.rst


.. toctree::
Expand Down
Loading

0 comments on commit 86f5cec

Please sign in to comment.