pub struct CoEvolutionaryHarness<B, C>where
B: Backend,
C: CoEvolutionaryAlgorithm<B>,{ /* private fields */ }Expand description
Wraps a CoEvolutionaryAlgorithm into a BenchEnv.
Like EvolutionaryHarness, the
harness is lazily initialized: reset materializes the
joint state on the configured device, and each
step runs one generation. The reward exposed to the
benchmark harness is the canonical binding_fitness = min(best_a, best_b)
(canonical maximise, no negation): the weaker population — the lower canonical
fitness — is the binding constraint, and a higher binding value is better.
The per-population best_fitness_{a,b} / mean_fitness_{a,b} in
CoEAMetrics are reported in the objective’s natural sense (ADR 0023);
only binding_fitness stays canonical.
Per-generation metrics are emitted through tracing with structured
per-population fields. (A dual-population PopulationObserver channel —
the single-population
PopulationSnapshot cannot carry
both populations — is deferred to a follow-up.)
§Determinism
Determinism follows the same backend-RNG caveats documented on
EvolutionaryHarness: run one
harness per process, or pin EvaluatorConfig::num_threads = Some(1), for
bit-reproducible runs.
Implementations§
Source§impl<B, C> CoEvolutionaryHarness<B, C>where
B: Backend,
C: CoEvolutionaryAlgorithm<B>,
impl<B, C> CoEvolutionaryHarness<B, C>where
B: Backend,
C: CoEvolutionaryAlgorithm<B>,
Sourcepub fn new(
algorithm: C,
params: C::Params,
seed: u64,
device: B::Device,
max_generations: usize,
) -> Result<Self, ConfigError>
pub fn new( algorithm: C, params: C::Params, seed: u64, device: B::Device, max_generations: usize, ) -> Result<Self, ConfigError>
Build a new harness from an algorithm, its params, a seed, a device, and a generation budget.
The caller-supplied params are validated up front — this is the
co-evolutionary harness consumption chokepoint (ADR 0026).
The harness is lazily initialized — the first reset
call materializes the joint state on device.
§Errors
Returns a ConfigError when params fails Validate::validate,
naming the offending field and violated invariant.
Sourcepub fn latest_metrics(&self) -> Option<&CoEAMetrics>
pub fn latest_metrics(&self) -> Option<&CoEAMetrics>
The most recent generation’s metrics, if any.
Sourcepub fn generation(&self) -> usize
pub fn generation(&self) -> usize
Number of completed generations.
Trait Implementations§
Source§impl<B, C> BenchEnv for CoEvolutionaryHarness<B, C>where
B: Backend,
C: CoEvolutionaryAlgorithm<B>,
impl<B, C> BenchEnv for CoEvolutionaryHarness<B, C>where
B: Backend,
C: CoEvolutionaryAlgorithm<B>,
Source§type Observation = ()
type Observation = ()
Source§fn reset(&mut self) -> Result<Self::Observation, BenchError>
fn reset(&mut self) -> Result<Self::Observation, BenchError>
Source§fn step(
&mut self,
action: Self::Action,
) -> Result<BenchStep<Self::Observation>, BenchError>
fn step( &mut self, action: Self::Action, ) -> Result<BenchStep<Self::Observation>, BenchError>
action and advance the environment by one step. Read moreAuto Trait Implementations§
impl<B, C> Freeze for CoEvolutionaryHarness<B, C>where
C: Freeze,
<C as CoEvolutionaryAlgorithm<B>>::Params: Freeze,
<B as BackendTypes>::Device: Freeze,
<C as CoEvolutionaryAlgorithm<B>>::State: Freeze,
impl<B, C> RefUnwindSafe for CoEvolutionaryHarness<B, C>where
C: RefUnwindSafe,
<C as CoEvolutionaryAlgorithm<B>>::Params: RefUnwindSafe,
<B as BackendTypes>::Device: RefUnwindSafe,
<C as CoEvolutionaryAlgorithm<B>>::State: RefUnwindSafe,
B: RefUnwindSafe,
impl<B, C> Send for CoEvolutionaryHarness<B, C>
impl<B, C> Sync for CoEvolutionaryHarness<B, C>
impl<B, C> Unpin for CoEvolutionaryHarness<B, C>where
C: Unpin,
<C as CoEvolutionaryAlgorithm<B>>::Params: Unpin,
<B as BackendTypes>::Device: Unpin,
<C as CoEvolutionaryAlgorithm<B>>::State: Unpin,
B: Unpin,
impl<B, C> UnsafeUnpin for CoEvolutionaryHarness<B, C>where
C: UnsafeUnpin,
<C as CoEvolutionaryAlgorithm<B>>::Params: UnsafeUnpin,
<B as BackendTypes>::Device: UnsafeUnpin,
<C as CoEvolutionaryAlgorithm<B>>::State: UnsafeUnpin,
impl<B, C> UnwindSafe for CoEvolutionaryHarness<B, C>where
C: UnwindSafe,
<C as CoEvolutionaryAlgorithm<B>>::Params: UnwindSafe,
<B as BackendTypes>::Device: UnwindSafe,
<C as CoEvolutionaryAlgorithm<B>>::State: UnwindSafe,
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more