pub struct StudyState { /* private fields */ }Expand description
A read-only snapshot of a study’s history, handed to samplers and pruners.
Both crate::Sampler::suggest and crate::Pruner::should_prune receive
a StudyState rather than a single trial so that adaptive samplers (TPE)
and cross-trial pruners (median, successive-halving) have everything they
need through one channel. Under parallel execution this snapshot is
deliberately slightly stale — see [crate::Study::optimize_parallel].
Implementations§
Source§impl StudyState
impl StudyState
Sourcepub fn new(direction: Direction, trials: Vec<Trial>) -> Self
pub fn new(direction: Direction, trials: Vec<Trial>) -> Self
Builds a snapshot from the study direction and its trials so far.
Sourcepub fn completed_trials(&self) -> impl Iterator<Item = &Trial>
pub fn completed_trials(&self) -> impl Iterator<Item = &Trial>
Trials that completed successfully and carry a final value.
Sourcepub fn n_completed(&self) -> usize
pub fn n_completed(&self) -> usize
Number of completed trials — used by samplers/pruners for warmup gates.
Sourcepub fn intermediate_values_at(&self, step: usize) -> Vec<f64>
pub fn intermediate_values_at(&self, step: usize) -> Vec<f64>
Intermediate values reported at exactly step across all trials that
reached it (completed or pruned). Used by MedianPruner.
Sourcepub fn values_at_or_after(&self, step: usize) -> Vec<f64>
pub fn values_at_or_after(&self, step: usize) -> Vec<f64>
Values of all trials that reached resource >= step, taken at the first
step at or after step. Used by rung-based pruners.
Sourcepub fn best_trial(&self) -> Option<&Trial>
pub fn best_trial(&self) -> Option<&Trial>
The best completed trial under the study direction, if any.
Trait Implementations§
Source§impl Clone for StudyState
impl Clone for StudyState
Source§fn clone(&self) -> StudyState
fn clone(&self) -> StudyState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more