Skip to main content

Antithetic

Struct Antithetic 

pub struct Antithetic;
Expand description

Uniform sampling with antithetic pairs: trial 2k + 1 mirrors trial 2k.

History-dependent — see the crate documentation for why it cannot be stateless — and persists nothing. Construct it with Antithetic::new.

A unit struct, and that is the point: everything it needs is either handed to it per trial or already recorded in the study. A sampler holding interior mutability would owe the determinism contract an explanation, and would have to persist that state through Sampler::state to survive a resume.

Implementations§

§

impl Antithetic

pub const fn new() -> Self

Creates the sampler.

Trait Implementations§

§

impl Clone for Antithetic

§

fn clone(&self) -> Antithetic

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Copy for Antithetic

§

impl Debug for Antithetic

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for Antithetic

§

fn default() -> Antithetic

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

impl Sampler for Antithetic

§

fn infer_relative_space(&self, study: &StudyView) -> Result<SpaceSchema>

The study’s declared space, or an empty one.

An empty schema is legal and means “sample everything independently”, which this sampler answers identically through sample_independent.

§

fn sample_relative( &self, study: &StudyView, trial: &TrialMeta, space: &SpaceSchema, ) -> Result<Assignment>

Draws every parameter of the joint space.

§

fn sample_independent( &self, study: &StudyView, trial: &TrialMeta, name: &str, dist: &Distribution, ) -> Result<ParamValue>

Draws one parameter the relative space did not cover.

Identical to what sample_relative would have produced for it: a parameter that migrates between the declared space and the define-by-run fallback must keep its value.

§

fn reseed(&self, _seed: u64)

Nothing to reseed.

The hook exists for a sampler with auxiliary randomness of its own. Every seed this one uses comes from TrialMeta, which the framework has already made worker-independent, so the correct implementation is empty — not a hidden self.rng = … that would make a draw depend on which worker called it.

§

fn after_trial( &self, study: &StudyView, trial: &FrozenTrial, ) -> Result<(), Error>

Called once a trial reaches a terminal state. Read more
§

fn state(&self) -> Result<Option<StateBlob>, Error>

The sampler’s persistable state, if it has any. Read more
§

fn snapshots_space(&self) -> bool

Whether this sampler enumerates a snapshot of the space it was constructed with, rather than the space each ask presents. Read more
§

fn restore_state(&self, blob: &StateBlob) -> Result<(), Error>

Restores a sampler from a previously persisted blob. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more