jaga.evolve
Class EvolveLib

java.lang.Object
  |
  +--jaga.evolve.EvolveLib

public abstract class EvolveLib
extends java.lang.Object

This Library contains useful functions used within the evolve package.


Constructor Summary
EvolveLib()
           
 
Method Summary
static int pickPosition(double[] cumProb)
          Chooses a position from an array according to the cumulative probabilities stored in that array.
static BitSet randomize(BitSet blob)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvolveLib

public EvolveLib()
Method Detail

pickPosition

public static int pickPosition(double[] cumProb)
Chooses a position from an array according to the cumulative probabilities stored in that array. cumProb[ 0 ] must be equal to 0 and cumProb[ 1 ] will be equal to the first cumulative frequency (fitness or rank value) of the first individual.

Note cumProb.length = pop.size() + 1. The index returned by this procedure is in the range [ 0, cumProb.length - 2 ] since there is an extra element.

A random number r is generated and this method searches the array for the position p such that cumProb[ p ] < r < cumProb[ p + 1 ]. Binary chop algorithm is used to guarantee O(log(n)) time of search. WARNING: does not work with negative probabilities!


randomize

public static BitSet randomize(BitSet blob)