-
Notifications
You must be signed in to change notification settings - Fork 0
2. Getting started
Iannick Gagnon edited this page May 19, 2025
·
13 revisions
The MDAF_objective_functions library provides a variety of well-known objective functions that you can import as follows:
from MDAF_objective_functions import Ackley, Rastrigin, StyblinskiTang, DropWaveTo see a list of all available objective functions:
>>> import MDAF_objective_functions as of
>>> of.show_all()
Ackley
Buckin6
DropWave
...Each ObjectiveFunction class provides a .visualize() method for quick 2D/3D visualizations:
>>> from MDAF_objective_functions import Bukin6
>>> Bukin6().visualize()The previous commands will generate the following interactive graph:
Note: The star (⭐) symbol represents the global minimum.
To evaluate a function at a single position:
>>> from MDAF_objective_functions import Sphere
>>> foo = Sphere()
>>> val = foo.evaluate(np.array([[1, 1]]))
>>> print(val)
[2]To evaluate a function at multiple positions:
>>> from MDAF_objective_functions import Sphere
>>> foo = Sphere()
>>> val = foo.evaluate(np.array([[1, 1], [2, 2]]))
>>> print(val)
[2, 8]You can also customize the visualization by passing parameters such as dimensions, bounds, and resolution. See the ObjectiveFunction class documentation for details.