Module abc::scaling [] [src]

Manipulates the probabilities of working on different solutions.

A portion of the bees in an artificial bee colony are tasked with observing the dedicated workers, and doing extra work on promising solutions. To enable this, the solutions' fitnesses are gathered as a Vec<f64>. A ScalingFunction is then run on the fitnesses to get weighting factors, and a solution is chosen with likelihood proportionate to its scaled fitness. This is expressed as:

P(i) = scaledi / ∑j = 1 … N scaledj

By default, proportionate scaling is used.

Examples

Several constructors for scaling functions are available in this module. However, users may also implement custom scaling functions. These can, for example, exaggerate differences in fitness:

Box::new(move |fitnesses: Vec<f64>| {
    // Square the fitnesses.
    fitnesses.iter().map(|fitness| fitness.powf(2_f64)).collect::<Vec<_>>()
});

If you have a large number of active solutions, and don't want to replicate the fitnesses vector, you can mutate and return the same vector. Since the actual storage portion of a Vec is is heap-allocated, the scaling function should be reasonably well-behaved with respect to memory.

Functions

power

Chooses more fit solutions exponentially more often.

power_rank

Chooses solutions according to their rank, raised to a certain power.

proportionate

Chooses solutions in direct proportion to their fitness.

rank

Chooses solutions according to their rank.

Type Definitions

ScalingFunction

Transform a set of fitnesses into weights for observers' random choices.