Skip to main content

Qmc

Struct Qmc 

pub struct Qmc;
Expand description

A quasi-random Sobol sampler.

Stateless and configuration-free: construct with Qmc::new and hand it to a study through StudyBuilder::sampler. See the module-level documentation for the sequence and its guarantees.

use atune_core::sampler::{Qmc, Sampler};
use atune_core::id::{StudyId, TrialId, TrialNumber};
use atune_core::space::{Distribution, ParamSpec, SpaceSchema};
use atune_core::study::StudyView;
use atune_core::trial::TrialMeta;

let space = SpaceSchema::new([
    ParamSpec::new("x", Distribution::float(0.0, 1.0).unwrap()).unwrap(),
    ParamSpec::new("y", Distribution::float(0.0, 1.0).unwrap()).unwrap(),
])
.unwrap();

let qmc = Qmc::new();
let view = StudyView::new(StudyId::new(0), vec![], Some(space.clone()));
let meta = TrialMeta::derive(TrialId::new(1), TrialNumber::new(0), 42);

// The very first Sobol point is the origin of the cube.
let first = qmc.sample_relative(&view, &meta, &space).unwrap();
assert_eq!(first.get("x"), Some(&atune_core::space::ParamValue::F64(0.0)));

Implementations§

§

impl Qmc

pub const fn new() -> Self

Creates the sampler.

Trait Implementations§

§

impl Clone for Qmc

§

fn clone(&self) -> Qmc

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 Qmc

§

impl Debug for Qmc

§

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

Formats the value using the given formatter. Read more
§

impl Default for Qmc

§

fn default() -> Qmc

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

impl Eq for Qmc

§

impl PartialEq for Qmc

§

fn eq(&self, other: &Qmc) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl Sampler for Qmc

§

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

The study’s declared space, or the intersection of the visible trials’ parameters for a define-by-run study — the same shape every built-in sampler infers.

§Errors

Error::InvalidSpace if a recorded parameter name is empty, which no writer of this crate produces.

§

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

The Sobol point of this trial’s number, dimension-assigned by sorted name.

§Errors

Error::InvalidSpace if a declared distribution is malformed; Error::Sampler once the trial number leaves the sequence’s SOBOL_POINTS budget.

§

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

The uniform Random draw.

A parameter outside the relative space has no assigned Sobol dimension, so it cannot take part in the joint low-discrepancy fill; it gets the deterministic per-name uniform draw instead, exactly as Optuna’s QMC sampler does.

§Errors

Error::InvalidSpace if dist is malformed.

§

fn reseed(&self, _seed: u64)

A no-op: the Sobol point is a pure function of the trial number, so a reseed cannot move it without breaking the low-discrepancy guarantee. See Random::reseed for the full argument.

§

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

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

fn state(&self) -> Result<Option<SamplerState>>

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: &SamplerState) -> Result<()>

Restores a sampler from a previously persisted blob. Read more
§

impl StructuralPartialEq for Qmc

Auto Trait Implementations§

§

impl Freeze for Qmc

§

impl RefUnwindSafe for Qmc

§

impl Send for Qmc

§

impl Sync for Qmc

§

impl Unpin for Qmc

§

impl UnsafeUnpin for Qmc

§

impl UnwindSafe for Qmc

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