Setup objective function (benchmark or custom)

The simple way to test the optymus methods is via benchmark functions.

You can check a complete list of functions in our documentation.

Benchmark functions

[1]:
#import a function in benchmark
from optymus.benchmark import Mccormick
from optymus.plots import plot_function

# instatiate the function
f = Mccormick()

# plot the function
plot_function(f_obj=f, n_levels=200)

Custom funtions

If you need define a specif objective function use the CustomFunction class.

[2]:
#import the custom function class in benchmark
from optymus.benchmark import CustomFunction


# define the function
def my_function(x):
    return x[0] ** 2 + x[1] ** 2

# instatiate the function
f = CustomFunction(my_function)

# plot the function
plot_function(f_obj=f)