Struct net_ensembles::sampling::rees::ReplicaExchangeEntropicSampling [−][src]
pub struct ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> { /* fields omitted */ }
Expand description
Struct used for entropic sampling with replica exchanges
See this, also for merge functions to create the final probability density functions
Implementations
impl<Ensemble, R, Hist, Energy, S, Res, Extra> ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>
impl<Ensemble, R, Hist, Energy, S, Res, Extra> ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>
Iterator over ensembles
If you do not know what RwLockReadGuard<'a, Ensemble>
is - do not worry.
you can just pretend it is &Ensemble
and everything should work out fine,
since it implements Deref
.
Of cause, you can also take a look at RwLockReadGuard
read access to your ensembles
- None if index out of range
- If you do not know what
RwLockReadGuard<Ensemble>
is - do not worry. you can just pretend it is&Ensemble
and everything will work out fine, since it implementsDeref
. Of cause, you can also take a look atRwLockReadGuard
mut access to your ensembles
- if possible, prefer
get_ensemble
- unsafe only use this if you know what you are doing
- it is assumed, that whatever you change has no effect on the Markov Chain, the result of the energy function etc.
None
ifindex
out of range- might panic if a thread is poisened
Mutable iterator over ensembles
- if possible, prefer
ensemble_iter
- unsafe only use this if you know what you are doing
- it is assumed, that whatever you change has no effect on the Markov Chain, the result of the energy function etc.
- might panic if a thread is poisened
impl<Extra, Ensemble, R, Hist, Energy, S, Res> ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>
impl<Extra, Ensemble, R, Hist, Energy, S, Res> ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>
Checks threshold
returns true, if all walkers are finished
Returns number of walkers per interval
Returns internal walkers
- access to internal slice of walkers
- the walkers are sorted and neighboring walker are either sampling the same interval, or a neighboring (and if the replica exchange makes any sense overlapping) interval
Change step size for markov chain of walkers
- changes the step size used in the sweep
- changes step size of all walkers in the nth interval
- returns Err if index out of bounds, i.e., the requested interval does not exist
- interval counting starts at 0, i.e., n=0 is the first interval
Get step size for markov chain of walkers
- returns
None
if index out of bounds, i.e., the requested interval does not exist - interval counting starts at 0, i.e., n=0 is the first interval
pub fn change_sweep_size_of_interval(
&mut self,
n: usize,
sweep_size: NonZeroUsize
) -> Result<(), ()>
pub fn change_sweep_size_of_interval(
&mut self,
n: usize,
sweep_size: NonZeroUsize
) -> Result<(), ()>
Change sweep size for markov chain of walkers
- changes the sweep size used in the sweep
- changes sweep size of all walkers in the nth interval
- returns Err if index out of bounds, i.e., the requested interval does not exist
- interval counting starts at 0, i.e., n=0 is the first interval
Get sweep size for markov chain of walkers
- returns
None
if index out of bounds, i.e., the requested interval does not exist - interval counting starts at 0, i.e., n=0 is the first interval
pub fn unpack_extra(
self
) -> (ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res>, Vec<Extra, Global>)
pub fn unpack_extra(
self
) -> (ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res>, Vec<Extra, Global>)
Remove extra vector
- returns tuple of Self (without extra, i.e.,
Rees<(), Ensemble, R, Hist, Energy, S, Res>
) and vector of Extra
Swap the extra vector
- Note: len of extra has to be the same as
self.num_walkers()
(which is the same asself.extra_slice().len()
) otherwise an Err is returned
impl<Ensemble, R, Hist, Energy, S, Res> ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res>
impl<Ensemble, R, Hist, Energy, S, Res> ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res>
Add extra information to your Replica Exchange entropic sampling simulation
- can be used to, e.g., print stuff during the simulation, or write it to a file and so on
impl<Extra, Ensemble, R, Hist, Energy, S, Res> ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
R: Send + Sync + Rng,
S: Send + Sync,
Res: Send + Sync,
Hist: Send + Sync + Histogram + HistogramVal<Energy>,
Energy: Send + Sync + Clone,
Ensemble: Send + Sync + MarkovChain<S, Res>,
Extra: Send + Sync,
impl<Extra, Ensemble, R, Hist, Energy, S, Res> ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
R: Send + Sync + Rng,
S: Send + Sync,
Res: Send + Sync,
Hist: Send + Sync + Histogram + HistogramVal<Energy>,
Energy: Send + Sync + Clone,
Ensemble: Send + Sync + MarkovChain<S, Res>,
Extra: Send + Sync,
Refine the estimate of the probability density functions
- refines the estimate of all walkers
- does so by calling the walker method refine
Sweep
- Performs one sweep of the Replica exchange entropic sampling simulation
- You can make a complete simulation, by repeatatly calling this method
until
self.is_finished()
returns true
Perform the Replica exchange simulation
- will simulate until all walkers are finished
- extra_fn should be used for example for writing Data to a file
pub fn simulate_while<F, C, P>(
&mut self,
energy_fn: F,
condition: C,
extra_fn: P
) where
C: FnMut(&ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>) -> bool,
F: Fn(&mut Ensemble) -> Option<Energy> + Copy + Send + Sync,
R: Send + Sync,
Ensemble: Send + Sync,
P: Fn(&ReesWalker<R, Hist, Energy, S, Res>, &mut Ensemble, &mut Extra) + Copy + Send + Sync,
pub fn simulate_while<F, C, P>(
&mut self,
energy_fn: F,
condition: C,
extra_fn: P
) where
C: FnMut(&ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>) -> bool,
F: Fn(&mut Ensemble) -> Option<Energy> + Copy + Send + Sync,
R: Send + Sync,
Ensemble: Send + Sync,
P: Fn(&ReesWalker<R, Hist, Energy, S, Res>, &mut Ensemble, &mut Extra) + Copy + Send + Sync,
Perform the Replica exchange simulation
- will simulate until all walkers are finished or
- until condition returns false
Sanity check
- checks if the stored (i.e., last) energy(s) of the system match with the result of energy_fn
pub fn merged_log_prob(&self) -> Result<(Hist, Vec<f64, Global>), HistErrors> where
Hist: HistogramCombine,
pub fn merged_log_prob(&self) -> Result<(Hist, Vec<f64, Global>), HistErrors> where
Hist: HistogramCombine,
Result of the simulations!
This is what we do the simulation for!
It returns the natural logarithm of the normalized (i.e. sum=1 within numerical precision) probability density and the histogram, which contains the corresponding bins.
Failes if the internal histograms (invervals) do not align. Might fail if there is no overlap between neighboring intervals
pub fn merged_log_prob_and_aligned(
&self
) -> Result<(Hist, Vec<f64, Global>, Vec<Vec<f64, Global>, Global>), HistErrors> where
Hist: HistogramCombine,
pub fn merged_log_prob_and_aligned(
&self
) -> Result<(Hist, Vec<f64, Global>, Vec<Vec<f64, Global>, Global>), HistErrors> where
Hist: HistogramCombine,
Results of the simulation
This is what we do the simulation for!
It returns histogram, which contains the corresponding bins and the natural logarithm of the normalized (i.e. sum=1 within numerical precision) probability density. Lastly it returns the vector of the aligned probability estimates (also ln) of the different intervals. This can be used to see, how good the simulation worked, e.g., by plotting them to see, if they match
Notes
Failes if the internal histograms (invervals) do not align. Might fail if there is no overlap between neighboring intervals
Trait Implementations
impl<'de, Extra, Ensemble, R, Hist, Energy, S, Res> Deserialize<'de> for ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
R: Deserialize<'de>,
S: Deserialize<'de>,
Res: Deserialize<'de>,
Hist: Deserialize<'de>,
Energy: Deserialize<'de>,
Ensemble: Deserialize<'de>,
Extra: Deserialize<'de>,
impl<'de, Extra, Ensemble, R, Hist, Energy, S, Res> Deserialize<'de> for ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
R: Deserialize<'de>,
S: Deserialize<'de>,
Res: Deserialize<'de>,
Hist: Deserialize<'de>,
Energy: Deserialize<'de>,
Ensemble: Deserialize<'de>,
Extra: Deserialize<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<Ensemble, R, Hist, Energy, S, Res> From<ReplicaExchangeWangLandau<Ensemble, R, Hist, Energy, S, Res>> for ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res> where
Hist: Histogram,
impl<Ensemble, R, Hist, Energy, S, Res> From<ReplicaExchangeWangLandau<Ensemble, R, Hist, Energy, S, Res>> for ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res> where
Hist: Histogram,
pub fn from(
rewl: ReplicaExchangeWangLandau<Ensemble, R, Hist, Energy, S, Res>
) -> ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res>
pub fn from(
rewl: ReplicaExchangeWangLandau<Ensemble, R, Hist, Energy, S, Res>
) -> ReplicaExchangeEntropicSampling<(), Ensemble, R, Hist, Energy, S, Res>
Performs the conversion.
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl<Extra, Ensemble, R, Hist, Energy, S, Res> RefUnwindSafe for ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
Energy: RefUnwindSafe,
Extra: RefUnwindSafe,
Hist: RefUnwindSafe,
R: RefUnwindSafe,
Res: RefUnwindSafe,
S: RefUnwindSafe,
impl<Extra, Ensemble, R, Hist, Energy, S, Res> Send for ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
Energy: Send,
Ensemble: Send,
Extra: Send,
Hist: Send,
R: Send,
Res: Send,
S: Send,
impl<Extra, Ensemble, R, Hist, Energy, S, Res> Sync for ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
Energy: Sync,
Ensemble: Send + Sync,
Extra: Sync,
Hist: Sync,
R: Sync,
Res: Sync,
S: Sync,
impl<Extra, Ensemble, R, Hist, Energy, S, Res> Unpin for ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
Energy: Unpin,
Ensemble: Unpin,
Extra: Unpin,
Hist: Unpin,
R: Unpin,
Res: Unpin,
S: Unpin,
impl<Extra, Ensemble, R, Hist, Energy, S, Res> UnwindSafe for ReplicaExchangeEntropicSampling<Extra, Ensemble, R, Hist, Energy, S, Res> where
Energy: UnwindSafe,
Extra: UnwindSafe,
Hist: UnwindSafe,
R: UnwindSafe,
Res: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn cast_trunc(self) -> T
pub fn cast_trunc(self) -> T
Cast to integer, truncating Read more
pub fn cast_nearest(self) -> T
pub fn cast_nearest(self) -> T
Cast to the nearest integer Read more
pub fn cast_floor(self) -> T
pub fn cast_floor(self) -> T
Cast the floor to an integer Read more
pub fn try_cast_trunc(self) -> Result<T, Error>
pub fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
pub fn try_cast_nearest(self) -> Result<T, Error>
pub fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
pub fn try_cast_floor(self) -> Result<T, Error>
pub fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
pub fn try_cast_ceil(self) -> Result<T, Error>
pub fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more