pub trait MarkovChain<S, Res> {
// Required methods
fn undo_step(&mut self, step: &S) -> Res;
fn undo_step_quiet(&mut self, step: &S);
fn m_step(&mut self) -> S;
// Provided methods
fn m_steps(&mut self, count: usize, steps: &mut Vec<S>) { ... }
fn m_steps_quiet(&mut self, count: usize) { ... }
fn m_step_acc<Acc, AccFn>(&mut self, acc: &mut Acc, acc_fn: AccFn) -> S
where AccFn: FnMut(&Self, &S, &mut Acc) { ... }
fn m_steps_acc<Acc, AccFn>(
&mut self,
count: usize,
steps: &mut Vec<S>,
acc: &mut Acc,
acc_fn: AccFn,
)
where AccFn: FnMut(&Self, &S, &mut Acc) { ... }
fn m_steps_acc_quiet<Acc, AccFn>(
&mut self,
count: usize,
acc: &mut Acc,
acc_fn: AccFn,
)
where AccFn: FnMut(&Self, &S, &mut Acc) { ... }
fn undo_steps(&mut self, steps: &[S], res: &mut Vec<Res>) { ... }
fn undo_steps_quiet(&mut self, steps: &[S]) { ... }
fn steps_accepted(&mut self, _steps: &[S]) { ... }
fn steps_rejected(&mut self, _steps: &[S]) { ... }
}
Expand description
§Create a markov chain by doing markov steps
Required Methods§
Sourcefn undo_step(&mut self, step: &S) -> Res
fn undo_step(&mut self, step: &S) -> Res
- undo a markov step, return result-state
- if you want to undo more than one step
see
undo_steps
Sourcefn undo_step_quiet(&mut self, step: &S)
fn undo_step_quiet(&mut self, step: &S)
- undo a markov, panic on invalid result state
- for undoing multiple steps see
undo_steps_quiet
Provided Methods§
Sourcefn m_steps(&mut self, count: usize, steps: &mut Vec<S>)
fn m_steps(&mut self, count: usize, steps: &mut Vec<S>)
§Markov steps
- use this to perform multiple markov steps at once
- steps can be used to undo the steps with
self.undo_steps(steps)
steps
will be emptied before step is performed
Sourcefn m_steps_quiet(&mut self, count: usize)
fn m_steps_quiet(&mut self, count: usize)
§Markov steps without return
- use this to perform multiple markov steps at once
- only use this if you know that you do not want to undo the steps
- you cannot undo this steps, but therefore it does not need to allocate a vector for undoing steps
Sourcefn m_step_acc<Acc, AccFn>(&mut self, acc: &mut Acc, acc_fn: AccFn) -> S
fn m_step_acc<Acc, AccFn>(&mut self, acc: &mut Acc, acc_fn: AccFn) -> S
§Accumulating markov step
- this calculates something while performing the markov chain, e.g., the current energy, which can be more efficient then calculating it from scratch afterwards
Sourcefn m_steps_acc<Acc, AccFn>(
&mut self,
count: usize,
steps: &mut Vec<S>,
acc: &mut Acc,
acc_fn: AccFn,
)
fn m_steps_acc<Acc, AccFn>( &mut self, count: usize, steps: &mut Vec<S>, acc: &mut Acc, acc_fn: AccFn, )
§Accumulating markov steps
- this calculates something while performing the markov chain, e.g., the current energy which can be more efficient then calculating it from scratch afterwards
Sourcefn m_steps_acc_quiet<Acc, AccFn>(
&mut self,
count: usize,
acc: &mut Acc,
acc_fn: AccFn,
)
fn m_steps_acc_quiet<Acc, AccFn>( &mut self, count: usize, acc: &mut Acc, acc_fn: AccFn, )
§Accumulating markov steps
- this calculates something while performing the markov chain, e.g., the current energy which can be more efficient then calculating it from scratch afterwards
- quiet step, i.e., you will not be able to undo the step
Sourcefn undo_steps(&mut self, steps: &[S], res: &mut Vec<Res>)
fn undo_steps(&mut self, steps: &[S], res: &mut Vec<Res>)
Sourcefn undo_steps_quiet(&mut self, steps: &[S])
fn undo_steps_quiet(&mut self, steps: &[S])
Sourcefn steps_accepted(&mut self, _steps: &[S])
fn steps_accepted(&mut self, _steps: &[S])
§Function called whenever the steps are accepted.
*You can use it to create the acceptance statistics if you move a variety of different moves
- If you use the default implementation this will be a optimized out
Sourcefn steps_rejected(&mut self, _steps: &[S])
fn steps_rejected(&mut self, _steps: &[S])
§Function called whenever the steps are rejected.
- You can use it to create the acceptance statistics if you move a variety of different moves
- If you use the default implementation this will be a optimized out
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.