19 releases (breaking)

new 0.18.1 Apr 10, 2024
0.17.0 Apr 4, 2024
0.16.0 Mar 7, 2024
0.14.0 Dec 13, 2023
0.4.0 Jul 9, 2022

#96 in Machine learning

Download history 4/week @ 2024-01-26 7/week @ 2024-02-02 20/week @ 2024-02-09 120/week @ 2024-02-16 95/week @ 2024-02-23 117/week @ 2024-03-01 68/week @ 2024-03-08 11/week @ 2024-03-15 77/week @ 2024-03-29 271/week @ 2024-04-05

370 downloads per month

Apache-2.0

2.5MB
12K SLoC

egobox

tests pytests linting DOI

Rust toolbox for Efficient Global Optimization algorithms inspired from SMT.

egobox is twofold:

  1. for end-users: a Python module, the Python binding of the optimizer named Egor and the surrogate model Gpx, mixture of Gaussian processes, written in Rust.
  2. for developers: a set of Rust libraries useful to implement bayesian optimization (EGO-like) algorithms,

The Python module

Thanks to the PyO3 project, which makes Rust well suited for building Python extensions. You can install the Python package using:

pip install egobox

See the tutorial notebooks for usage of the optimizer and mixture of Gaussian processes surrogate model.

The Rust libraries

egobox Rust libraries consists of the following sub-packages.

Name Version Documentation Description
doe crates.io docs sampling methods; contains LHS, FullFactorial, Random methods
gp crates.io docs gaussian process regression; contains Kriging, PLS dimension reduction and sparse methods
moe crates.io docs mixture of experts using GP models
ego crates.io docs efficient global optimization with constraints and mixed integer handling

Usage

Depending on the sub-packages you want to use, you have to add following declarations to your Cargo.toml

[dependencies]
egobox-doe = { version = "0.18" }
egobox-gp  = { version = "0.18" }
egobox-moe = { version = "0.18" }
egobox-ego = { version = "0.18" }

Features

The table below presents the various features available depending on the subcrate

Name doe gp moe ego
serializable ✔️ ✔️ ✔️
persistent ✔️ ✔️(*)
blas ✔️ ✔️ ✔️
nlopt ✔️ ✔️

(*) required for mixed-variable gaussian process

serializable

When selected, the serialization with serde crate is enabled.

persistent

When selected, the save and load as a json file with serde_json crate is enabled.

blas

When selected, the usage of BLAS/LAPACK backend is possible, see below for more information.

nlopt

When selected, the nlopt crate is used to provide optimizer implementations (ie Cobyla, Slsqp)

Examples

Examples (in examples/ sub-packages folder) are run as follows:

cd doe && cargo run --example samplings --release
cd gp && cargo run --example kriging --release
cd moe && cargo run --example clustering --release
cd ego && cargo run --example ackley --release

BLAS/LAPACK backend (optional)

egobox relies on linfa project for methods like clustering and dimension reduction, but also try to adopt as far as possible the same coding structures.

As for linfa, the linear algebra routines used in gp, moe ad ego are provided by the pure-Rust linfa-linalg crate, the default linear algebra provider.

Otherwise, you can choose an external BLAS/LAPACK backend available through the ndarray-linalg crate. In this case, you have to specify the blas feature and a linfa BLAS/LAPACK backend feature (more information in linfa features).

Thus, for instance, to use gp with the Intel MKL BLAS/LAPACK backend, you could specify in your Cargo.toml the following features:

[dependencies]
egobox-gp = { version = "0.18", features = ["blas", "linfa/intel-mkl-static"] }

or you could run the gp example as follows:

cd gp && cargo run --example kriging --release --features blas,linfa/intel-mkl-static

Citation

DOI

If you find this project useful for your research, you may cite it as follows:

@article{
  Lafage2022, 
  author = {Rémi Lafage}, 
  title = {egobox, a Rust toolbox for efficient global optimization}, 
  journal = {Journal of Open Source Software} 
  year = {2022}, 
  doi = {10.21105/joss.04737}, 
  url = {https://doi.org/10.21105/joss.04737}, 
  publisher = {The Open Journal}, 
  volume = {7}, 
  number = {78}, 
  pages = {4737}, 
} 

Additionally, you may consider adding a star to the repository. This positive feedback improves the visibility of the project.

Dependencies

~21–43MB
~638K SLoC