pub struct TrialContext { /* private fields */ }Expand description
Handle passed to a trial: reports intermediate metrics and asks whether the pruner wants the trial stopped.
report is the single channel for per-step metrics:
it records the value on the trial, emits Event::TrialMetric, and
— when the metric is the study’s objective — consults the pruner
against the completed trials’ histories. Values are compared on a
maximize scale (the runner pre-normalizes for Minimize).
The handle is cheaply cloneable (Arc-backed shared state) so it
can outlive the borrow stack — e.g. cross into a Python callback.
Implementations§
Source§impl TrialContext
impl TrialContext
Sourcepub fn report(&self, name: &str, value: f64, step: usize) -> bool
pub fn report(&self, name: &str, value: f64, step: usize) -> bool
Record an intermediate metric at step. Returns true when the
trial should stop (pruned) — the executor should then return
early; the runner marks the trial pruned regardless.
Sourcepub fn should_prune(&self) -> bool
pub fn should_prune(&self) -> bool
Whether the pruner has decided to stop this trial.
Sourcepub fn metrics(&self) -> Vec<MetricRecord>
pub fn metrics(&self) -> Vec<MetricRecord>
Metrics reported so far.
Trait Implementations§
Source§impl Clone for TrialContext
impl Clone for TrialContext
Source§fn clone(&self) -> TrialContext
fn clone(&self) -> TrialContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more