mod replica_exchange

module replica_exchange

Temperature spread across a cooperative ensemble and its exchange. Temperature spread across a cooperative ensemble, and the exchange that makes it worth having.

An ensemble at one temperature is one search repeated. The funnel problem it fails on is the classical one: a chain equilibrated in a narrow funnel does not cross to a wide one on any reasonable timescale, and LJ38 is the benchmark case where the global minimum sits in the narrow funnel while the entropically favoured region is elsewhere. Spreading replicas in temperature and exchanging between them is the reference answer to exactly that, older than any of the descriptor machinery above it.

Nothing here owns a socket or a chain. The ladder is arithmetic and the exchange is a predicate, so a coordinator that brokers swaps and a test that replays them see the same rule.

Functions

fn replica_exchange_accepts(energy_a: f64, temperature_a: f64, energy_b: f64, temperature_b: f64, draw: f64) -> bool

Metropolis acceptance for swapping two rungs of the ladder.

The exchange is accepted with probability (min[1, e^{(beta_a - beta_b)(E_a - E_b)}]). The sign is what carries the meaning: when the hotter chain is holding the lower energy the exponent is positive and the swap is certain, which is how a discovery made at high temperature is handed down to a chain cold enough to refine it. When the cold chain already holds the better structure the swap is possible but unlikely, so the ladder does not casually throw away what it has.

draw is the uniform variate, supplied so the decision is a pure function of its inputs and a replay reproduces it.

fn replica_temperature(replica: u32, replicas: usize, base: f64, top: f64) -> f64

Temperature this replica walks at, or base when it has no rung.

fn temperature_ladder(replicas: usize, base: f64, top: f64) -> Vec<f64>

Geometric temperature ladder for replicas chains.

Geometric rather than linear because the acceptance of an exchange depends on the gap in inverse temperature, so equal ratios give comparable acceptance along the ladder instead of crowding the cold end. A single replica keeps base, and a non-finite or non-positive bound yields an empty ladder rather than a silent default.