declivity
A unified benchmarking framework and modern Python port for evolutionary and quasi-Newton optimization algorithms. Thesis project by Jedrzej Grabski.
What this is
Two things, glued together:
- A unified framework for fairly comparing optimizers under identical conditions (shared budgets, shared seeds, shared problem definitions).
- Modern Python implementations of algorithms that previously only existed as inconsistent academic ports — CMA-ES variants from R, L-BFGS-B from Fortran 77 — rewritten as clean, type-checked Python that plugs into the framework.
The current algorithm roster:
| Algorithm | Family | Notes |
|---|---|---|
| DES | Evolutionary | Adaptive Ft via evolution-path history (ring buffer) |
| CMA-ES | Evolutionary | Full covariance matrix, rank-1 + rank-μ updates |
| MF-CMA-ES | Evolutionary | Matrix-free CMA-ES (Arabas), optional PPMF |
| L-BFGS-B | Quasi-Newton | Pure-Python port of Fortran v3.0, configurable B₀ |
L-BFGS-B is the newest addition and ships with the more involved studies (rotated Ellipsoid, CMA-ES → L-BFGS-B covariance handoff).
Quick start
pdm install
pdm run run-example # Sphere demo (DES on 10D Sphere)
pdm run run-r # CEC2017 F10, 10 seeds, writes CSVs for R cross-check
Or directly:
PYTHONPATH=. pdm run python experiments/basic/declarative_plotting.py
PYTHONPATH=. pdm run python experiments/handoff/multimodal.py --num-seeds 25
Minimal example
Run one optimizer:
import numpy as np
from declivity import AlgorithmFactory
from declivity.algorithms.choices import AlgorithmChoice
from declivity.plotting import plot_metrics
from declivity.utils.benchmark_functions import Sphere
func = Sphere(dimensions=10)
initial_point = np.random.uniform(-50, 50, 10)
optimizer = AlgorithmFactory.create_optimizer(
algorithm=AlgorithmChoice.CMAES,
func=func,
initial_point=initial_point,
lower_bounds=-100,
upper_bounds=100,
)
result = optimizer.optimize()
print(f"f* = {result.best_fitness:.4e} after {result.evaluations} evals")
plot_metrics(result, save_path="cmaes.png") # every default panel for CMA-ES
Compare two algorithms:
from declivity.plotting import plot_comparison
plot_comparison(
{"CMA-ES": cmaes_result, "L-BFGS-B": lbfgsb_result},
save_path="comparison.png",
)
# Auto-picks the panels both algorithms expose (convergence + step_size by
# default). CMA-ES sigma and L-BFGS-B step_length end up on the same axes
# under one "Step Size" panel — semantic comparability is the point.
Multi-seed benchmark:
from declivity.benchmarking import Benchmark, Problem, SingleAlgorithm, CMAESLBFGSBHandoff
from declivity.plotting import plot_benchmark_convergence, plot_benchmark_boxplot
bench = Benchmark(problems=[...], algorithms=[...], seeds=range(25), output_dir=...)
bench.run()
plot_benchmark_convergence(bench.traces, problems, algorithms, save_path="conv.png")
plot_benchmark_boxplot (bench.traces, problems, algorithms, save_path="box.png")
See DOCUMENTATION.md for the full API.
Project layout
declivity/
├── declivity/ Library code (algorithms, framework)
│ ├── core/ BaseOptimizer, AlgorithmFactory, BaseConfig
│ ├── algorithms/ DES, CMA-ES, MF-CMA-ES, L-BFGS-B
│ ├── benchmarking/ Problem, Benchmark, RunTrace
│ │ + BenchmarkAlgorithm / HandoffAlgorithm ABCs
│ ├── utils/ Benchmark functions, constraint handlers,
│ │ repair strategies, initial-point generators,
│ │ population initializers, helpers
│ ├── logging/ BaseLogData / PopulationLogData + per-algo loggers
│ └── plotting/ Declarative panel system (Panel + 8 entry points)
│
├── experiments/ Runnable studies (one script per study)
│ ├── basic/ Tutorial demos, sanity checks, declarative API demos
│ ├── cross_validation/ Cross-checks against R reference impls
│ ├── lbfgsb/ L-BFGS-B feature studies
│ ├── handoff/ CMA-ES → L-BFGS-B handoff studies
│ └── report/ Plot regeneration utilities
│
├── plots/ Experiment outputs (gitignored, mirrors experiments/)
├── docs/ Algorithm lectures + design notes + reports
├── reference/ Reference R implementations and their outputs
└── notes/ Local scratch notes (gitignored)
Where to look next
- API reference:
DOCUMENTATION.md - Framework design principles:
docs/framework_design.md - Experiment index:
experiments/README.md - L-BFGS-B internals:
docs/lbfgsb_lecture.md - Initial-Hessian design:
docs/lbfgsb_initial_hessian_design.md - CMA-ES → L-BFGS-B handoff study:
docs/covariance_handoff_when_it_matters.md - CMA-ES diagnostic plot legend:
docs/cmaes_diagnostic_plots.md
Tech stack
- Python 3.12 (strict), managed with PDM
- NumPy 2.x, SciPy 1.15+, Matplotlib 3.10+
opfunufor CEC2017 benchmark functionsjoblibfor optional parallel benchmark execution
Status
Thesis-in-progress. There is no formal test suite — correctness is
validated by cross-comparison against the R reference implementations in
reference/ and by the supervisor-report experiments under
plots/report/.
License
MIT — see LICENSE.
Metadata
Release files for declivity 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| declivity-0.1.0.tar.gz | 115.5 kB | Without provenance | Details for declivity-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| declivity-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for declivity-0.1.0-py3-none-any.whl |
Total release size: 259.8 kB
Release files / declivity-0.1.0.tar.gz
| Download URL | declivity-0.1.0.tar.gz |
|---|---|
| Size | 115.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6753f481a15be3bbbf8234da4cc1ded3df276b8a9198f5d5b410926699eb7f2d
|
|
BLAKE2b-256 checksum How to use checksums |
938bdcd5ccc5d37a180fa22e3372f9877bc3ed043bbb6637e54b75975a064d8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Release files / declivity-0.1.0-py3-none-any.whl
| Download URL | declivity-0.1.0-py3-none-any.whl |
|---|---|
| Size | 144.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8c9831321e692660df017f71178eba553d2a77aee3f2c15eaf8f181321fb2cb
|
|
BLAKE2b-256 checksum How to use checksums |
85c01ff2bc45dc16d5d6574955ee2b276bf2e138f725f4111192b1b29738e5f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Security for declivity 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.