Skip to main content

ResumableInner

Trait ResumableInner 

Source
pub trait ResumableInner<V, F = f64>: Sized
where F: Scalar,
{ type State: State<Param = V, Float = F> + CountsMirror; // Required methods fn seed_chain( &self, x: &V, fx: F, scale: F, seed: u64, ) -> (Self, Self::State); fn prepare_resume(&self, state: &mut Self::State); // Provided method fn segment_criteria( &self, _state: &Self::State, ) -> Vec<Box<dyn TerminationCriterion<Self::State>>> { ... } }
Expand description

A local-search operator whose full evolution state can be seeded at a point, snapshotted, and resumed: the contract behind MA-LSCh chain persistence (Molina et al. 2010), where an outer solver stores a (solver, state) pair per individual and later continues that exact local-search run.

This is the fourth composition tier, next to the fresh-seed ladder InitialStateWarmStartMemeticInner—but deliberately not a subtrait of InitialState: seed_chain takes an explicit scale hint precisely because a resumable operator (CmaEs) may have no natural σ-free default seed (that’s why Executor::from_start is a compile error for CMA-ES). A solver may implement both tiers (SolisWets does).

§Contract

  • Implementor must: make Solver::init resume-idempotent: calling init on an already-advanced State must not reset evolution state (CMA-ES’s constants cache + non-empty-population skip and Solis-Wets’s cost: Option<_> sentinel are the reference behaviors).
  • Implementor must: make seed_chain a pure function of (self-as-config, x, fx, scale, seed). The prototype’s own RNG must not be consumed: chains derive their streams solely from seed, so outer trajectories stay reproducible.
  • Implementor must: return a state whose State::param equals x.
  • Caller (the outer solver) must: bound the operator’s Solver impl at its own impl site (LS: Solver<P, LS::State, Error = P::Error>), never via a supertrait here; and follow the three composition contracts on InnerExecutor (eval aggregation, criteria reset, failure routing) when driving the chain segment.

Required Associated Types§

Source

type State: State<Param = V, Float = F> + CountsMirror

Evolution-state snapshot stored per chain slot.

Required Methods§

Source

fn seed_chain(&self, x: &V, fx: F, scale: F, seed: u64) -> (Self, Self::State)

Build a fresh per-chain (solver, state) pair anchored at x.

self acts as a configuration prototype: hyperparameters are copied into the returned per-chain solver instance, while the prototype’s own RNG is ignored. fx is the caller’s known cost at x (implementations may prime their state with it to avoid a redundant evaluation, or ignore it). scale is the caller’s scale hint (MA-LSCh passes half the nearest-neighbor distance; it becomes CMA-ES’s σ or Solis-Wets’s ρ). seed seeds the chain’s private RNG stream.

Source

fn prepare_resume(&self, state: &mut Self::State)

Prepare a stored snapshot for its next run segment: reset the local iteration counter and any per-segment bookkeeping. Must not touch evolution state (distribution, bias, step size, streak counters, …)—persisting those across segments is the point of the chain.

Provided Methods§

Source

fn segment_criteria( &self, _state: &Self::State, ) -> Vec<Box<dyn TerminationCriterion<Self::State>>>

Operator-specific per-segment convergence criteria, built from the segment’s starting state (CMA-ES: TolX at 1e-12 · the segment’s starting σ). Budget criteria (MaxCostEvals) are the outer’s responsibility and are checked before these. Default: none (Solis-Wets, which the reference implementation runs purely budget-driven).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<V, F> ResumableInner<V, F> for SolisWets<F>
where F: Scalar, V: Clone + VectorLen + ScaleInPlace<F>,

Source§

impl<V, M, F> ResumableInner<V, F> for CmaEs<V, M, F>
where F: Scalar, V: VectorLen + Clone + ScaleInPlace<F> + IndexMut<usize, Output = F>, M: MatrixIdentity,

Source§

type State = CmaEsState<V, M, F>