pub struct EntropicSamplingAdaptive<Hist, R, E, S, Res, T> { /* private fields */ }Expand description
§Entropic sampling made easy
J. Lee, “New Monte Carlo algorithm: Entropic sampling,” Phys. Rev. Lett. 71, 211–214 (1993), DOI: 10.1103/PhysRevLett.71.211
Implementations§
Source§impl<Hist, R, E, S, Res, T> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Sourcepub fn energy(&self) -> &T
pub fn energy(&self) -> &T
§Energy of ensemble
- assuming
energy_fn(seeself.entropic_stepetc.) is deterministic and will always give the same result for the same ensemble, this returns the energy of the current ensemble
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
§Number of entropic steps done until now
- will be reset by
self.refine_estimate
Sourcepub fn step_goal(&self) -> usize
pub fn step_goal(&self) -> usize
§Number of entropic steps to be performed
- if
selfwas created fromWangLandauAdaptive,step_goalwill be equal to the number of WangLandau steps, that were performed
Sourcepub fn set_step_goal(&mut self, step_goal: usize)
pub fn set_step_goal(&mut self, step_goal: usize)
§Number of entropic steps to be performed
- set the number of steps to be performed by entropic sampling
Sourcepub fn min_step_size(&self) -> usize
pub fn min_step_size(&self) -> usize
§Smallest possible markov step (m_steps of MarkovChain trait) by entropic step
Sourcepub fn max_step_size(&self) -> usize
pub fn max_step_size(&self) -> usize
§Largest possible markov step (m_steps of MarkovChain trait) by entropic step
Sourcepub fn best_of_steps(&self) -> &Vec<usize>
pub fn best_of_steps(&self) -> &Vec<usize>
§Currently used best of
- might have length 0, if statistics are still being gathered
- otherwise this contains the step sizes, from which the next step size is drawn uniformly
Sourcepub fn fraction_accepted_current(&self) -> f64
pub fn fraction_accepted_current(&self) -> f64
§Fraction of steps accepted since the statistics were reset the last time
- (steps accepted since last reset) / (steps since last reset)
NaNif no steps were performed yet
Sourcepub fn total_entr_steps_accepted(&self) -> usize
pub fn total_entr_steps_accepted(&self) -> usize
§total number of entropic steps, that were accepted
Sourcepub fn total_entr_steps_rejected(&self) -> usize
pub fn total_entr_steps_rejected(&self) -> usize
§total number of entropic steps, that were rejected
Sourcepub fn fraction_accepted_total_entropic(&self) -> f64
pub fn fraction_accepted_total_entropic(&self) -> f64
§Fraction of steps accepted since the creation of self
NaNif no steps were performed yet
Sourcepub fn log_density_estimate(&self) -> &Vec<f64>
pub fn log_density_estimate(&self) -> &Vec<f64>
- returns the (non normalized) log_density estimate log(P(E)), with which the simulation was started
- if you created this from a WangLandau simulation, this is the result of the WangLandau Simulation
Source§impl<Hist, R, E, S, Res, T> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Sourcepub fn from_wl_adaptive(
wl: WangLandauAdaptive<Hist, R, E, S, Res, T>,
) -> Result<Self, EntropicErrors>
pub fn from_wl_adaptive( wl: WangLandauAdaptive<Hist, R, E, S, Res, T>, ) -> Result<Self, EntropicErrors>
§Creates EntropicSamplingAdaptive from a WangLandauAdaptive state
WangLandauAdaptivestate needs to be valid, i.e., you must have called one of theinit*methods
- this ensures, that the members
old_energyandold_binare notNone
Sourcepub fn refine_estimate(&mut self) -> Vec<f64>
pub fn refine_estimate(&mut self) -> Vec<f64>
Sourcepub fn set_adjust_bestof_every(&mut self, adjust_bestof_every: usize)
pub fn set_adjust_bestof_every(&mut self, adjust_bestof_every: usize)
§How often to adjust bestof_steps?
- if you try to set a value smaller 10, it will be set to 10
- will re-evaluate the statistics every
adjust_bestof_everysteps,
- this will not start new statistics gathering but just trigger a reevaluation of the gathered statistics (should be O(max_stepsize - min_stepsize))
Sourcepub fn is_rebuilding_statistics(&self) -> bool
pub fn is_rebuilding_statistics(&self) -> bool
Is the simulation in the process of rebuilding the statistics, i.e., is it currently trying many different step sizes?
Sourcepub fn estimate_statistics(&self) -> Result<Vec<f64>, WangLandauErrors>
pub fn estimate_statistics(&self) -> Result<Vec<f64>, WangLandauErrors>
§Estimate accept/reject statistics
- contains list of estimated probabilities for accepting a step of corresponding step size
- list[i] corresponds to step size
i + self.min_step - O(trial_step_max - trial_step_min)
Source§impl<Hist, R, E, S, Res, T> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Sourcepub unsafe fn entropic_sampling_while_unsafe<F, G, W>(
&mut self,
energy_fn: F,
print_fn: G,
condition: W,
)
pub unsafe fn entropic_sampling_while_unsafe<F, G, W>( &mut self, energy_fn: F, print_fn: G, condition: W, )
§Entropic sampling
- performs
self.entropic_step(energy_fn)untilconditionis false - Note: you have access to the current step_count (
self.step_count())
§Parameter
energy_fnfunction calculatingSome(energy)of the system or rather the Parameter of which you wish to obtain the probability distribution. If there are any states, for which the calculation is invalid,Noneshould be returned- steps resulting in ensembles for which
energy_fn(&mut ensemble)isNonewill always be rejected - Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong! print_fn: see below
§Correlations
- if you want to measure correlations between “energy” and other measurable quantities,
use
print_fn, which will be called after each step - use this function to write to a file or whatever you desire - Note: You do not have to recalculate the energy, if you need it in
print_fn: just callself.energy() - you have access to your ensemble with
self.ensemble() - if you do not need it, you can use
|_|{}asprint_fn
§Safety
- While you do have mutable access to the ensemble, the energy function should not change the ensemble in a way, which affects the next calculation of the energy
- This is intended for usecases, where the energy calculation is more efficient with mutable access, e.g., through using a buffer stored in the ensemble
- Note: I chose to make this function unsafe to force users to acknowledge the (purely logical) limitations regarding the usage of the mutable ensemble. From a programming point of view this will not lead to any undefined behavior or such regardless of if the user fulfills the requirements
Sourcepub fn entropic_sampling_while<F, G, W>(
&mut self,
energy_fn: F,
print_fn: G,
condition: W,
)
pub fn entropic_sampling_while<F, G, W>( &mut self, energy_fn: F, print_fn: G, condition: W, )
§Entropic sampling
- performs
self.entropic_step(energy_fn)untilconditionis false - Note: you have access to the current step_count (
self.step_count())
§Parameter
energy_fnfunction calculatingSome(energy)of the system or rather the Parameter of which you wish to obtain the probability distribution. If there are any states, for which the calculation is invalid,Noneshould be returned- steps resulting in ensembles for which
energy_fn(&mut ensemble)isNonewill always be rejected - Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong! print_fn: see below
§Correlations
- if you want to measure correlations between “energy” and other measurable quantities,
use
print_fn, which will be called after each step - use this function to write to a file or whatever you desire - Note: You do not have to recalculate the energy, if you need it in
print_fn: just callself.energy() - you have access to your ensemble with
self.ensemble() - if you do not need it, you can use
|_|{}asprint_fn
Sourcepub fn entropic_sampling_while_acc<F, G, W>(
&mut self,
energy_fn: F,
print_fn: G,
condition: W,
)
pub fn entropic_sampling_while_acc<F, G, W>( &mut self, energy_fn: F, print_fn: G, condition: W, )
§Entropic sampling using an accumulating markov step
- performs
self.entropic_step_acc(&mut energy_fn)untilcondition(self) == false
§Parameter
energy_fnfunction calculating the energyEof the system (or rather the Parameter of which you wish to obtain the probability distribution) during the markov steps, which can be more efficient.- Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong! print_fn: see below
§Correlations
- if you want to measure correlations between “energy” and other measurable quantities,
use
print_fn, which will be called after each step - use this function to write to a file or whatever you desire - Note: You do not have to recalculate the energy, if you need it in
print_fn: just callself.energy() - you have access to your ensemble with
self.ensemble() - if you do not need it, you can use
|_|{}asprint_fn
Sourcepub unsafe fn entropic_sampling_unsafe<F, G>(
&mut self,
energy_fn: F,
print_fn: G,
)
pub unsafe fn entropic_sampling_unsafe<F, G>( &mut self, energy_fn: F, print_fn: G, )
§Entropic sampling
- if possible, use
self.entropic_sampling()instead! - More powerful version of
self.entropic_sampling(), since you now have mutable access - to access ensemble mutable, use
self.ensemble_mut() - Note: Whatever you do with the ensemble (or self), should not change the result of the energy function, if performed again. Otherwise the results will be false!
- performs
self.entropic_step_unsafe(energy_fn)untilself.step_count == self.step_goal
§Parameter
energy_fnfunction calculatingSome(energy)of the system or rather the Parameter of which you wish to obtain the probability distribution. If there are any states, for which the calculation is invalid,Noneshould be returned- steps resulting in ensembles for which
energy_fn(&mut ensemble)isNonewill always be rejected - Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong! print_fn: see below
§Correlations
- if you want to measure correlations between “energy” and other measurable quantities,
use
print_fn, which will be called after each step - use this function to write to a file or whatever you desire - Note: You do not have to recalculate the energy, if you need it in
print_fn: just callself.energy() - you have access to your ensemble with
self.ensemble() - if you do not need it, you can use
|_|{}asprint_fn
§Safety
- While you do have mutable access to the ensemble, the energy function should not change the ensemble in a way, which affects the next calculation of the energy
- This is intended for usecases, where the energy calculation is more efficient with mutable access, e.g., through using a buffer stored in the ensemble
- Note: I chose to make this function unsafe to force users to acknowledge the (purely logical) limitations regarding the usage of the mutable ensemble. From a programming point of view this will not lead to any undefined behavior or such regardless of if the user fulfills the requirements
Sourcepub fn entropic_sampling<F, G>(&mut self, energy_fn: F, print_fn: G)
pub fn entropic_sampling<F, G>(&mut self, energy_fn: F, print_fn: G)
§Entropic sampling
- performs
self.entropic_step(energy_fn)untilself.step_count == self.step_goal
§Parameter
energy_fnfunction calculatingSome(energy)of the system or rather the Parameter of which you wish to obtain the probability distribution. If there are any states, for which the calculation is invalid,Noneshould be returned- steps resulting in ensembles for which
energy_fn(&mut ensemble)isNonewill always be rejected - Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong! print_fn: see below
§Correlations
- if you want to measure correlations between “energy” and other measurable quantities,
use
print_fn, which will be called after each step - use this function to write to a file or whatever you desire - Note: You do not have to recalculate the energy, if you need it in
print_fn: just callself.energy() - you have access to your ensemble with
self.ensemble() - if you do not need it, you can use
|_|{}asprint_fn
Sourcepub fn entropic_sampling_acc<F, G>(&mut self, energy_fn: F, print_fn: G)
pub fn entropic_sampling_acc<F, G>(&mut self, energy_fn: F, print_fn: G)
§Entropic sampling using an accumulating markov step
- performs
self.entropic_step_acc(&mut energy_fn)untilself.step_count == self.step_goal
§Parameter
energy_fnfunction calculating the energyEof the system (or rather the Parameter of which you wish to obtain the probability distribution) during the markov steps, which can be more efficient.- Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong! print_fn: see below
§Correlations
- if you want to measure correlations between “energy” and other measurable quantities,
use
print_fn, which will be called after each step - use this function to write to a file or whatever you desire - Note: You do not have to recalculate the energy, if you need it in
print_fn: just callself.energy() - you have access to your ensemble with
self.ensemble() - if you do not need it, you can use
|_|{}asprint_fn
Sourcepub unsafe fn entropic_step_unsafe<F>(&mut self, energy_fn: F)
pub unsafe fn entropic_step_unsafe<F>(&mut self, energy_fn: F)
§Entropic step
- performs a single step
§Parameter
energy_fnfunction calculatingSome(energy)of the system or rather the Parameter of which you wish to obtain the probability distribution. If there are any states, for which the calculation is invalid,Noneshould be returned- steps resulting in ensembles for which
energy_fn(&mut ensemble)isNonewill always be rejected
§Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong!
§Safety
- While you do have mutable access to the ensemble, the energy function should not change the ensemble in a way, which affects the next calculation of the energy
- This is intended for usecases, where the energy calculation is more efficient with mutable access, e.g., through using a buffer stored in the ensemble
- Note: I chose to make this function unsafe to force users to acknowledge the (purely logical) limitations regarding the usage of the mutable ensemble. From a programming point of view this will not lead to any undefined behavior or such regardless of if the user fulfills the requirements
Sourcepub fn entropic_step<F>(&mut self, energy_fn: F)
pub fn entropic_step<F>(&mut self, energy_fn: F)
§Entropic step
- performs a single step
§Parameter
energy_fnfunction calculatingSome(energy)of the system or rather the Parameter of which you wish to obtain the probability distribution. If there are any states, for which the calculation is invalid,Noneshould be returned- steps resulting in ensembles for which
energy_fn(&mut ensemble)isNonewill always be rejected
§Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong!
Sourcepub fn entropic_step_acc<F>(&mut self, energy_fn: F)
pub fn entropic_step_acc<F>(&mut self, energy_fn: F)
§Accumulating entropic step
- performs a single step
§Parameter
energy_fnfunction calculating the energyEof the system (or rather the Parameter of which you wish to obtain the probability distribution) during the markov steps, which can be more efficient.
§Important
energy_fn: should be the same as used for Wang Landau, otherwise the results will be wrong!
Trait Implementations§
Source§impl<Hist: Clone, R: Clone, E: Clone, S: Clone, Res: Clone, T: Clone> Clone for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist: Clone, R: Clone, E: Clone, S: Clone, Res: Clone, T: Clone> Clone for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Source§fn clone(&self) -> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
fn clone(&self) -> EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Hist: Debug, R: Debug, E: Debug, S: Debug, Res: Debug, T: Debug> Debug for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist: Debug, R: Debug, E: Debug, S: Debug, Res: Debug, T: Debug> Debug for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Source§impl<'de, Hist, R, E, S, Res, T> Deserialize<'de> for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>where
Hist: Deserialize<'de>,
R: Deserialize<'de>,
E: Deserialize<'de>,
S: Deserialize<'de>,
T: Deserialize<'de>,
impl<'de, Hist, R, E, S, Res, T> Deserialize<'de> for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>where
Hist: Deserialize<'de>,
R: Deserialize<'de>,
E: Deserialize<'de>,
S: Deserialize<'de>,
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<Hist, R, E, S, Res, T> Entropic for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> Entropic for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Source§fn step_counter(&self) -> usize
fn step_counter(&self) -> usize
§Number of entropic steps done until now
- will be reset by
self.refine_estimate
Source§fn step_goal(&self) -> usize
fn step_goal(&self) -> usize
§Number of entropic steps to be performed
- if
selfwas created fromWangLandauAdaptive,step_goalwill be equal to the number of WangLandau steps, that were performed
Source§fn total_steps_accepted(&self) -> usize
fn total_steps_accepted(&self) -> usize
How many steps were accepted until now? Read more
Source§fn total_steps_rejected(&self) -> usize
fn total_steps_rejected(&self) -> usize
How many steps were rejected until now? Read more
Source§fn write_log<W: Write>(&self, w: W) -> Result<(), Error>
fn write_log<W: Write>(&self, w: W) -> Result<(), Error>
Writes Information about the simulation to a file.
E.g. How many steps were performed.
Source§fn steps_total(&self) -> usize
fn steps_total(&self) -> usize
Counter Read more
Source§fn fraction_accepted_total(&self) -> f64
fn fraction_accepted_total(&self) -> f64
Calculate, which fraction of steps were accepted Read more
Source§fn fraction_rejected_total(&self) -> f64
fn fraction_rejected_total(&self) -> f64
Calculate, which fraction of steps were rejected Read more
Source§fn is_finished(&self) -> bool
fn is_finished(&self) -> bool
Checks wang landau threshold Read more
Source§impl<Hist, R, E, S, Res, Energy> EntropicEnergy<Energy> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
impl<Hist, R, E, S, Res, Energy> EntropicEnergy<Energy> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
Source§impl<Hist, R, E, S, Res, Energy> EntropicEnsemble<E> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
impl<Hist, R, E, S, Res, Energy> EntropicEnsemble<E> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
Source§impl<Hist, R, E, S, Res, Energy> EntropicHist<Hist> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
impl<Hist, R, E, S, Res, Energy> EntropicHist<Hist> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
Source§impl<Hist, R, E, S, Res, Energy> GlueAble<Hist> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
impl<Hist, R, E, S, Res, Energy> GlueAble<Hist> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>
Source§impl<Hist, R, E, S, Res, Energy> HasRng<R> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>where
R: Rng,
impl<Hist, R, E, S, Res, Energy> HasRng<R> for EntropicSamplingAdaptive<Hist, R, E, S, Res, Energy>where
R: Rng,
Source§impl<Hist, R, E, S, Res, T> Serialize for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> Serialize for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Source§impl<Hist, R, E, S, Res, T> TryFrom<WangLandauAdaptive<Hist, R, E, S, Res, T>> for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> TryFrom<WangLandauAdaptive<Hist, R, E, S, Res, T>> for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
Source§type Error = EntropicErrors
type Error = EntropicErrors
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl<Hist, R, E, S, Res, T> Freeze for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> RefUnwindSafe for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>where
R: RefUnwindSafe,
E: RefUnwindSafe,
Hist: RefUnwindSafe,
T: RefUnwindSafe,
Res: RefUnwindSafe,
S: RefUnwindSafe,
impl<Hist, R, E, S, Res, T> Send for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> Sync for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> Unpin for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>
impl<Hist, R, E, S, Res, T> UnwindSafe for EntropicSamplingAdaptive<Hist, R, E, S, Res, T>where
R: UnwindSafe,
E: UnwindSafe,
Hist: UnwindSafe,
T: UnwindSafe,
Res: UnwindSafe,
S: 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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