Expand description
§hyperopt-core
Core abstractions for hyperopt-rs, an Optuna-shaped hyperparameter
optimization framework for Rust. This crate defines the foundational types
and the three extension traits everything else plugs into:
Sampler— a pluggable search algorithm (random, grid, TPE, …).Pruner— a pluggable early-stopping policy.Storage— where trial history lives (in-memory, SQLite, …).
Third parties can depend on just hyperopt-core to implement a new sampler
or pruner without pulling in SQLite or rayon.
§Define-by-run
The search space is not declared up front. Instead the user’s objective
closure receives a TrialContext and calls suggest_* methods on it;
each call records a Distribution and asks the active Sampler for a
Value. This allows conditional/dynamic search spaces — a later
suggestion can depend on an earlier one — which is the design this framework
is built around.
study.optimize(|trial| {
let x = trial.suggest_float("x", -10.0, 10.0);
let y = trial.suggest_float("y", -10.0, 10.0);
Ok((x - 2.0).powi(2) + (y + 3.0).powi(2)) // minimize
}, 100)?;Structs§
- Param
Record - One recorded
(name, distribution, value)triple, in suggestion order. - Study
- A single optimization run: a direction, a sampler, a pruner, and a storage backend, tied to a named study whose trials live in that storage.
- Study
Metadata - Persisted study-level metadata (everything about a study except its trials).
- Study
State - A read-only snapshot of a study’s history, handed to samplers and pruners.
- Trial
- A single optimization trial: its suggested parameters, intermediate reports, and final objective value.
- Trial
Context - The handle passed into the user’s objective closure.
Enums§
- Direction
- Optimization direction: whether the objective should be minimized or
maximized. Samplers and pruners read this from
StudyState::directionand adjust accordingly (e.g. TPE always minimizes internally, negating values underMaximize). - Distribution
- The search-space shape recorded for a single suggested parameter.
- Hyperopt
Error - Errors raised by
crate::Studyoperations (currently all storage-backed). - Objective
Error - Signalled by a user objective to describe how a trial ended.
- Storage
Error - Errors a
Storagebackend can raise. - Trial
State - Lifecycle state of a single trial.
- Value
- A concrete hyperparameter value suggested for a trial.
Traits§
- Pruner
- A pluggable early-stopping policy.
- Sampler
- A pluggable search algorithm.
- Storage
- Where a study’s trial history lives.
- Suggest
- The portable objective interface: exactly the operations a user objective performs on a trial (suggest parameters, report intermediate values, ask whether to prune).
Type Aliases§
- Objective
Result - The value an objective closure returns for one trial.