EGObox: Efficient Global Optimization Toolbox

repository·master·Indexed 41 days ago

https://github.com/relf/egobox

A toolbox for gradient-free optimization of expensive objective functions, featuring a high-level Python module and specialized Rust libraries. It includes egobox-ego for the Efficient Global Optimization algorithm, egobox-gp for Gaussian process regression, egobox-moe for Mixture of Experts, and egobox-doe for Design of Experiments sampling methods. Also provides the gpx CLI tool for training and predicting with Gaussian Process surrogates.

Tokens
57.5K
Snippets
206
Records
262
Agent score
49%

What's inside EGObox

  1. Overview of egobox-ego features

    master

    The egobox-ego crate provides a Rust implementation of the Efficient Global Optimization (EGO) algorithm. It leverages egobox-moe (Mixture of Experts) to provide several advanced optimization capabilities:

    • Surrogate Modeling: Uses a Mixture of Gaussian Processes.
    • Infill Criteria: Supports multiple criteria including EI, WB2, WB2S, LogEI, CEI, and LogCEI.
    • Constraint Handling: Manages negative constraints using either actual constraint functions or surrogate models.
    • Mixed Integer Optimization: Available via continuous relaxation.
    • Advanced Algorithms: Implements the Trust Region EGO algorithm and the CoEGO method with CCBO settings.
  2. Overview of `gpx` subcommands

    master

    The gpx tool provides several subcommands for managing Gaussian Process (GP) surrogate models without writing Python code:

    • fit: Train a GP surrogate from CSV or .npy data files.
    • spec: Inspect a saved model's dimensions, configuration, and metadata.
    • qa: Assess predictive quality (metrics like Q2, PVA, IAEalpha) using Leave-One-Out (LOO) or k-fold cross-validation.
    • predict: Run inference on new input samples and export results to CSV or .npy.
    • py: Generate a self-contained Python helper script that embeds the model.
  3. Overview of egobox-gp features

    master

    The egobox-gp crate is a Rust implementation of Gaussian process regression, ported from the SMT Python library. It supports the following modeling options:

    Regression Models

    • constant
    • linear
    • quadratic

    Correlation Models (Kernels)

    • squared exponential
    • absolute exponential
    • matern 3/2
    • matern 5/2

    High-Dimensional Support

    • Uses Partial Least Squares (linfa-pls) to handle high-dimensional problems.
  4. Overview of the egobox library architecture

    master

    egobox is a Rust-based toolbox designed for efficient global optimization (EGO). It provides building blocks for implementing surrogate-based adaptive optimization algorithms, specifically targeting computationally costly black-box functions. The library is organized into four core sub-packages:

    • doe: Provides sampling methods for Design of Experiments (DOE), including Latin Hypercube sampling.
    • gp: Implements Gaussian process regression (also known as kriging), used as surrogate models.
    • moe: Implements Mixture of Experts to increase surrogate accuracy by clustering the design space and training/selecting local models.
    • ego: Provides an efficient global optimization implementation that supports inequality constraints and mixed-integer optimization via continuous relaxation.

    The library also includes a Python module egobox (via PyO3 bindings) which provides access to the Egor optimizer.

  5. Overview of EGObox

    master

    EGObox is a toolbox for Efficient Global Optimization (EGO), a Bayesian optimization algorithm designed for the gradient-free optimization of expensive objective functions. It is provided in two ways:

    1. For End-Users: A Python module containing the Egor optimizer and the Gpx surrogate model (a mixture of Gaussian processes), both implemented in Rust.
    2. For Developers: A collection of Rust crates used to implement or utilize Bayesian optimization (EGO-like) algorithms.

    Key components include:

    • Egor: The core optimizer.
    • Gpx: The surrogate model based on a mixture of Gaussian processes.
  6. Use egobox-doe for Design of Experiments

    master

    egobox-doe is a Rust library providing various sampling methods for the Design of Experiments (DoE). It is a Rust port of the sampling methods found in the Python SMT library.

    Currently, the crate supports the following sampling methods:

    • Random sampling
    • Full-factorial sampling
    • Latin hypercube sampling: including classic, centered, and optimized variants.
  7. Core features of egobox-moe

    master

    The current implementation of egobox-moe utilizes Gaussian Processes (provided by egobox-gp) to implement the following capabilities:

    • Clustering: Uses linfa-clustering/gmm (Gaussian Mixture Models).
    • Recombination: Supports both Hard recombination and Smooth recombination.
    • Model Choice: Allows specifying allowed models for regression and correlation.
    • Mixed-integer variables: Handles mixed-integer variables through continuous relaxation.
  8. Configure mixed-integer variable types

    master

    Egor supports several variable types via egx.XType within egx.XSpec. These types handle continuous relaxation differently:

    • egx.XType.FLOAT: Standard continuous variable.
    • egx.XType.INT: Integer variable. The resulting float is rounded to the closest integer.
    • egx.XType.ORD: Ordered variable. The resulting float is cast to the closest value among the provided list.
    • egx.XType.ENUM: Enumerated variable. Uses one-hot encoding. If tags are provided, x_opt will contain the indices corresponding to those tags.
    xtypes = [
        egx.XSpec(egx.XType.FLOAT, [-5.0, 5.0]),
        egx.XSpec(egx.XType.ENUM, tags=["blue", "red", "green"]),
        egx.XSpec(egx.XType.ORD, [0, 2, 3]),
    ]
    egor = egx.Egor(xtypes)
  9. How Egor and Gpx work together

    master

    EGObox provides two primary high-level objects for Bayesian optimization:

    1. Egor: The Bayesian optimizer. It is used to iteratively evaluate an expensive black-box function to find its minimum.
    2. Gpx: A mixture of Gaussian Processes (Kriging + Mixture of Experts). It acts as a surrogate model used for regression and prediction.

    Developers typically use Egor to automate the optimization loop, while Gpx can be used as a standalone surrogate model for modeling known data points.

  10. Check EGObox documentation for errors

    master

    To validate the documentation site and check for configuration or content errors without starting a server or building the full site, run zola check from within the website directory.

    cd website
    zola check