This is a set of test functions which can be used to test the effectiveness of global optimization algorithms. Some are rather easy to optimize (rosenbrock, leon, ...), others next to impossible (crosslegtable, bukin6, ...).
All the test-functions are taken from either ,  or  (see below). All functions may be called in two ways:
[dims, lb, ub, sol, fval_sol] = fun()
(e.g., no input arguments) This returns the number of dimensions of the function, the default lower and upper bounds, the solution vectors for all global minima and the corresponding function values. To calculate the function value for input X, use:
val = fun( [x1, x2, ..., xn] )
with the dimension [n] depending on the specific function [fun] (for most functions, n=2). Note the single vector argument--this is done in order to easily insert the function into a global optimizer that inserts a [N x n] matrix of trial vectors in these functions.
I also included a function to display most of the functions. This is called EZIMAGE, and can be called with a function handle argument:
ezimage(@himmelblau) (to plot the himmelblau function)
ezimage(@sinenvsin) (see screenshot)
or just as-is:
which lists all functions and waits for user input. This is meant to get a first impression of what the challenges are the test function has to offer.
- constrained single-objective functions
- (constrained ) multi-objective functions
 Mishra, Sudhanshu. "Some new test functions for global optimization and performance of repulsive particle swarm method". MPRA, 23rd august 2006. http://mpra.ub.uni-muenchen.de/2718/
 Z.K. Silagadze. "Finding two-dimensional peaks". 11th mar 2004. arXiv preprint: arXiv:physics/0402085v3
 W. Sun, Ya-X. Yuan. "Optimization theory and Methods. Nonlinear Programming". Springer verlag, 2006. ISBN-13:978-0-387-24975-9.
If you find this work useful, please consider a small donation:
Fixed all bugs found by Jeffrey Larson (thanks!)
[linked to Github]
- Corrected bug in leon function (square -> cube)
- updated all functions to automate finding its dimensions/bounds
Inspired: Constrained Particle Swarm Optimization
Win cash prizes and have your live script featured on our websiteLearn more
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.