2026-01-30 18:08:13 +01:00
|
|
|
# optimizer
|
2026-01-30 17:33:33 +01:00
|
|
|
|
|
|
|
|
A Rust library for black-box optimization using Tree-Parzen Estimator (TPE).
|
|
|
|
|
|
2026-01-30 18:08:13 +01:00
|
|
|
[](https://docs.rs/optimizer)
|
|
|
|
|
[](https://crates.io/crates/optimizer)
|
|
|
|
|
[](https://codecov.io/gh/raimannma/rust-optimizer)
|
2026-01-30 17:33:33 +01:00
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
|
|
- Optuna-like API for hyperparameter optimization
|
|
|
|
|
- Float, integer, and categorical parameter types
|
|
|
|
|
- Log-scale and stepped parameter sampling
|
|
|
|
|
- Sync and async optimization with parallel trial evaluation
|
|
|
|
|
|
|
|
|
|
## Quick Start
|
|
|
|
|
|
|
|
|
|
```rust
|
2026-01-30 18:08:13 +01:00
|
|
|
use optimizer::{Direction, Study, TpeSampler};
|
2026-01-30 17:33:33 +01:00
|
|
|
|
|
|
|
|
let sampler = TpeSampler::builder().seed(42).build();
|
|
|
|
|
let study: Study<f64> = Study::with_sampler(Direction::Minimize, sampler);
|
|
|
|
|
|
|
|
|
|
study
|
|
|
|
|
.optimize_with_sampler(20, |trial| {
|
|
|
|
|
let x = trial.suggest_float("x", -10.0, 10.0)?;
|
2026-01-30 18:08:13 +01:00
|
|
|
Ok::<_, optimizer::TpeError>(x * x)
|
2026-01-30 17:33:33 +01:00
|
|
|
})
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
let best = study.best_trial().unwrap();
|
|
|
|
|
println!("Best value: {} at x={:?}", best.value, best.params);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Feature Flags
|
|
|
|
|
|
|
|
|
|
- `async` - Enable async optimization methods (requires tokio)
|
|
|
|
|
|
|
|
|
|
## Documentation
|
|
|
|
|
|
2026-01-30 18:08:13 +01:00
|
|
|
Full API documentation is available at [docs.rs/optimizer](https://docs.rs/optimizer).
|
2026-01-30 17:33:33 +01:00
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
MIT
|