[][src]Trait vrp_core::utils::Random

pub trait Random {
    pub fn get_rng(&self) -> StdRng;

    pub fn uniform_int(&self, min: i32, max: i32) -> i32 { ... }
pub fn uniform_real(&self, min: f64, max: f64) -> f64 { ... }
pub fn is_head_not_tails(&self) -> bool { ... }
pub fn is_hit(&self, probability: f64) -> bool { ... }
pub fn weighted(&self, weights: &[usize]) -> usize { ... } }

Provides the way to use randomized values in generic way.

Required methods

pub fn get_rng(&self) -> StdRng[src]

Returns RNG.

Loading content...

Provided methods

pub fn uniform_int(&self, min: i32, max: i32) -> i32[src]

Produces integral random value, uniformly distributed on the closed interval [min, max]

pub fn uniform_real(&self, min: f64, max: f64) -> f64[src]

Produces real random value, uniformly distributed on the closed interval [min, max)

pub fn is_head_not_tails(&self) -> bool[src]

Flips a coin and returns true if it is "heads", false otherwise.

pub fn is_hit(&self, probability: f64) -> bool[src]

Tests probability value in (0., 1.) range.

pub fn weighted(&self, weights: &[usize]) -> usize[src]

Returns an index from collected with probability weight. Uses exponential distribution where the weights are the rate of the distribution (lambda) and selects the smallest sampled value.

Loading content...

Implementors

impl Random for DefaultRandom[src]

Loading content...