Metadata-Version: 2.4
Name: gmpb
Version: 0.1.0
Summary: A Python implementation of the Generalized Moving Peaks Benchmark
Author: The Design Research Collective
License-Expression: MIT
Keywords: benchmark,dynamic-optimization,gmpb,moving-peaks,numpy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy<3,>=1.24
Provides-Extra: dev
Requires-Dist: build<2,>=1.2; extra == "dev"
Requires-Dist: mypy<2,>=1.10; extra == "dev"
Requires-Dist: pre-commit<5,>=3.7; extra == "dev"
Requires-Dist: pytest<9,>=8.2; extra == "dev"
Requires-Dist: pytest-cov<8,>=7.0; extra == "dev"
Requires-Dist: ruff<1,>=0.6.0; extra == "dev"
Requires-Dist: sphinx<9,>=7.4; extra == "dev"
Requires-Dist: sphinx-rtd-theme<4,>=2.0; extra == "dev"
Requires-Dist: twine<7,>=5.1; extra == "dev"
Requires-Dist: uv<1,>=0.6; extra == "dev"
Provides-Extra: viz
Requires-Dist: matplotlib<4,>=3.8; extra == "viz"
Dynamic: license-file

# gmpb

This Python implementation follows the Generalized Moving Peaks Benchmark introduced by Danial Yazdani, Michalis Mavrovouniotis, Changhe Li, Guoyu Chen, Wenjian Luo, Mohammad Nabi Omidvar, Juergen Branke, Shengxiang Yang, and Xin Yao.

`gmpb` is a small, reusable, MIT-licensed implementation of the fully
non-separable GMPB formulation described in the paper
“Competition on Dynamic Optimization Problems Generated by Generalized Moving
Peaks Benchmark (GMPB)”. The core library intentionally does not depend on or
derive its implementation from the original MATLAB/Octave codebase.

## Quick Start

Requires Python 3.10+.

```bash
python -m venv .venv
source .venv/bin/activate
make dev
make test
```

```python
import numpy as np

from gmpb import GMPB, GMPBConfig

config = GMPBConfig(d=5, m=10, change_frequency=5000)
problem = GMPB(config, seed=7)

value = problem.evaluate(np.zeros(config.d))
batch = problem.evaluate_batch(np.random.default_rng(0).normal(size=(32, config.d)))
```

## Public API

The stable import surface for `0.1.x` is:

```python
from gmpb import GMPB, GMPBConfig
from gmpb.metrics import end_of_env_error, offline_error
```

## Stepping Semantics

GMPB is a dynamic maximization benchmark. With the default `auto_step=True`:

- Each scalar or batch evaluation consumes fitness evaluations.
- The `change_frequency`-th evaluation is still scored in the current
  environment.
- The benchmark steps immediately after returning the value that consumed the
  last evaluation in that environment.
- `evaluate_batch()` splits work into chunks when a batch crosses environment
  boundaries, so each sub-block is scored under the correct environment.

If you want to control environment changes manually, set `auto_step=False` and
call `step_environment()` directly.

## Metrics

The benchmark does not compute the true optimum value `f*` for each environment.
You supply those values externally when calculating:

- `offline_error(f_star, best_so_far)`
- `end_of_env_error(f_star, best_end)`

## Minimization

GMPB is defined as a maximization problem. To use it in a minimization
pipeline, negate the returned objective values.

## Examples And Docs

Run the minimal example:

```bash
make run-example
```

Build the docs:

```bash
make docs
```

The HTML output is written to `docs/_build/html/`.

## Upstream Compatibility

This repository can optionally validate its installed Python implementation
against EDOLAB's Octave GMPB implementation as a test-only oracle. EDOLAB is
not a runtime dependency and is never bundled into the package artifacts.

For a local compatibility run, clone EDOLAB into `_edolab/`, check out the
pinned commit in `tests/upstream/EDOLAB_SHA.txt`, and run:

```bash
make test-upstream-compat
```
