|
| 1 | +# Toy continuous objective functions |
| 2 | + |
| 3 | + |
| 4 | + |
| 6 | + |
| 7 | +## About |
| 8 | + |
| 9 | +These are the usual objective function people use to test continuous optimizers {cite:p}`Al-Roomi:continuous_objective_benchmarks:2015`. In particular, we include: |
| 10 | + |
| 11 | +- For $n$-dimensional optimization: |
| 12 | + - [`ackley_function_01`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/227-ackley-s-function-no-1-or-ackley-s-path-function), |
| 13 | + - [`alpine_01`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/162-alpine-function-no-1), |
| 14 | + - [`alpine_02`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/163-alpine-function-no-2), |
| 15 | + - [`bent_cigar`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/164-bent-cigar-function), |
| 16 | + - [`brown`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/241-brown-s-function), |
| 17 | + - [`chung_reynolds`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/165-chung-reynolds-function), |
| 18 | + - [`cosine_mixture`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/166-cosine-mixture-function), |
| 19 | + - [`deb_01`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/231-deb-s-function-no-01), |
| 20 | + - [`deb_02`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/232-deb-s-function-no-02), |
| 21 | + - [`deflected_corrugated_spring`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/238-deflected-corrugated-spring-function), |
| 22 | + - `shifted_sphere` ($\sum_{d=1}^n (x_d - 1)^2$), |
| 23 | + - [`egg_holder`](https://www.al-roomi.org/benchmarks/unconstrained/n-dimensions/187-egg-holder-function), |
| 24 | +- For specific dimensions: |
| 25 | + - [`easom`](https://www.al-roomi.org/benchmarks/unconstrained/2-dimensions/22-easom-s-function), which is only available in 2 dimensions. |
| 26 | + - [`cross_in_tray`](https://www.al-roomi.org/benchmarks/unconstrained/2-dimensions/44-cross-in-tray-function), which is only available in 2 dimensions. |
| 27 | + |
| 28 | +:::{warning} |
| 29 | + |
| 30 | +Some of the signs might be flipped, since we are usually interested in maximization. Some of the constants inside might also be changed for scale. [For the definitive version we used, check the implementation](https://github.com/MachineLearningLifeScience/poli/blob/dev/src/poli/objective_repository/toy_continuous_problem/definitions.py). |
| 31 | + |
| 32 | +::: |
| 33 | + |
| 34 | +## Prerequisites |
| 35 | + |
| 36 | +None, this function should always run out-of-the-box |
| 37 | + |
| 38 | +## How to run |
| 39 | + |
| 40 | +```python |
| 41 | +import numpy as np |
| 42 | +from poli import objective_factory |
| 43 | + |
| 44 | +# Choose a function name and number of dimensions |
| 45 | +function_name = "ackley_function_01" |
| 46 | +n_dimensions = 2 # it's 2 by default. |
| 47 | + |
| 48 | +# How to create |
| 49 | +problem_info, f, x0, y0, run_info = objective_factory.create( |
| 50 | + name="toy_continuous_problem", |
| 51 | + function_name=function_name, |
| 52 | + n_dimensions=n_dimensions, # For some, this can be arbitrary. |
| 53 | +) |
| 54 | + |
| 55 | + |
| 56 | +# Example input: |
| 57 | +x = np.array([[0.0, 0.0]]) # must be of shape [b, n_dimensions], in this case [1, 2]. |
| 58 | + |
| 59 | +# Querying: |
| 60 | +print(f(x)) # Should be [[0.0]] in this example |
| 61 | +``` |
0 commit comments