Skip to main content

StudyBuilder

Struct StudyBuilder 

Source
pub struct StudyBuilder<V: PartialOrd = f64> { /* private fields */ }
Expand description

A builder for constructing Study instances with a fluent API.

Created via Study::builder(). Collects sampler, pruner, direction, and storage options before constructing the study.

§Defaults

§Examples

use optimizer::prelude::*;

let study: Study<f64> = Study::builder()
    .maximize()
    .sampler(TpeSampler::new())
    .pruner(MedianPruner::new(Direction::Maximize).n_warmup_steps(5))
    .build();

assert_eq!(study.direction(), Direction::Maximize);

Implementations§

Source§

impl<V: PartialOrd> StudyBuilder<V>

Source

pub fn minimize(self) -> Self

Set the optimization direction to minimize (the default).

Source

pub fn maximize(self) -> Self

Set the optimization direction to maximize.

Source

pub fn direction(self, direction: Direction) -> Self

Set the optimization direction explicitly.

Source

pub fn sampler(self, sampler: impl Sampler + 'static) -> Self

Set the sampler used for parameter suggestions.

Defaults to RandomSampler if not specified.

Source

pub fn pruner(self, pruner: impl Pruner + 'static) -> Self

Set the pruner used for early stopping of trials.

Defaults to NopPruner (no pruning) if not specified.

Source

pub fn storage(self, storage: impl Storage<V> + 'static) -> Self

Set a custom storage backend.

Defaults to MemoryStorage if not specified.

Source

pub fn build(self) -> Study<V>
where V: Send + Sync + 'static,

Build the Study with the configured options.

Auto Trait Implementations§

§

impl<V> Freeze for StudyBuilder<V>

§

impl<V = f64> !RefUnwindSafe for StudyBuilder<V>

§

impl<V> Send for StudyBuilder<V>
where V: Send,

§

impl<V> Sync for StudyBuilder<V>
where V: Sync,

§

impl<V> Unpin for StudyBuilder<V>
where V: Unpin,

§

impl<V = f64> !UnwindSafe for StudyBuilder<V>

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.