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
impl BohbSampler
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new BOHB sampler with default settings.
Defaults:
min_resource: 1max_resource: 81reduction_factor: 3min_points_in_model: 10- TPE: default settings
Sourcepub fn builder() -> BohbSamplerBuilder
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();Sourcepub fn matching_pruner(&self, direction: Direction) -> HyperbandPruner
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
impl Default for BohbSampler
Source§impl Sampler for BohbSampler
impl Sampler for BohbSampler
Source§fn sample(
&self,
distribution: &Distribution,
trial_id: u64,
history: &[CompletedTrial],
) -> ParamValue
fn sample( &self, distribution: &Distribution, trial_id: u64, history: &[CompletedTrial], ) -> ParamValue
Samples a parameter value from the given distribution. Read more
Auto Trait Implementations§
impl !Freeze for BohbSampler
impl !RefUnwindSafe for BohbSampler
impl Send for BohbSampler
impl Sync for BohbSampler
impl Unpin for BohbSampler
impl UnsafeUnpin for BohbSampler
impl !UnwindSafe for BohbSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more