mod sampler¶
- module sampler¶
Stan-style single-step sampler trait: trait Sampler<T>. trait Sampler<T>: a single-step interface for the SA driver loop.
Stan’s
base_mcmc::transition(stan/mcmc/base_mcmc.hpp:21) factors the per-step logic into one virtual call, with the driver loop inservices/util/generate_transitions.hpp:42independent of which sampler is wired. Ourrun_rspreviously monomorphised on five type parameters <O, C, N, M, A>; this trait gives the driver a single type bound and a single dispatch point.Traits
- trait Sampler<T: Float>¶
One step of an SA driver: take the current state at the given epoch, produce a new state, and report whether the proposal was accepted.
The trait is intentionally minimal: state, temperature schedule, and proposal+accept logic all live behind
step. This lets the driver loop (run_rs) treat preset, custom, and adaptive variants through a single dispatch point.Functions
- fn best_pair(&self, state: &State) -> FPair<f64>¶
Best-seen pair for the given state. Default impl returns
state.best.
- fn initial_state<R: Rng>(&self, rng: &mut R) -> State¶
Draws an initial state from the sampler’s prior (uniform on the objective’s bounds for the shipped impl).
- fn initial_state_from_position(&self, _pos: Array1<f64>) -> Option<State>¶
Constructs an initial state from a bounded design point.
- fn qmc_bounds(&self) -> Option<&Bounds<f64>>¶
Bounds for low-discrepancy starts when the sampler can construct a state from an externally supplied position.
- fn step<R: Rng>(&self, state: &mut State, epoch: usize, rng: &mut R) -> bool¶
One proposal + accept cycle at the given epoch. Mutates
statein place and returnstrueiff the proposal was accepted.
Implemented for
-
impl<O, C, N, M, A> Sampler<f64> for SaVariant<f64, O, C, N, M, A>¶
where
O: eindir_core::Objective<f64> + Send + Sync,
C: Cooling<f64>,
N: Neighborhood<f64>,
M: MoveKernel<f64>,
A: AcceptRule<f64>
¶
Structs and Unions
- struct HoppingSampler<C, M, A, Q>¶
Basin-hopping sampler with interchangeable proposal and quench kernels.
run_rsowns the hop loop. This type supplies the basin-hopping step: propose from the current local minimum, quench the proposal, then apply the configured acceptance rule to the two quenched objective values. Cluster moves and ordinary continuous-space kernels therefore use the same driver.Implementations
-
impl<C, M, A, Q> HoppingSampler<C, M, A, Q>¶
where
Q: for<'a> FnMut(ArrayView1<'a, f64>, usize) -> FPair<f64> + Send
¶ Functions
- fn new(initial_position: Array1<f64>, mover: M, cooling: C, accept: A, quench_steps: usize, quench: Q) -> Self¶
Constructs a basin-hopping sampler from general sampler components.
Traits implemented
-
impl<C, M, A, Q> Sampler<f64> for HoppingSampler<C, M, A, Q>¶
where
C: Cooling<f64>,
M: MoveKernel<f64>,
A: AcceptRule<f64>,
Q: for<'a> FnMut(ArrayView1<'a, f64>, usize) -> FPair<f64> + Send
¶
-
impl<C, M, A, Q> HoppingSampler<C, M, A, Q>¶