Skip to main content

Trial

Struct Trial 

Source
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: usize

Zero-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: TrialState

Current lifecycle state.

Implementations§

Source§

impl Trial

Source

pub fn new(number: usize) -> Trial

Creates a fresh Running trial with the given number and no params.

Source

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).

Source

pub fn param_value(&self, name: &str) -> Option<&Value>

Looks up a previously recorded parameter value by name.

Source

pub fn value_at_step(&self, step: usize) -> Option<f64>

The intermediate value reported at exactly step, if any.

Source

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.

Source

pub fn last_intermediate(&self) -> Option<(usize, f64)>

The most recent (step, value) report, if the trial has reported.

Trait Implementations§

Source§

impl Clone for Trial

Source§

fn clone(&self) -> Trial

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Trial

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Trial

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Trial, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Trial

Source§

fn eq(&self, other: &Trial) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Trial

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Trial

Auto Trait Implementations§

§

impl Freeze for Trial

§

impl RefUnwindSafe for Trial

§

impl Send for Trial

§

impl Sync for Trial

§

impl Unpin for Trial

§

impl UnsafeUnpin for Trial

§

impl UnwindSafe for Trial

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.