1f1e9d1779713da99ea815a3d1200e21ad7e6548
optimizer
Bayesian and population-based optimization library with an Optuna-like API for hyperparameter tuning and black-box optimization. Supports 12 samplers, 8 pruners, multi-objective optimization, async parallelism, and persistent storage.
Quick Start
use optimizer::prelude::*;
let study: Study<f64> = Study::new(Direction::Minimize);
let x = FloatParam::new(-10.0, 10.0).name("x");
study.optimize(50, |trial| {
let val = x.suggest(trial)?;
Ok::<_, Error>((val - 3.0).powi(2))
}).unwrap();
let best = study.best_trial().unwrap();
println!("Best x = {:.4}, f(x) = {:.4}", best.get(&x).unwrap(), best.value);
Features at a Glance
- Samplers — Random, TPE, Multivariate TPE, Grid, Sobol, CMA-ES, Gaussian Process, Differential Evolution, BOHB, NSGA-II, NSGA-III, MOEA/D
- Pruners — Median, Percentile, Threshold, Patient, Hyperband, Successive Halving, Wilcoxon, Nop
- Parameters — Float, Int, Categorical, Bool, and Enum types with
.name()labels and typed access - Multi-objective — Pareto front extraction with NSGA-II/III and MOEA/D
- Async & parallel — Concurrent trial evaluation with Tokio
- Storage backends — In-memory (default) or JSONL journal for persistence and resumption
- Visualization — HTML reports with optimization history, parameter importance, and Pareto fronts
- Analysis — fANOVA and Spearman correlation for parameter importance
Feature Flags
| Flag | Enables | Default |
|---|---|---|
async |
Async/parallel optimization (Tokio) | No |
derive |
#[derive(Categorical)] for enum parameters |
No |
serde |
Serialization of trials and parameters | No |
journal |
JSONL storage backend (implies serde) |
No |
sobol |
Sobol quasi-random sampler | No |
cma-es |
CMA-ES sampler (requires nalgebra) |
No |
gp |
Gaussian Process sampler (requires nalgebra) |
No |
tracing |
Structured logging with tracing |
No |
Examples
cargo run --example basic_optimization # Minimize a quadratic — simplest possible usage
cargo run --example sampler_comparison # Compare Random, TPE, and Grid on the same problem
cargo run --example pruning_and_callbacks # Trial pruning with MedianPruner + early stopping
cargo run --example parameter_types --features derive # All 5 param types + #[derive(Categorical)]
cargo run --example advanced_features --features async,journal # Async, journal storage, ask-and-tell, multi-objective
Learn More
License
MIT
Description
Languages
Rust
99.8%
Shell
0.2%