Git Product home page Git Product logo

cec2017-py's Introduction

CEC 2017 Python

Python 3 module containing a native implementation of the CEC 2017 benchmark functions (single objective optimization). The implementation is adapted from Awad's original C implementation, available on Suganthan's GitHub repo, along with the problem definitions [1].

Although there are wrappers for the C code, this module is easier to use, natively supports numpy arrays and is (much) more readable than the C implementation.

During the implementation of this module, a few differences between the problem definitions and the original code were picked up on. In these cases, the implementation always follows whatever the original code did to remain compatible, and are marked with Note: comments.

As per the problem definitions, functions are defined for 10, 30, 50 and 100 dimensions, with functions f1 to f10 and f21 to f28 also being defined for 2 and 20 dimensions. If you provide custom rotation matrices (and shuffles, where applicable) you can however use arbitrary dimensions. Below are some surface plots for functions f1 to f10 over 2 dimensions.

Function Surface Plots

[1] Awad, N. H., Ali, M. Z., Suganthan, P. N., Liang, J. J., & Qu, B. Y. (2016). Problem Definitions and Evaluation Criteria for the CEC 2017 Special Session and Competition on Single Objective Bound Constrained Real-Parameter Numerical Optimization.

Features

  • Native implementation of all CEC 2017 single objective functions
  • Pre-defined rotations, shifts and shuffles for 2, 10, 20, 30, 50 and 100 dimensions
  • Allows custom rotations, shifts and shuffles
  • Convenient surface plot utility
  • Easy access to basic functions f1 to f19 (e.g. Ackley, Discus, etc.)

Installation

git clone https://github.com/tilleyd/cec2017-py
cd cec2017-py
python3 setup.py install

Usage

Below is a simple example of executing either a single function or all functions. See example.py for more advanced use cases.

# Using only f5:
from cec2017.functions import f5
x = np.random.uniform(-100, 100, size=50)
val = f5(x)
print('f5(x) = %.6f' %val)

# Using all functions:
from cec2017.functions import all_functions
for f in all_functions:
    x = np.random.uniform(-100, 100, size=50)
    val = f(x)
    print('%s(x) = %.6f' %( f.__name__, val ))

License

Copyright © 2020 Duncan Tilley See the license notice for full details.

Issues

If you see any issues or possible improvements, please open an issue or feel free to make a pull request.

cec2017-py's People

Contributors

lukaa12 avatar tilleyd avatar

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.