Rust toolbox for Efficient Global Optimization method (arguably the most well-known bayesian optimization algorithm) which adresses the gradient-free optimization of expensive objective functions.
EGObox is twofold:
- for end-users: a Python module, the Python binding of the optimizer named
Egorand the surrogate modelGpx, mixture of Gaussian processes, written in Rust. - for developers: a set of Rust libraries useful to implement bayesian optimization (EGO-like) algorithms,
pip install egoboximport numpy as np
import egobox as egx
# Objective function
def f_obj(x: np.ndarray) -> np.ndarray:
return (x - 3.5) * np.sin((x - 3.5) / (np.pi))
# Minimize f_opt in [0, 25]
optim = egx.Egor([[0.0, 25.0]]).minimize(f_obj, max_iters=20, seed=42)
print(f"Optimization f={optim.result.y_opt} at {optim.result.x_opt}") # Optimization f=[-15.12510323] at [18.93525454]See also this example written in Rust
import numpy as np
import matplotlib.pyplot as plt
import egobox as egx
# Training
xtrain = np.array([0.0, 1.0, 2.0, 3.0, 4.0])
ytrain = np.array([0.0, 1.0, 1.5, 0.9, 1.0])
gpx = egx.Gpx.builder().fit(xtrain, ytrain)
# Prediction
xtest = np.linspace(0, 4, 100).reshape((-1, 1))
ytest = gpx.predict(xtest)
# Plot
plt.plot(xtest, ytest)
plt.plot(xtrain, ytrain, "o")
plt.show()See also this example written in Rust
See the tutorial notebooks and examples folder for more information on the usage of the optimizer and mixture of Gaussian processes surrogate model.
egobox Rust libraries consists of the following sub-packages.
| Name | Version | Documentation | Description |
|---|---|---|---|
| doe | sampling methods; contains LHS, FullFactorial, Random methods | ||
| gp | gaussian process regression; contains Kriging, PLS dimension reduction and sparse methods | ||
| moe | mixture of experts using GP models | ||
| ego | efficient global optimization with constraints, mixed integer handling and multi-objective optimization (experimental) |
Depending on the sub-packages you want to use, you have to add following declarations to your Cargo.toml
[dependencies]
egobox-doe = { version = "0.x.y" }
egobox-gp = { version = "0.x.y" }
egobox-moe = { version = "0.x.y" }
egobox-ego = { version = "0.x.y" }
The table below presents the various features available depending on the subcrate
| Name | doe | gp | moe | ego |
|---|---|---|---|---|
| serializable | ✔️ | ✔️ | ||
| persistent | ✔️ | |||
| blas | ✔️ | ✔️ | ✔️ | |
| c-cobyla | ✔️ | ✔️ | ✔️ | |
| c-slsqp | ✔️ |
Note: moe and ego models are always serializable and can be saved/loaded (json or binary format).
When selected, the serialization with serde crate is enabled.
When selected, the save and load as a json file with serde_json crate is enabled.
When selected, the usage of BLAS/LAPACK backend is possible, see below for more information.
By default, Basin pure Rust optimizers are used: COBYLA for GP hyperparameters
training (gp, moe) and COBYLA/SLSQP for infill criterion optimization (ego), which also always
uses Basin to execute the EGO loop.
When selected, c-cobyla (resp. c-slsqp) uses the cobyla
(resp. slsqp) crate, a C-ported NLopt implementation, instead of
the Basin one. These features are also available on egobox-gpx and the Python package. See
Basin integration for build commands, checkpoint behavior, and
reproducible comparisons.
Examples (in examples/ sub-packages folder) are run as follows:
cd doe && cargo run --example samplings --releasecd gp && cargo run --example kriging --releasecd moe && cargo run --example clustering --releasecd ego && cargo run --example ackley --releasecd ego && cargo run --example zdt1 --release # multi-objective optimizationegobox 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.x.y", 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-staticIf 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.
Bartoli, N., Lefebvre, T., Dubreuil, S., Olivanti, R., Priem, R., Bons, N., Martins, J. R. R. A., & Morlier, J. (2019). Adaptive modeling strategy for constrained global optimization with application to aerodynamic wing design. Aerospace Science and Technology, 90, 85–102.
Bouhlel, M. A., Bartoli, N., Otsmane, A., & Morlier, J. (2016). Improving kriging surrogates of high-dimensional design models by partial least squares dimension reduction. Structural and Multidisciplinary Optimization, 53(5), 935–952.
Bouhlel, M. A., Hwang, J. T., Bartoli, N., Lafage, R., Morlier, J., & Martins, J. R. R. A. (2019). A python surrogate modeling framework with derivatives. Advances in Engineering Software, 102662.
Dubreuil, S., Bartoli, N., Gogu, C., & Lefebvre, T. (2020). Towards an efficient global multi-disciplinary design optimization algorithm Structural and Multidisciplinary Optimization, 62(4), 1739–1765.
Jin, R. and Chen, W. and Sudjianto, A. (2005). An efficient algorithm for constructing optimal design of computer experiments Journal of Statistical Planning and Inference, 134:268-287.
Bettebghor, Dimitri, et al. (2011). Surrogate modeling approximation using a mixture of experts based on EM joint estimation Structural and multidisciplinary optimization 43.2 (2011): 243-259.
Jones, D. R., Schonlau, M., & Welch, W. J. (1998). Efficient global optimization of expensive black-box functions. Journal of Global Optimization, 13(4), 455–492.
Knowles, J. (2006). ParEGO: a hybrid algorithm with on-line landscape approximation for expensive multiobjective optimization problems. IEEE Transactions on Evolutionary Computation, 10(1), 50–66.
Zhan, D., Cheng, Y., & Liu, J. (2017). Expected improvement matrix-based infill criteria for expensive multiobjective optimization. IEEE Transactions on Evolutionary Computation, 21(6), 956–975.
Emmerich, M. T. M., Giannakoglou, K. C., & Naujoks, B. (2006). Single- and multiobjective evolutionary optimization assisted by Gaussian random field metamodels. IEEE Transactions on Evolutionary Computation, 10(4), 421–439.
Daulton, S., Balandat, M., & Bakshy, E. (2020). Differentiable Expected Hypervolume Improvement for Parallel Multi-Objective Bayesian Optimization. Advances in Neural Information Processing Systems 33 (NeurIPS 2020), 9851–9864.
Diouane, Youssef, et al. (2023). TREGO: a trust-region framework for efficient global optimization. Journal of Global Optimization 86.1 (2023): 1-23.
Priem, Rémy, Nathalie Bartoli, and Youssef Diouane. (2019) On the use of upper trust bounds in constrained Bayesian optimization infill criteria. AIAA aviation 2019 forum. 2019.
Sasena M., Papalambros P., Goovaerts P., (2002). Global optimization of problems with disconnected feasible regions via surrogate modeling. AIAA Paper.
Ginsbourger, D., Le Riche, R., & Carraro, L. (2010). Kriging is well-suited to parallelize optimization
E.C. Garrido-Merchan and D. Hernandez-Lobato. Dealing with categorical and integer-valued variables in Bayesian Optimization with Gaussian processes.
Zhan, Dawei, et al. (2024). A cooperative approach to efficient global optimization. Journal of Global Optimization 88.2 (2024): 327-357
Lisa Pretsch et al. (2025). Bayesian optimization of cooperative components for multi-stage aero-structural compressor blade design. Struct Multidisc Optim 68, 84 (2025)
Appriou, T., Rullière, D. & Gaudrie, D, (2024) Combination of optimization-free kriging models for high-dimensional problems, Comput Stat 39, 3049–3071 (2024).
S. Ament, S. Daulton, D. Eriksson, M. Balandat, E. Bakshy, (2023). Unexpected improvements to expected improvement for bayesian optimization, Advances in Neural Information Processing Systems, 2023
Marrel, A., & Iooss, B. (2024). Probabilistic surrogate modeling by Gaussian process: A review on recent insights in estimation and validation. Reliability Engineering & System Safety, 247, 110094.
Bussemaker, Jasper H., et al. (2024). Surrogate-based optimization of system architectures subject to hidden constraints. AIAA Aviation forum and Ascend 2024.
Tfaily, Ali, et al. (2024). Bayesian optimization with hidden constraints for aircraft design. Structural and Multidisciplinary Optimization 67.7 (2024): 123.
Larsson, J. (2026). Basin: Efficient and Extensible Numerical Optimization in Rust. arXiv:2608.11279. basin.rs
Marchildon, A. (2026). GpFlash: Maximizing Speed and Minimizing Memory for Gaussian Process Training and Prediction. arXiv:2610.16861.
smtorg. (2018). Surrogate modeling toolbox. GitHub.
Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
