Skip to main content

SeedProtocol

Struct SeedProtocol 

pub struct SeedProtocol { /* private fields */ }
Expand description

The seed protocol attached to a study: the fan width, the pairing and the aggregate.

The default is single-seed — tune_seeds = 1, no fan — so a study that never touches this type behaves exactly as it did before the protocol existed. See the module documentation for the seed formulas.

Implementations§

§

impl SeedProtocol

pub const fn new() -> Self

The single-seed default: tune_seeds = 1, no test seeds, Paired, Mean.

A study built with this protocol runs one evaluation per trial and takes the fast, fan-free path — byte-for-byte the behaviour of a study with no protocol at all.

pub const fn with_tune_seeds(self, tune_seeds: u32) -> Self

Sets the fan width k (the number of tune seeds per trial).

k <= 1 means “no fan”: fans stays false and the study takes the single-evaluation path. k = 0 is treated as k = 1 rather than being an error — a documented total, not a panic.

pub const fn with_test_seeds(self, test_seeds: u32) -> Self

Sets the number of disjoint seeds the final re-evaluation stage uses.

0 (the default) disables the stage.

pub const fn with_pairing(self, pairing: Pairing) -> Self

Sets the pairing.

pub const fn with_aggregate(self, aggregate: Aggregate) -> Self

Sets the aggregate.

pub const fn tune_seeds(&self) -> u32

The configured fan width, verbatim (0 is possible).

pub const fn test_seeds(&self) -> u32

The number of test seeds; 0 when the re-evaluation stage is off.

pub const fn pairing(&self) -> Pairing

The pairing.

pub const fn aggregate(&self) -> Aggregate

The aggregate.

pub const fn effective_tune_seeds(&self) -> usize

The effective fan width: at least 1 (a tune_seeds of 0 counts as one single evaluation).

pub const fn fans(&self) -> bool

true if this protocol produces a fan of more than one replicate.

When this is false the study loop takes the fan-free path and produces exactly the same trace it would with no protocol at all.

pub const fn has_test_stage(&self) -> bool

true if the final test-seed re-evaluation stage is enabled.

pub fn is_single_seed_default(&self) -> bool

true if this is the single-seed default (SeedProtocol::new).

A persisted StudyConfig tests this to keep the default protocol out of its serialized form: a fan-free study is written byte-for-byte as it was before the protocol became a config field, so on-disk goldens are unchanged. A non-default protocol is serialized in full and restored on resume.

pub const fn tune_seed( &self, study_seed: u64, trial_number: u64, replicate: u32, ) -> u64

The tune seed of replicate replicate in trial trial_number.

See the module documentation for the exact formula. Under Paired the trial_number argument is ignored, which is what makes the seed common across trials.

pub const fn test_seed( &self, study_seed: u64, trial_number: u64, replicate: u32, ) -> u64

The test seed of replicate replicate in trial trial_number.

Uses the shifted replicate index TEST_REPLICATE_OFFSET + replicate, so the test stream is disjoint from the tune stream (see the module documentation).

Trait Implementations§

§

impl Clone for SeedProtocol

§

fn clone(&self) -> SeedProtocol

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 SeedProtocol

§

impl Debug for SeedProtocol

§

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

Formats the value using the given formatter. Read more
§

impl Default for SeedProtocol

§

fn default() -> Self

Single-seed, no fan — see SeedProtocol::new.

§

impl<'de> Deserialize<'de> for SeedProtocol

§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl PartialEq for SeedProtocol

§

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

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

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

Inequality operator !=. Read more
§

impl Serialize for SeedProtocol

§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StructuralPartialEq for SeedProtocol

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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