Skip to main content

BohbSampler

Struct BohbSampler 

Source
pub struct BohbSampler { /* private fields */ }
Expand description

A BOHB sampler that combines TPE with HyperBand budget awareness.

BOHB filters trial history by budget level before delegating to TPE, so the surrogate model is conditioned on trials evaluated at the same resource level. This produces better-calibrated parameter proposals than using a single global model across all budgets.

Use BohbSampler::matching_pruner to create a HyperbandPruner with matching HyperBand parameters.

§Examples

use optimizer::parameter::{FloatParam, Parameter};
use optimizer::sampler::bohb::BohbSampler;
use optimizer::{Direction, Study};

let bohb = BohbSampler::builder()
    .min_resource(1)
    .max_resource(27)
    .reduction_factor(3)
    .seed(42)
    .build()
    .unwrap();
let pruner = bohb.matching_pruner(Direction::Minimize);
let study: Study<f64> = Study::with_sampler_and_pruner(Direction::Minimize, bohb, pruner);

Implementations§

Source§

impl BohbSampler

Source

pub fn new() -> Self

Creates a new BOHB sampler with default settings.

Defaults:

  • min_resource: 1
  • max_resource: 81
  • reduction_factor: 3
  • min_points_in_model: 10
  • TPE: default settings
Source

pub fn builder() -> BohbSamplerBuilder

Creates a builder for configuring a BOHB sampler.

§Examples
use optimizer::sampler::bohb::BohbSampler;

let sampler = BohbSampler::builder()
    .min_resource(1)
    .max_resource(27)
    .reduction_factor(3)
    .min_points_in_model(5)
    .seed(42)
    .build()
    .unwrap();
Source

pub fn matching_pruner(&self, direction: Direction) -> HyperbandPruner

Creates a HyperbandPruner with matching Hyperband parameters.

This ensures the pruner’s budget schedule is consistent with the budget levels used by BOHB for model conditioning.

Trait Implementations§

Source§

impl Default for BohbSampler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Sampler for BohbSampler

Source§

fn sample( &self, distribution: &Distribution, trial_id: u64, history: &[CompletedTrial], ) -> ParamValue

Samples a parameter value from the given distribution. Read more

Auto Trait Implementations§

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.