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

Required Methods§

source

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
source

fn undo_step_quiet(&mut self, step: &S)

  • undo a markov, panic on invalid result state
  • for undoing multiple steps see undo_steps_quiet
source

fn m_step(&mut self) -> S

Markov step
  • use this to perform a markov step step
  • for doing multiple markov steps at once, use m_steps

Provided Methods§

source

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
source

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
source

fn m_step_acc<Acc, AccFn>(&mut self, acc: &mut Acc, acc_fn: AccFn) -> S
where AccFn: FnMut(&Self, &S, &mut Acc),

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
source

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),

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
source

fn m_steps_acc_quiet<Acc, AccFn>( &mut self, count: usize, acc: &mut Acc, acc_fn: AccFn )
where AccFn: FnMut(&Self, &S, &mut Acc),

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
source

fn undo_steps(&mut self, steps: &[S], res: &mut Vec<Res>)

Undo markov steps
  • Note: uses undo_step in correct order and returns result
Important:
  • look at specific implementation of undo_step, every thing mentioned there applies to each step
source

fn undo_steps_quiet(&mut self, steps: &[S])

Undo markov steps
  • Note: uses undo_step_quiet in correct order
Important:
  • look at specific implementation of undo_step_quiet, every thing mentioned there applies to each step
source

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
source

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

Object Safety§

This trait is not object safe.

Implementors§