Skip to main content

A python implementation of optimization benchmarks

Project description

# PyBenchFCN #

A python implementation of optimization benchmarks

How to Install

This library is a python implementation for the MatLab package BenchmarkFcns Toolbox.

You can simply install with command pip install PyBenchFCN.

  • Pre-request: numpy, matplotlib

How to Use

The input of each numerical optimization problem could be a 1-D ndarray, or 2-D ndarray.

  • 1-D array
    • an example of a solution (individual) for 10D problem is np.random.uniform(0, 1, 10), where each entry is a decision variable.
    • use f() to return a fitness value (scalar for SOP, 1D-array for MOP).
  • 2-D array
    • an example of group of solutions (population) for 10D problem is np.random.uniform(0, 1, (5, 10)), where each row (totally 5) is an individual.
    • use F() to return an array of fitness value (1-D array for SOP, 2-D array for MOP).

Set Benchmark Function

To set a benchmark function, one may see the sample code in Factory.py in the repository, or follow the script below. Also, there is a sample optimization program provided in sample.py.

import numpy as np

# import single objective problems from PyBenchFCN
from PyBenchFCN import SingleObjectiveProblem as SOP

n_var = 10                                      # dimension of problem
n_pop = 3                                       # size of population

problem = SOP.ackleyfcn(n_var)                  # Ackley problem

'''same function as the code above
from PyBenchFCN import Factory
problem = Factory.set_sop("f1", n_var)
'''

print( np.round(problem.optimalF, 5) )          # show rounded optimal value

xl, xu = problem.boundaries                     # bound of problem

x = np.random.uniform(xl, xu, n_var)            # initialize a solution
print( problem.f(x) )                           # show fitness value as scalar

X = np.random.uniform( xl, xu, (n_pop, n_var) ) # initialize a population
print( problem.F(X) )                           # show fitness values as 1d-array

Plot Fitness Landscape

To plot a fitness landscape (2D space), one can use the code below. Notice, this function only works for continuous SOPs.

from PyBenchFCN import Tool
Tool.plot_sop("sphere", mode="save")            # plot and save landscape of Sphere function
Tool.plot_sop("schwefel", plot_type="contour")  # plot contour plot of Schwefel function

List of Functions

Classical Single-Objective Optimization

Totally, 61 single-objective functions are implemented. The plot of 2D versions of 59 problems are provided. Please check the homepage of BenchmarkFcns Toolbox or this website for the further documentation.

Discrete Optimization

Under development ...

Multi-Objective Optimization

Under development ...

Real-World Optimization

Under development ...

Authors

Yifan He @ Dept. of CS, UTsukuba

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgement

PyBenchFCN is maintained by Yifan He. The author of this repostory is very grateful to Mr. Mazhar Ansari Ardeh, who implemented the MatLab package BenchFCNs Toolbox.

  • If you find any mistakes, please report at a new issue.
  • If you want to help me implement more benchmarks (discrete optimization, multi-objective optimization), please contact at he.yifan.xs@alumni.tsukuba.ac.jp.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyBenchFCN-1.0.3.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyBenchFCN-1.0.3-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file PyBenchFCN-1.0.3.tar.gz.

File metadata

  • Download URL: PyBenchFCN-1.0.3.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.4

File hashes

Hashes for PyBenchFCN-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d10fc0fec9f9c342c859b06c61369610e32fdfe6eeb7853159be3df71ce27b0c
MD5 4d0158d876715c3948467599d1dd5711
BLAKE2b-256 a280290a159344b3b38ea4c160e6eb9ba9e3893c475eef100bb2be8b45ce1908

See more details on using hashes here.

File details

Details for the file PyBenchFCN-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: PyBenchFCN-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.4

File hashes

Hashes for PyBenchFCN-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 940e7d3b23f91ca96a830a1eb62c22542ffb9d381daa55798d2bccd94604eaa0
MD5 b31d40595072bcf69a9e286ebe5fc867
BLAKE2b-256 c1ba12fc6e710774428b0aa7f5043d5b1e4bd2664e4c8a992d2dd92556a5cacc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page