This software contains the source code of the CEC'2017 benchmark for bounds contraints in https://github.com/P-N-Suganthan/CEC2017-BoundContrained.
That benchmark is available for researchers, and for students.
In addition to original benchmark code it contains:
-
A file cec17.c with several functions, including a fitness functions that store in external files, with filename results__.txt in a directory results_.
-
A script, extrae.py to generate automatically the results ready to use tacolab.
For information about the benchmark you can read:
It requires the CMake tool to compile the source code in a shared library.
$ cmake .
Prepare the source code of the algorithms following the experimental conditions indicated in this file.
- Init the benchmark, using the cec17_init function:
cec17_init(<algname>, funcid, dimension)
when algname is the name of your algorithm (for the output file).
- Run your algorithm using cec17_fitness to evaluate each solution.
$ python extract.py results_<algname>
This program create the file results_cec2017_.xlsx ready to be submitted to tacolab
Go to (https://tacolab.org/bench) to compare.
-
Select CEC2017 benchmark.
-
Select the dimension to use for comparisons.
-
Select your reference algorithms for comparisons (PSO and DE are classic algorithms, the other are more advanced).
-
Fulfill the name of your algorithm (that will appears at the comparisons tables) and the Excel file.
-
Select the comparison tables: It can be selected a mean comparison, a ranking tables (in which the alagorithms are sorted by its mean, and the average is calculated), and non-parametric statistics.
-
Download the interesting comparisons tables in Excel and/or latex format.
-
Stopping criterion: the algorithm must stop when a maximum number of evaluations is achieved. The maximum number of evaluations is 10000*dimension (100,000 for dimension 10, 350,000 for dimension 30, ...).
-
Run: The algorithm must be run for 51 times, with different seed values. 3- Number of functions: 1-30.
-
Dimensions: 10, 30, 50, 100.
5in code/
there are several example functions. In the following, I in
extern "C" {
#include "cec17.h"
}
#include <iostream>
#include <vector>
#include <random>
using namespace std;
int main() {
vector<double> sol;
int dim = 10;
int seed = 42;
std::uniform_real_distribution<> dis(-100.0, 100.0);
for (int funcid = 1; funcid <= 30; funcid++) {
vector<double> sol(dim);
vector<double> bestsol(dim);
double fitness;
double best = -1;
// Set the function to use in fitness
cec17_init("random", funcid, dim);
// If it is commented the output is print in console, instead of external files.
// cec17_print_output();
std::mt19937 gen(seed); // Start seed
int evals = 0;
while (evals < 10000*dim) {
// Generate random solution
for (int i = 0; i < dim; i++) {
sol[i] = dis(gen);
}
// Evaluate the solution
fitness = cec17_fitness(&sol[0]);
// Increase count
evals += 1;
// Calculate the best one
if (evals == 1 || fitness < best) {
best = fitness;
bestsol = sol;
}
}
// Show the error of the best solution
cout <<"Best Random[F" <<funcid <<"]: " << scientific <<cec17_error(best) <<endl;
}
}
We have included a wrapper in Python, and we are open to wrapper in more languages, feel free to submit a push request.
This source code includes the source code freely available at https://github.com/P-N-Suganthan/CEC2017-BoundContrained, with its license. The rest of source code is available as MIT LICENSE.
The function F02 was removed from benchmark because there were inconsistencies between implementations. However, in this code we have included it because it was included in tacolab.
API obtained by the doxygen and thanks to (https://delight-im.github.io/Javadoc-to-Markdown/).
Init the fitness function and dimension.
- Parameters:
algname
— (results will be copy to results_algname directory).funcid
— must be between 1 and 30.dimension
— must be 2, 5, 10, 30, 50, or 100.
Desactivate the output to external files, instead it will be shown at the console.
Return the error related with the fitness.
- Parameters:
fitness
— to compare. - Returns: error (fitness - optimum).
The fitness function to evaluate from the solution.
- Parameters:
sol
— solution to evaluate. - Returns: fitness value.