pub struct Study { /* private fields */ }Expand description
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.
Construct one with Study::new, or use the ergonomic builder in the
hyperopt facade crate. Run trials with Study::optimize (sequential) or
[Study::optimize_parallel] (feature parallel).
Implementations§
Source§impl Study
impl Study
Sourcepub fn new(
name: impl Into<String>,
direction: Direction,
sampler: Box<dyn Sampler>,
pruner: Box<dyn Pruner>,
storage: Box<dyn Storage>,
) -> Result<Study, HyperoptError>
pub fn new( name: impl Into<String>, direction: Direction, sampler: Box<dyn Sampler>, pruner: Box<dyn Pruner>, storage: Box<dyn Storage>, ) -> Result<Study, HyperoptError>
Assemble a study from its parts. Persists study metadata immediately so
the direction survives a reload. If the study already exists in
storage, its recorded direction is authoritative and is adopted here
(so a resumed study can’t silently flip direction).
Sourcepub fn trials(&self) -> Result<Vec<Trial>, HyperoptError>
pub fn trials(&self) -> Result<Vec<Trial>, HyperoptError>
A fresh snapshot of every trial recorded for this study.
Sourcepub fn best_trial(&self) -> Result<Option<Trial>, HyperoptError>
pub fn best_trial(&self) -> Result<Option<Trial>, HyperoptError>
The best completed trial under the study direction, if any.
Sourcepub fn best_value(&self) -> Result<Option<f64>, HyperoptError>
pub fn best_value(&self) -> Result<Option<f64>, HyperoptError>
The best objective value seen so far, if any trial has completed.
Sourcepub fn optimize<F>(
&self,
objective: F,
n_trials: usize,
) -> Result<(), HyperoptError>
pub fn optimize<F>( &self, objective: F, n_trials: usize, ) -> Result<(), HyperoptError>
Run n_trials sequentially. A trial that panics or returns
ObjectiveError::Failed is marked Failed and the run continues; one
that returns ObjectiveError::Pruned is marked Pruned.