pub struct Trial {
pub number: usize,
pub params: Vec<ParamRecord>,
pub intermediate_values: Vec<(usize, f64)>,
pub value: Option<f64>,
pub state: TrialState,
}Expand description
A single optimization trial: its suggested parameters, intermediate reports, and final objective value.
params is kept in suggestion order (an ordered list rather than a hash
map) so that define-by-run search spaces — where the set of parameters can
differ between trials — round-trip faithfully through storage and are
reproducible for grid enumeration.
Fields§
§number: usizeZero-based trial index within its study.
params: Vec<ParamRecord>Parameters suggested so far, in the order they were requested.
intermediate_values: Vec<(usize, f64)>Intermediate (step, value) reports, populated via
crate::TrialContext::report; consumed by pruners.
value: Option<f64>Final objective value, once the trial completes.
state: TrialStateCurrent lifecycle state.
Implementations§
Source§impl Trial
impl Trial
Sourcepub fn new(number: usize) -> Self
pub fn new(number: usize) -> Self
Creates a fresh Running trial with the given number and no params.
Sourcepub fn record(&mut self, name: &str, distribution: Distribution, value: Value)
pub fn record(&mut self, name: &str, distribution: Distribution, value: Value)
Records a suggested parameter. Re-suggesting the same name overwrites
the previous record (mirrors Optuna, where repeated suggest_* calls
for one name within a trial are idempotent).
Sourcepub fn param_value(&self, name: &str) -> Option<&Value>
pub fn param_value(&self, name: &str) -> Option<&Value>
Looks up a previously recorded parameter value by name.
Sourcepub fn value_at_step(&self, step: usize) -> Option<f64>
pub fn value_at_step(&self, step: usize) -> Option<f64>
The intermediate value reported at exactly step, if any.
Sourcepub fn value_at_or_after(&self, step: usize) -> Option<f64>
pub fn value_at_or_after(&self, step: usize) -> Option<f64>
The intermediate value at the smallest reported step >= step, if any.
Used by rung-based pruners that compare trials at a resource budget.
Sourcepub fn last_intermediate(&self) -> Option<(usize, f64)>
pub fn last_intermediate(&self) -> Option<(usize, f64)>
The most recent (step, value) report, if the trial has reported.