Struct TrialMeta
pub struct TrialMeta {
pub id: TrialId,
pub number: TrialNumber,
pub sampler_seed: u64,
}Expand description
The lightweight handle a sampler receives for the trial it is sampling.
§Why the seed is precomputed
sampler_seed is seed_for(study_seed, number, Stream::Sampler), derived
by the framework before the sampler is called. A stateless sampler
therefore does not need — and must not use — any ambient randomness: it
seeds ChaCha8Rng from this value and is
automatically deterministic per trial number, regardless of which
worker runs the trial, in which order trials complete, or how many threads
exist. That is the determinism
contract,
and it is what lets a multithreaded study evaluate exactly the
configuration set a single-threaded one would.
use atune_core::id::{TrialId, TrialNumber};
use atune_core::seed::{Stream, seed_for};
use atune_core::trial::TrialMeta;
let meta = TrialMeta::derive(TrialId::new(99), TrialNumber::new(3), 42);
assert_eq!(meta.sampler_seed, seed_for(42, 3, Stream::Sampler));Fields§
§id: TrialIdStorage-global identity.
number: TrialNumberPer-study ordinal — what the seed is derived from.
sampler_seed: u64The precomputed Stream::Sampler seed for this trial.
Implementations§
§impl TrialMeta
impl TrialMeta
pub const fn new(id: TrialId, number: TrialNumber, sampler_seed: u64) -> Self
pub const fn new(id: TrialId, number: TrialNumber, sampler_seed: u64) -> Self
Builds a handle from an already-derived seed.
pub const fn derive(id: TrialId, number: TrialNumber, study_seed: u64) -> Self
pub const fn derive(id: TrialId, number: TrialNumber, study_seed: u64) -> Self
Builds a handle, deriving the sampler seed from the study seed.