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

f3dasm.functions.pybenchfunction.AckleyN2

Bohachevsky N. 1

f3dasm.functions.pybenchfunction.BohachevskyN1

Booth

f3dasm.functions.pybenchfunction.Booth

Brent

f3dasm.functions.pybenchfunction.Brent

Brown

f3dasm.functions.pybenchfunction.Brown

Bukin N. 6

f3dasm.functions.pybenchfunction.BukinN6

Dixon Price

f3dasm.functions.pybenchfunction.DixonPrice

Exponential

f3dasm.functions.pybenchfunction.Exponential

Matyas

f3dasm.functions.pybenchfunction.Matyas

McCormick

f3dasm.functions.pybenchfunction.McCormick

Perm 0, d, beta

f3dasm.functions.pybenchfunction.PermZeroDBeta

Powell

f3dasm.functions.pybenchfunction.Powell

Rotated Hyper-Ellipsoid

f3dasm.functions.pybenchfunction.RotatedHyperEllipsoid

Schwefel 2.20

f3dasm.functions.pybenchfunction.Schwefel2_20

Schwefel 2.21

f3dasm.functions.pybenchfunction.Schwefel2_21

Schwefel 2.22

f3dasm.functions.pybenchfunction.Schwefel2_22

Schwefel 2.23

f3dasm.functions.pybenchfunction.Schwefel2_23

Sphere

f3dasm.functions.pybenchfunction.Sphere

Sum Squares

f3dasm.functions.pybenchfunction.SumSquares

Thevenot

f3dasm.functions.pybenchfunction.Thevenot

Trid

f3dasm.functions.pybenchfunction.Trid

Xin She Yang N.3

f3dasm.functions.pybenchfunction.XinSheYangN3

Xin-She Yang N.4

f3dasm.functions.pybenchfunction.XinSheYangN4

Seperable functions

Name

Docs of the Python class

Ackley

f3dasm.functions.pybenchfunction.Ackley

Bohachevsky N. 1

f3dasm.functions.pybenchfunction.BohachevskyN1

Easom

f3dasm.functions.pybenchfunction.Easom

Egg Crate

f3dasm.functions.pybenchfunction.EggCrate

Exponential

f3dasm.functions.pybenchfunction.Exponential

Griewank

f3dasm.functions.pybenchfunction.Griewank

Michalewicz

f3dasm.functions.pybenchfunction.Michalewicz

Powell

f3dasm.functions.pybenchfunction.Powell

Qing

f3dasm.functions.pybenchfunction.Qing

Quartic

f3dasm.functions.pybenchfunction.Quartic

Rastrigin

f3dasm.functions.pybenchfunction.Rastrigin

Schwefel

f3dasm.functions.pybenchfunction.Schwefel

Schwefel 2.20

f3dasm.functions.pybenchfunction.Schwefel2_20

Schwefel 2.21

f3dasm.functions.pybenchfunction.Schwefel2_21

Schwefel 2.22

f3dasm.functions.pybenchfunction.Schwefel2_22

Schwefel 2.23

f3dasm.functions.pybenchfunction.Schwefel2_23

Sphere

f3dasm.functions.pybenchfunction.Sphere

Styblinski Tank

f3dasm.functions.pybenchfunction.StyblinskiTank

Sum Squares

f3dasm.functions.pybenchfunction.SumSquares

Thevenot

f3dasm.functions.pybenchfunction.Thevenot

Xin She Yang

f3dasm.functions.pybenchfunction.XinSheYang

Differentiable functions

Name

Docs of the Python class

Ackley

f3dasm.functions.pybenchfunction.Ackley

Ackley N. 2

f3dasm.functions.pybenchfunction.AckleyN2

Ackley N. 3

f3dasm.functions.pybenchfunction.AckleyN3

Ackley N. 4

f3dasm.functions.pybenchfunction.AckleyN4

Adjiman

f3dasm.functions.pybenchfunction.Adjiman

Beale

f3dasm.functions.pybenchfunction.Beale

Bird

f3dasm.functions.pybenchfunction.Bird

Bohachevsky N. 1

f3dasm.functions.pybenchfunction.BohachevskyN1

Bohachevsky N. 2

f3dasm.functions.pybenchfunction.BohachevskyN2

Bohachevsky N. 3

f3dasm.functions.pybenchfunction.BohachevskyN3

Booth

f3dasm.functions.pybenchfunction.Booth

Branin

f3dasm.functions.pybenchfunction.Branin

Brent

f3dasm.functions.pybenchfunction.Brent

Brown

f3dasm.functions.pybenchfunction.Brown

Colville

f3dasm.functions.pybenchfunction.Colville

De Jong N. 5

f3dasm.functions.pybenchfunction.DeJongN5

Deckkers-Aarts

f3dasm.functions.pybenchfunction.DeckkersAarts

Dixon Price

f3dasm.functions.pybenchfunction.DixonPrice

Drop-Wave

f3dasm.functions.pybenchfunction.DropWave

Easom

f3dasm.functions.pybenchfunction.Easom

Egg Crate

f3dasm.functions.pybenchfunction.EggCrate

Egg Holder

f3dasm.functions.pybenchfunction.EggHolder

Exponential

f3dasm.functions.pybenchfunction.Exponential

Goldstein-Price

f3dasm.functions.pybenchfunction.GoldsteinPrice

Griewank

f3dasm.functions.pybenchfunction.Griewank

Happy Cat

f3dasm.functions.pybenchfunction.HappyCat

Himmelblau

f3dasm.functions.pybenchfunction.Himmelblau

Keane

f3dasm.functions.pybenchfunction.Keane

Langermann

f3dasm.functions.pybenchfunction.Langermann

Leon

f3dasm.functions.pybenchfunction.Leon

Levy

f3dasm.functions.pybenchfunction.Levy

Levy N. 13

f3dasm.functions.pybenchfunction.LevyN13

Matyas

f3dasm.functions.pybenchfunction.Matyas

McCormick

f3dasm.functions.pybenchfunction.McCormick

Michalewicz

f3dasm.functions.pybenchfunction.Michalewicz

Periodic

f3dasm.functions.pybenchfunction.Periodic

Perm d, beta

f3dasm.functions.pybenchfunction.PermDBeta

Perm 0, d, beta

f3dasm.functions.pybenchfunction.PermZeroDBeta

Qing

f3dasm.functions.pybenchfunction.Qing

Quartic

f3dasm.functions.pybenchfunction.Quartic

Rastrigin

f3dasm.functions.pybenchfunction.Rastrigin

Ridge

f3dasm.functions.pybenchfunction.Ridge

Rosenbrock

f3dasm.functions.pybenchfunction.Rosenbrock

Rotated Hyper-Ellipsoid

f3dasm.functions.pybenchfunction.RotatedHyperEllipsoid

Salomon

f3dasm.functions.pybenchfunction.Salomon

Schaffel N. 1

f3dasm.functions.pybenchfunction.SchaffelN1

Schaffel N. 2

f3dasm.functions.pybenchfunction.SchaffelN2

Schaffel N. 3

f3dasm.functions.pybenchfunction.SchaffelN3

Schaffel N. 4

f3dasm.functions.pybenchfunction.SchaffelN4

Shekel

f3dasm.functions.pybenchfunction.Shekel

Shubert

f3dasm.functions.pybenchfunction.Shubert

Shubert N. 3

f3dasm.functions.pybenchfunction.ShubertN3

Shubert N. 4

f3dasm.functions.pybenchfunction.ShubertN4

Styblinski Tank

f3dasm.functions.pybenchfunction.StyblinskiTank

Sum Squares

f3dasm.functions.pybenchfunction.SumSquares

Thevenot

f3dasm.functions.pybenchfunction.Thevenot

Three-Hump

f3dasm.functions.pybenchfunction.ThreeHump

Trid

f3dasm.functions.pybenchfunction.Trid

Xin She Yang N.3

f3dasm.functions.pybenchfunction.XinSheYangN3

Multimodal functions

Name

Docs of the Python class

Ackley

f3dasm.functions.pybenchfunction.Ackley

Ackley N. 3

f3dasm.functions.pybenchfunction.AckleyN3

Ackley N. 4

f3dasm.functions.pybenchfunction.AckleyN4

Adjiman

f3dasm.functions.pybenchfunction.Adjiman

Bartels

f3dasm.functions.pybenchfunction.Bartels

Beale

f3dasm.functions.pybenchfunction.Beale

Bird

f3dasm.functions.pybenchfunction.Bird

Bohachevsky N. 2

f3dasm.functions.pybenchfunction.BohachevskyN2

Bohachevsky N. 3

f3dasm.functions.pybenchfunction.BohachevskyN3

Branin

f3dasm.functions.pybenchfunction.Branin

Bukin N. 6

f3dasm.functions.pybenchfunction.BukinN6

Colville

f3dasm.functions.pybenchfunction.Colville

Cross-in-Tray

f3dasm.functions.pybenchfunction.CrossInTray

De Jong N. 5

f3dasm.functions.pybenchfunction.DeJongN5

Deckkers-Aarts

f3dasm.functions.pybenchfunction.DeckkersAarts

Easom

f3dasm.functions.pybenchfunction.Easom

Egg Crate

f3dasm.functions.pybenchfunction.EggCrate

Egg Holder

f3dasm.functions.pybenchfunction.EggHolder

Goldstein-Price

f3dasm.functions.pybenchfunction.GoldsteinPrice

Happy Cat

f3dasm.functions.pybenchfunction.HappyCat

Himmelblau

f3dasm.functions.pybenchfunction.Himmelblau

Holder-Table

f3dasm.functions.pybenchfunction.HolderTable

Keane

f3dasm.functions.pybenchfunction.Keane

Langermann

f3dasm.functions.pybenchfunction.Langermann

Levy

f3dasm.functions.pybenchfunction.Levy

Levy N. 13

f3dasm.functions.pybenchfunction.LevyN13

McCormick

f3dasm.functions.pybenchfunction.McCormick

Michalewicz

f3dasm.functions.pybenchfunction.Michalewicz

Periodic

f3dasm.functions.pybenchfunction.Periodic

Perm d, beta

f3dasm.functions.pybenchfunction.PermDBeta

Qing

f3dasm.functions.pybenchfunction.Qing

Quartic

f3dasm.functions.pybenchfunction.Quartic

Rastrigin

f3dasm.functions.pybenchfunction.Rastrigin

Rosenbrock

f3dasm.functions.pybenchfunction.Rosenbrock

Salomon

f3dasm.functions.pybenchfunction.Salomon

Schwefel

f3dasm.functions.pybenchfunction.Schwefel

Shekel

f3dasm.functions.pybenchfunction.Shekel

Shubert

f3dasm.functions.pybenchfunction.Shubert

Shubert N. 3

f3dasm.functions.pybenchfunction.ShubertN3

Shubert N. 4

f3dasm.functions.pybenchfunction.ShubertN4

Styblinski Tank

f3dasm.functions.pybenchfunction.StyblinskiTank

Thevenot

f3dasm.functions.pybenchfunction.Thevenot

Xin She Yang

f3dasm.functions.pybenchfunction.XinSheYang

Xin She Yang N.2

f3dasm.functions.pybenchfunction.XinSheYangN2

Functions including a randomized term

Name

Docs of the Python class

Quartic

f3dasm.functions.pybenchfunction.Quartic

Xin She Yang

f3dasm.functions.pybenchfunction.XinSheYang