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§
Trait Implementations§
impl Copy for Qmc
impl Eq for Qmc
§impl Sampler for Qmc
impl Sampler for Qmc
§fn infer_relative_space(&self, study: &StudyView) -> Result<SpaceSchema>
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>
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>
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)
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.