Metadata-Version: 2.4
Name: coo-algorithm
Version: 4.0.0
Summary: COO: a cost-aware evolutionary optimizer for box-constrained black-box problems (SHADE population for cheap objectives; knowledge-map-guided packs with a surrogate for expensive objectives)
Author-email: Sandip Garai <sandipnicksandy@gmail.com>
Maintainer-email: Sandip Garai <sandipnicksandy@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://sandipgarai.github.io/coo_algorithm/
Project-URL: Documentation, https://github.com/SandipGarai/coo_algorithm/blob/main/README.md
Project-URL: Repository, https://github.com/SandipGarai/coo_algorithm
Project-URL: Issues, https://github.com/SandipGarai/coo_algorithm/issues
Project-URL: Paper code and data, https://github.com/SandipGarai/coo-study
Keywords: optimization,black-box,evolutionary,differential evolution,SHADE,surrogate,expensive optimization,hyperparameter-tuning,metaheuristic
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.22
Requires-Dist: scipy>=1.8
Requires-Dist: scikit-learn>=1.1
Requires-Dist: joblib>=1.1
Provides-Extra: full
Requires-Dist: lightgbm>=4.0; extra == "full"
Requires-Dist: cma>=3.3.0; extra == "full"
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Dynamic: license-file

# coo-algorithm

A component-based, cost-aware population optimizer for box-constrained black-box
problems. COO combines SHADE-style differential evolution, an optional grid-based
knowledge map of evaluated points, and an optional surrogate model (random forest or
Gaussian process) that proposes new points. A short cost probe decides whether the
objective is cheap (one SHADE population, no surrogate) or expensive (three
sub-populations, knowledge-map guidance and surrogate proposals).

The name COO comes from the first release ("Canine Olfactory Optimization"); the
current version is described in standard optimization terms.

```bash
pip install coo-algorithm
```

## Quick start

COO **maximises** the function it is given, so pass `-f` to minimise `f`.

```python
import numpy as np
from coo_algorithm import make_coo

def sphere(x):
    return float(np.sum(np.asarray(x) ** 2))

opt = make_coo(bounds=[(-5.0, 5.0)] * 10, preset="adaptive",
               max_iterations=200, random_state=0)
best_x, best_value, history, diagnostics, _ = opt.optimize(lambda x: -sphere(x))
print(best_x, -best_value)
```

## Presets

| preset | use it when | components |
|---|---|---|
| `"adaptive"` (default) | general use | cost probe; cheap -> panmictic SHADE; expensive -> packs + map + trust-region GP + EI |
| `"rf"` | expensive objectives, d up to about 20 | pack moves, knowledge map, global random-forest surrogate, UCB proposals |
| `"islands"` | studying sub-population effects | SHADE moves in 3 packs, map-guided mutation, GP surrogate |

In our evaluation (see the repository below) the `rf` preset performed on a par with
TPE on expensive 10-dimensional problems with 200–500 evaluations, and the `adaptive`
preset behaved like a SHADE variant on cheap CEC 2017/2022 functions. EGO was better
at the smallest budgets. Every preset accepts any keyword of `COO`, e.g.
`make_coo(bounds, "rf", surrogate_retrain_freq=5)`.

To stop after an exact number of objective evaluations, raise an exception from your
objective wrapper when the budget is reached; the best exactly evaluated point is
available as `opt.best_position` / `opt.best_fitness` in your bounds.

## Earlier releases

`coo_algorithm.legacy.v1_1_1` (first release), `.v2_2_0` and `.v3_0_0` are frozen
copies kept for reproducibility. Releases 2.2.0 and 3.0.0 are reproduced exactly by
the `rf` and `islands` presets. Release 1.1.1 contained two defects (its surrogate
was never trained, and its step sizes depended on the scale of the bounds); do not use
it for new work.

## Tests

```bash
pip install coo-algorithm[test]
pytest            # from the package folder; about 12 minutes on one CPU core
```

## Citation and source

Author and maintainer: Sandip Garai (sandipnicksandy@gmail.com)
Package homepage: https://sandipgarai.github.io/coo_algorithm/ · source: https://github.com/SandipGarai/coo_algorithm
Code and data of the accompanying paper: https://github.com/SandipGarai/coo-study
Licence: MIT.
