|
| 1 | +# Author: Simon Blanke |
| 2 | + |
| 3 | +# License: MIT License |
| 4 | + |
| 5 | +"""Pre-defined function presets for standardized optimizer testing. |
| 6 | +
|
| 7 | +This module provides curated collections of test functions for different |
| 8 | +benchmarking scenarios. Using standardized presets enables: |
| 9 | +
|
| 10 | +- Comparable results across different papers and projects |
| 11 | +- Appropriate function selection for specific use cases |
| 12 | +- Reduced boilerplate when setting up benchmarks |
| 13 | +
|
| 14 | +Available Presets |
| 15 | +----------------- |
| 16 | +quick : list |
| 17 | + 5 functions for fast sanity checks during development. |
| 18 | +
|
| 19 | +standard : list |
| 20 | + 15 well-known functions covering diverse landscape types. |
| 21 | +
|
| 22 | +algebraic_2d : list |
| 23 | + All 2D algebraic functions (18 functions). |
| 24 | +
|
| 25 | +algebraic_nd : list |
| 26 | + N-dimensional scalable functions (5 functions). |
| 27 | +
|
| 28 | +bbob : list |
| 29 | + Full BBOB/COCO benchmark (24 functions). |
| 30 | +
|
| 31 | +cec2014 : list |
| 32 | + CEC 2014 competition functions (30 functions). |
| 33 | +
|
| 34 | +cec2017 : list |
| 35 | + CEC 2017 simple functions (10 functions). |
| 36 | +
|
| 37 | +engineering : list |
| 38 | + Constrained engineering design problems (5 functions). |
| 39 | +
|
| 40 | +Examples |
| 41 | +-------- |
| 42 | +2D functions instantiate directly: |
| 43 | +
|
| 44 | +>>> from surfaces.presets import algebraic_2d |
| 45 | +>>> for FuncClass in algebraic_2d: |
| 46 | +... func = FuncClass() |
| 47 | +... result = optimizer.minimize(func) |
| 48 | +
|
| 49 | +N-dimensional functions require n_dim parameter: |
| 50 | +
|
| 51 | +>>> from surfaces.presets import algebraic_nd |
| 52 | +>>> for FuncClass in algebraic_nd: |
| 53 | +... func = FuncClass(n_dim=10) |
| 54 | +... result = optimizer.minimize(func) |
| 55 | +
|
| 56 | +Use instantiate() for mixed presets: |
| 57 | +
|
| 58 | +>>> from surfaces.presets import standard, instantiate |
| 59 | +>>> functions = instantiate(standard, n_dim=10) |
| 60 | +>>> for func in functions: |
| 61 | +... result = optimizer.minimize(func) |
| 62 | +
|
| 63 | +Notes |
| 64 | +----- |
| 65 | +All presets contain function **classes**, not instances. This allows |
| 66 | +customization of parameters (n_dim, instance, etc.) when instantiating. |
| 67 | +
|
| 68 | +Function classes fall into two categories: |
| 69 | +
|
| 70 | +1. **Fixed-dimension** (algebraic_2d, engineering): Instantiate with FuncClass(). |
| 71 | +2. **Scalable** (algebraic_nd, bbob, cec2014, cec2017): Require FuncClass(n_dim=N). |
| 72 | +
|
| 73 | +The `quick` and `standard` presets contain a mix of both types. |
| 74 | +Use `instantiate()` to handle this automatically. |
| 75 | +""" |
| 76 | + |
| 77 | +from .suites import ( |
| 78 | + quick, |
| 79 | + standard, |
| 80 | + algebraic_2d, |
| 81 | + algebraic_nd, |
| 82 | + bbob, |
| 83 | + cec2014, |
| 84 | + cec2017, |
| 85 | + engineering, |
| 86 | +) |
| 87 | + |
| 88 | +from .utilities import ( |
| 89 | + instantiate, |
| 90 | + get, |
| 91 | + list_presets, |
| 92 | +) |
| 93 | + |
| 94 | +__all__ = [ |
| 95 | + # Presets |
| 96 | + 'quick', |
| 97 | + 'standard', |
| 98 | + 'algebraic_2d', |
| 99 | + 'algebraic_nd', |
| 100 | + 'bbob', |
| 101 | + 'cec2014', |
| 102 | + 'cec2017', |
| 103 | + 'engineering', |
| 104 | + # Utilities |
| 105 | + 'instantiate', |
| 106 | + 'get', |
| 107 | + 'list_presets', |
| 108 | +] |
0 commit comments