Giter Club home page Giter Club logo

cec20_python's Introduction

repository based on https://github.com/lacerdamarcelo/cec17_python/

CEC 2020 - Benchmark Functions (Bound Constrained) in Python

Very simple Python wrapper function for the benchmark functions of the CEC 2020 Special Session and Competition on Single Objective Bound Constrained Real-Parameter Numerical Optimization, originally written in CPP.

Instructions

First you have to compile the original file where the CEC20 functions are written in C. In my computer, running on a Ubuntu 20.04 and GCC 11.2.0, in the same directory as the .c file I enter the following command on terminal:

gcc -fPIC -shared -lm -o cec20_test_func.so cec20_test_func.cpp

This command is going to generate a file called cec20_test_func.so, which is going to be used by the wrapper function 'cec20_test_func' in the module 'cec20_functions'.

Since there is no pip installation, you'll have to manually include these files on your project so that you would have access to them. After doing that, you might be able to call 'cec20_test_func' function and compute the fitness value of a given solution vector. Don't forget to also copy 'input_data' to your project's directory.

In order to call the 'cec20_test_func' function, first you need to import it from 'cec20_functions'.

from cec20_functions import cec20_test_func

The following lines is just me creating the arguments necessary to demonstrate how to call the function.

# x: Solution vector
x = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# nx: Number of dimensions
nx = 10
# mx: Number of objective functions
mx = 1
# func_num: Function number
func_num = 1
# Pointer for the calculated fitness
f = [0]

This is how you call the function, just like in the original code in C (same order of the arguments):

cec20_test_func(x, f, nx, mx, func_num)

The result is stored in the vector 'f'. If mx==1, only the first element of โ€˜fโ€™ is used.

# This line is going to print 29975432515.940056
print(f[0])

Original implementation (in C)

https://github.com/P-N-Suganthan/2020-Bound-Constrained-Opt-Benchmark

cec20_python's People

Contributors

rodrigoclira avatar

Watchers

 avatar  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.