diff --git a/.gitignore b/.gitignore index d7021fd..66771f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Pycharm .idea/ - +tut_upcode.md # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/README.md b/README.md index 23f9e92..60522b4 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ print(func2d._bird__(solution)) ### Documentation ```code +0. A Literature Survey of Benchmark Functions For Global Optimization Problems (2013) 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/ diff --git a/opfunu/benchmark1d.py b/opfunu/benchmark1d.py new file mode 100644 index 0000000..8982dcf --- /dev/null +++ b/opfunu/benchmark1d.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python # +# ------------------------------------------------------------------------------------------------------# +# Created by "Thieu Nguyen" at 02:52, 07/12/2019 # +# # +# Email: nguyenthieu2102@gmail.com # +# Homepage: https://www.researchgate.net/profile/Thieu_Nguyen6 # +# Github: https://github.com/thieunguyen5991 # +#-------------------------------------------------------------------------------------------------------# + + +import numpy as np + +class Functions: + """ + This class of functions is belongs to 1-dimensional space + """ + + def _gramacy_lee__(self, solution=None): + """ + Class: uni-modal, non-convex, continuous + Global: 1 global minimum fx = −0.869011134989500, atx 0.548563444114526 + Link: http://benchmarkfcns.xyz/benchmarkfcns/gramacyleefcn.html + + @param solution: A numpy array include 1 items like: [0.5], limited range: [-0.5, 2.5] + + """ + n = len(solution) + assert (n == 1, 'Gramacy and Lee function is only defined on a 1D space.') + return np.sin(10*np.pi*solution) / (2*solution) + (solution-1)**4 diff --git a/opfunu/benchmark3d.py b/opfunu/benchmark3d.py new file mode 100644 index 0000000..923a89c --- /dev/null +++ b/opfunu/benchmark3d.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python # +# ------------------------------------------------------------------------------------------------------# +# Created by "Thieu Nguyen" at 02:52, 07/12/2019 # +# # +# Email: nguyenthieu2102@gmail.com # +# Homepage: https://www.researchgate.net/profile/Thieu_Nguyen6 # +# Github: https://github.com/thieunguyen5991 # +#-------------------------------------------------------------------------------------------------------# + + +import numpy as np + +class Functions: + """ + This class of functions is belongs to 3-dimensional space + """ + + def _wolfe__(self, solution=None): + """ + Class: multi-modal, non-convex, continuous, differentiable, non-separable + Global: 1 global minimum fx = 0, [0, 0, 0] + Link: http://benchmarkfcns.xyz/benchmarkfcns/wolfefcn.html + + @param solution: A numpy array include 3 items like: [0.2, 0.22, 0.5], limited range: [0, 2] + """ + n = len(solution) + assert (n == 3, 'Wolfe function is only defined on a 3D space.') + return 4/3 * (solution[0]**2 + solution[1]**2 - solution[0]*solution[1])**0.75 + solution[2] diff --git a/setup.py b/setup.py index 9b23f64..e8f09bf 100644 --- a/setup.py +++ b/setup.py @@ -7,12 +7,12 @@ def readme(): setup( name="opfunu", - version="0.2.0", - description="A python package for Optimization Functions in Numpy.", + version="0.2.1", + description="A python (Numpy) package for Un-constrained Optimization Functions", long_description=readme(), long_description_content_type="text/markdown", url="https://github.com/thieunguyen5991/opfunu", - download_url="https://github.com/thieunguyen5991/opfunu/archive/v.0.2.0.zip", + download_url="https://github.com/thieunguyen5991/opfunu/archive/v.0.2.1.zip", author="Thieu Nguyen", author_email="nguyenthieu2102@gmail.com", license="Apache License, Version 2.0",