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
impl Antithetic
pub const fn new() -> Self
pub const fn new() -> Self
Creates the sampler.
Trait Implementations§
§impl Clone for Antithetic
impl Clone for Antithetic
§fn clone(&self) -> Antithetic
fn clone(&self) -> Antithetic
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Antithetic
§impl Debug for Antithetic
impl Debug for Antithetic
§impl Default for Antithetic
impl Default for Antithetic
§fn default() -> Antithetic
fn default() -> Antithetic
§impl Sampler for Antithetic
impl Sampler for Antithetic
§fn infer_relative_space(&self, study: &StudyView) -> Result<SpaceSchema>
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>
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>
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)
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>
fn after_trial( &self, study: &StudyView, trial: &FrozenTrial, ) -> Result<(), Error>
§fn state(&self) -> Result<Option<StateBlob>, Error>
fn state(&self) -> Result<Option<StateBlob>, Error>
§fn snapshots_space(&self) -> bool
fn snapshots_space(&self) -> bool
§fn reads_constraints(&self) -> bool
fn reads_constraints(&self) -> bool
FrozenTrial::constraints on the views it
is asked with. Read more