Benchmark functions
Usage
Creating the function
First we make a 2-dimensional continous design space with the helper function make_nd_continuous_design():
bounds = np.array([[-1.0, 1.0], [-1.0, 1.0]])
design = f3dasm.make_nd_continuous_design(bounds=bounds, dimensions=2)
Then we create an object of the Sphere class, specifying the dimensionality:
sphere_function = f3dasm.functions.Sphere(dimensionality=dim, scale_bounds=bounds)
Evaluating the function
The function can be evaluated by directly calling the object
x = np.array([0.5, 0.8])
>>> sphere_function(x)
... array([[23.330816]])
Gradient
The gradient of a function can be estimated by calling the dfdx() function:
>>> sphere_function.dfdx(x)
... array([[26.2144 , 41.94304]])
The gradient is estimated using the numdifftools package.
Plotting
We can plot a 3D or 2D representation of the loss landscape:
sphere_function.plot(orientation="3D", domain=bounds)
img
sphere_function.plot(orientation="2D", domain=bounds)
img
Implement your own benchmark functions
Implemented benchmark functions
The following implementations of benchmark functions can found under the f3dasm.functions module.
These are taken and modified from the Python Benchmark Test Optimization Function Single Objective github repository.
Convex functions
Name |
Docs of the Python class |
|---|---|
Ackley N. 2 |
|
Bohachevsky N. 1 |
|
Booth |
|
Brent |
|
Brown |
|
Bukin N. 6 |
|
Dixon Price |
|
Exponential |
|
Matyas |
|
McCormick |
|
Perm 0, d, beta |
|
Powell |
|
Rotated Hyper-Ellipsoid |
|
Schwefel 2.20 |
|
Schwefel 2.21 |
|
Schwefel 2.22 |
|
Schwefel 2.23 |
|
Sphere |
|
Sum Squares |
|
Thevenot |
|
Trid |
|
Xin She Yang N.3 |
|
Xin-She Yang N.4 |
|
Seperable functions
Name |
Docs of the Python class |
|---|---|
Ackley |
|
Bohachevsky N. 1 |
|
Easom |
|
Egg Crate |
|
Exponential |
|
Griewank |
|
Michalewicz |
|
Powell |
|
Qing |
|
Quartic |
|
Rastrigin |
|
Schwefel |
|
Schwefel 2.20 |
|
Schwefel 2.21 |
|
Schwefel 2.22 |
|
Schwefel 2.23 |
|
Sphere |
|
Styblinski Tank |
|
Sum Squares |
|
Thevenot |
|
Xin She Yang |
|
Differentiable functions
Name |
Docs of the Python class |
|---|---|
Ackley |
|
Ackley N. 2 |
|
Ackley N. 3 |
|
Ackley N. 4 |
|
Adjiman |
|
Beale |
|
Bird |
|
Bohachevsky N. 1 |
|
Bohachevsky N. 2 |
|
Bohachevsky N. 3 |
|
Booth |
|
Branin |
|
Brent |
|
Brown |
|
Colville |
|
De Jong N. 5 |
|
Deckkers-Aarts |
|
Dixon Price |
|
Drop-Wave |
|
Easom |
|
Egg Crate |
|
Egg Holder |
|
Exponential |
|
Goldstein-Price |
|
Griewank |
|
Happy Cat |
|
Himmelblau |
|
Keane |
|
Langermann |
|
Leon |
|
Levy |
|
Levy N. 13 |
|
Matyas |
|
McCormick |
|
Michalewicz |
|
Periodic |
|
Perm d, beta |
|
Perm 0, d, beta |
|
Qing |
|
Quartic |
|
Rastrigin |
|
Ridge |
|
Rosenbrock |
|
Rotated Hyper-Ellipsoid |
|
Salomon |
|
Schaffel N. 1 |
|
Schaffel N. 2 |
|
Schaffel N. 3 |
|
Schaffel N. 4 |
|
Shekel |
|
Shubert |
|
Shubert N. 3 |
|
Shubert N. 4 |
|
Styblinski Tank |
|
Sum Squares |
|
Thevenot |
|
Three-Hump |
|
Trid |
|
Xin She Yang N.3 |
|
Multimodal functions
Name |
Docs of the Python class |
|---|---|
Ackley |
|
Ackley N. 3 |
|
Ackley N. 4 |
|
Adjiman |
|
Bartels |
|
Beale |
|
Bird |
|
Bohachevsky N. 2 |
|
Bohachevsky N. 3 |
|
Branin |
|
Bukin N. 6 |
|
Colville |
|
Cross-in-Tray |
|
De Jong N. 5 |
|
Deckkers-Aarts |
|
Easom |
|
Egg Crate |
|
Egg Holder |
|
Goldstein-Price |
|
Happy Cat |
|
Himmelblau |
|
Holder-Table |
|
Keane |
|
Langermann |
|
Levy |
|
Levy N. 13 |
|
McCormick |
|
Michalewicz |
|
Periodic |
|
Perm d, beta |
|
Qing |
|
Quartic |
|
Rastrigin |
|
Rosenbrock |
|
Salomon |
|
Schwefel |
|
Shekel |
|
Shubert |
|
Shubert N. 3 |
|
Shubert N. 4 |
|
Styblinski Tank |
|
Thevenot |
|
Xin She Yang |
|
Xin She Yang N.2 |
|
Functions including a randomized term
Name |
Docs of the Python class |
|---|---|
Quartic |
|
Xin She Yang |
|