Struct SamplerConfig
pub struct SamplerConfig { /* private fields */ }Expand description
A sampler kind plus the settings it departs from its default with.
SamplerConfig::new carries none, and then
build_for is exactly
SamplerKind::build_for, so a recipe without opt-ins or opt-outs keeps
its seeded output bit for bit.
Implementations§
§impl SamplerConfig
impl SamplerConfig
pub const fn new(kind: SamplerKind) -> Self
pub const fn new(kind: SamplerKind) -> Self
kind with its sampler’s default settings.
pub fn with_opt_in(self, opt_in: OptIn) -> Result<Self, String>
pub fn with_opt_in(self, opt_in: OptIn) -> Result<Self, String>
Switches opt_in on. Repeating a setting is a no-op, and so is a
setting the sampler already turns on: it is not
recorded, so the configuration stays the default.
§Errors
When opt_in belongs to another sampler kind, when it was also opted
out, or when the combination is one the sampler refuses (CMA-ES
separable with margin, as in Optuna).
pub fn with_opt_out(self, opt_out: OptIn) -> Result<Self, String>
pub fn with_opt_out(self, opt_out: OptIn) -> Result<Self, String>
Switches the on-by-default setting opt_out off,
restoring that part of the sampler’s earlier default. Repeating a
setting is a no-op.
§Errors
When opt_out belongs to another sampler kind or is off by default
already, or when the combination is one the sampler refuses. (An
earlier --opt-in of the same setting recorded nothing, so this call
cannot see it; SolverArgs::parse
refuses that pair from the command line.)
pub fn with_gp_cost_budget(self, budget: u64) -> Result<Self, String>
pub fn with_gp_cost_budget(self, budget: u64) -> Result<Self, String>
Switches OptIn::GpCostBudget on with an explicit per-ask budget in
[atune::auto_sampler::gp_ask_cost] units.
§Errors
When the kind is not SamplerKind::Auto.
pub const fn kind(&self) -> SamplerKind
pub const fn kind(&self) -> SamplerKind
The sampler kind.
pub fn opt_ins(&self) -> impl Iterator<Item = OptIn> + '_
pub fn opt_ins(&self) -> impl Iterator<Item = OptIn> + '_
The off-by-default settings switched on, in OptIn::ALL order.
pub fn opt_outs(&self) -> impl Iterator<Item = OptIn> + '_
pub fn opt_outs(&self) -> impl Iterator<Item = OptIn> + '_
The on-by-default settings switched off, in OptIn::ALL order.
pub fn has(&self, setting: OptIn) -> bool
pub fn has(&self, setting: OptIn) -> bool
Whether setting is on in the configured sampler: opted in, or on by
default and not opted out.
pub fn opt_out_label(&self) -> Option<String>
pub fn opt_out_label(&self) -> Option<String>
The opt-out labels joined by ,, or None when there are none.
pub fn opt_in_label(&self) -> Option<String>
pub fn opt_in_label(&self) -> Option<String>
The opt-in labels joined by ,, or None when there are none; with an
explicit routing budget, gp-cost-budget=<n>.
pub fn tpe(&self) -> Tpe
pub fn tpe(&self) -> Tpe
The configured TPE (meaningful for SamplerKind::Tpe).
pub fn qmc(&self, seed: u64) -> Qmc
pub fn qmc(&self, seed: u64) -> Qmc
The configured QMC sampler for a study seeded seed (meaningful for
SamplerKind::Sobol); seed is read only by scramble.
pub fn gp(&self) -> GpEi
pub fn gp(&self) -> GpEi
The configured GP-EI (meaningful for SamplerKind::Gp).
pub fn cmaes(&self) -> Result<Cmaes, String>
pub fn cmaes(&self) -> Result<Cmaes, String>
A fresh configured CMA-ES (meaningful for SamplerKind::Cmaes).
§Errors
The sampler’s refusal of separable with margin.
pub fn auto_settings(&self) -> AutoSamplerSettings
pub fn auto_settings(&self) -> AutoSamplerSettings
The configured auto settings (meaningful for SamplerKind::Auto).
pub fn build_for(
&self,
space: &SpaceSchema,
budget: &Budget,
directions: &[Direction],
seed: u64,
) -> Result<Arc<dyn Sampler>, String>
pub fn build_for( &self, space: &SpaceSchema, budget: &Budget, directions: &[Direction], seed: u64, ) -> Result<Arc<dyn Sampler>, String>
Builds a fresh sampler for a study of this shape seeded seed.
Without opt-ins or opt-outs this is SamplerKind::build_for itself,
so the default path cannot drift. seed is read only by scramble.
§Errors
The CMA-ES refusal cmaes reports, which
with_opt_in already rejects up front.
Trait Implementations§
§impl Clone for SamplerConfig
impl Clone for SamplerConfig
§fn clone(&self) -> SamplerConfig
fn clone(&self) -> SamplerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for SamplerConfig
impl Debug for SamplerConfig
impl Eq for SamplerConfig
§impl PartialEq for SamplerConfig
impl PartialEq for SamplerConfig
impl StructuralPartialEq for SamplerConfig
Auto Trait Implementations§
impl Freeze for SamplerConfig
impl RefUnwindSafe for SamplerConfig
impl Send for SamplerConfig
impl Sync for SamplerConfig
impl Unpin for SamplerConfig
impl UnsafeUnpin for SamplerConfig
impl UnwindSafe for SamplerConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more