[][src]Trait net_ensembles::traits::Ensemble

pub trait Ensemble<S, Res> {
    fn undo_step(&mut self, step: S) -> Res;
fn undo_step_quiet(&mut self, step: S);
fn randomize(&mut self);
fn mc_step(&mut self) -> S; fn mc_steps(&mut self, count: usize) -> Vec<S> { ... }
fn simple_sample<F>(&mut self, times: usize, f: F)
    where
        F: FnMut(&Self)
, { ... }
fn simple_sample_vec<F, G>(&mut self, times: usize, f: F) -> Vec<G>
    where
        F: FnMut(&Self) -> G
, { ... }
fn undo_steps(&mut self, steps: Vec<S>) -> Vec<Res> { ... }
fn undo_steps_quiet(&mut self, steps: Vec<S>) { ... } }

Sampling an Ensemble

includes:

  • monte carlo steps
  • simple sampling

Required methods

fn undo_step(&mut self, step: S) -> Res

  • undo a monte carlo step, return result-state
  • if you want to undo more than one step see undo_steps

fn undo_step_quiet(&mut self, step: S)

  • undo a monte carlo step, panic on invalid result state
  • for undoing multiple steps see undo_steps_quiet

fn randomize(&mut self)

Randomizes self according to model

fn mc_step(&mut self) -> S

Monte Carlo step

  • use this to perform a Monte Carlo step
  • for doing multiple mc steps at once, use mc_steps
Loading content...

Provided methods

fn mc_steps(&mut self, count: usize) -> Vec<S>

Monte Carlo steps

  • use this to perform multiple Monte Carlo steps at once
  • result Vec<S> can be used to undo the steps with self.undo_steps(result)

fn simple_sample<F>(&mut self, times: usize, f: F) where
    F: FnMut(&Self), 

do the following times times:

  1. f(self)
  2. self.randomize()

fn simple_sample_vec<F, G>(&mut self, times: usize, f: F) -> Vec<G> where
    F: FnMut(&Self) -> G, 

fn undo_steps(&mut self, steps: Vec<S>) -> Vec<Res>

Undo Monte Carlo 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

fn undo_steps_quiet(&mut self, steps: Vec<S>)

Undo Monte Carlo 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
Loading content...

Implementors

impl<T, R> Ensemble<ErStepC, ErStepC> for ErEnsembleC<T, R> where
    T: Node,
    R: Rng
[src]

fn randomize(&mut self)[src]

Randomizes the edges according to Er probabilities

  • this is used by ErEnsembleC::new to create the initial topology
  • you can use this for sampling the ensemble
  • runs in O(vertices * vertices)

fn mc_step(&mut self) -> ErStepC[src]

Monte Carlo step

  • use this to perform a Monte Carlo step
  • result ErStepC can be used to undo the step with self.undo_step(result)

fn undo_step(&mut self, step: ErStepC) -> ErStepC[src]

Undo a Monte Carlo step

  • adds removed edge, or removes added edge, or does nothing
  • if it returns an Err value, you probably used the function wrong

Important:

Restored graph is the same as before the random step except the order of nodes in the adjacency list might be shuffled!

fn undo_step_quiet(&mut self, step: ErStepC)[src]

Undo a Monte Carlo step

  • adds removed edge, or removes added edge, or does nothing
  • if it returns an Err value, you probably used the function wrong

Important:

Restored graph is the same as before the random step except the order of nodes in the adjacency list might be shuffled!

impl<T, R> Ensemble<ErStepM, ErStepM> for ErEnsembleM<T, R> where
    T: Node,
    R: Rng
[src]

fn undo_step(&mut self, step: ErStepM) -> ErStepM[src]

  • undo a monte carlo step, return result-state
  • if you want to undo more than one step see undo_steps

fn undo_step_quiet(&mut self, step: ErStepM)[src]

  • undo a monte carlo step, panic on invalid result state
  • for undoing multiple steps see undo_steps_quiet

fn randomize(&mut self)[src]

Randomizes self according to model

fn mc_step(&mut self) -> ErStepM[src]

Monte Carlo step

  • use this to perform a Monte Carlo step
  • for doing multiple mc steps at once, use mc_steps
Loading content...