Skip to main content

Study

Struct Study 

Source
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

Source

pub fn new( name: impl Into<String>, direction: Direction, sampler: Box<dyn Sampler>, pruner: Box<dyn Pruner>, storage: Box<dyn Storage>, ) -> Result<Self, 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).

Source

pub fn name(&self) -> &str

The study’s name (its key in storage).

Source

pub fn direction(&self) -> Direction

The optimization direction.

Source

pub fn trials(&self) -> Result<Vec<Trial>, HyperoptError>

A fresh snapshot of every trial recorded for this study.

Source

pub fn best_trial(&self) -> Result<Option<Trial>, HyperoptError>

The best completed trial under the study direction, if any.

Source

pub fn best_value(&self) -> Result<Option<f64>, HyperoptError>

The best objective value seen so far, if any trial has completed.

Source

pub fn optimize<F>( &self, objective: F, n_trials: usize, ) -> Result<(), HyperoptError>
where F: FnMut(&mut TrialContext<'_>) -> ObjectiveResult,

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.

Auto Trait Implementations§

§

impl !Freeze for Study

§

impl !RefUnwindSafe for Study

§

impl !UnwindSafe for Study

§

impl Send for Study

§

impl Sync for Study

§

impl Unpin for Study

§

impl UnsafeUnpin for Study

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