|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbodhidharma.classifiers.genetic_algorithms.Breeder
public class Breeder
Objects of this class control the evolution of Chromosome
objects based on their fitness
as judged by an Evaluator
object and on the parameters specified when objects of this
class are instantiated.
The evovle
method of this class can be called to carry out one epoch of evolution at a
time. Chromosomes may be divided into villages that evolve independantly, but exchange a given portion
of their population after a number of epochs. The population of each village stays constant in each generation.
Elitism is also possible, whereby the best performing members of the population are cloned, and therefore
passed on to the next generation unaltered. Crossover occurs at random locations in the parents.
A modified wheel of fortune algortihm is used to select parents that will engage in crossover during reproduction. This parent selection algorithm works as follows:
1) The number of parents per village is found by multiplying the number of chromosomes in a village by
the mating rate.
2) Parents are selected in each village until the number of parents is equal to the number determined
in step one. Each chromosome has a probability of being selected based on its fitness relative to the
fitness of other chromosomes in its village. Each parent may only be selected once at this stage (although
a single parent may reproduce polygamously multiple times in step 3).
3) All chromosomes that were not selected as parents in step 2 are replaced by offspring from the chromosomes
selected as parents in the same village in step 2. Which parents pair up for crossover is randomly determined.
4) Chromosomes selected in step two are randomly paired up in each village. Their offspring replace them.
The advantage of this approach over the traditional wheel of fortune is that it allows the degree of genetic diversity to be controlled with the mating rate parameter. A low mating rate causes only a few parents to produce all of the offspring of the next generation, whereas a high mating rate causes the offspring to be descendants of many parents. The first case may increase performance, but specialisation may be a problem, since genetic diversity will be limited. The second case helps guard against specialisation, but weakly performing chromosomes are much more likely to breed, thus perpetuating poor genetic material. Allowing the user to control the mating rate parameter gives better insights into how the evolution works and allows for interesting experimentation.
After the crossover phase is complete, mutation may occur, based on the probability of mutation parameter. The probability is the likelihood that a bit will flip in the DNA of each chromosome. This is a good way of introducing new genetic variations.
After this phase, a clone of the best performing chromosome of the parent generation in each village will replace a randomly selected member of each village if the elitism option is selected. This ensures the perpetuation of the best genes so far.
The use of villages allows separate pools of chromosomes to develop independantly. Some chromosomes will periodically exchange with other villages to introduce any positive developments that they have evolved. Which villages exchange is randomly determined each time that an exchange occurs.
Breeder
objects to not contain any assumptions about the meaning of bit strings.
The evolve
method of this class can be called to carry out one epoch of evolution.
Evaluator
,
Breeder
Constructor Summary | |
---|---|
Breeder(Evaluator eval,
int pop_size,
double mut_prob,
double mate_rate,
boolean elite_allowed,
int num_villages,
int mig_delay,
int mig_size)
Instantiates a new Breeder object to control the evolutions of Chromosomes . |
Method Summary | |
---|---|
java.lang.Object[] |
evolve()
Carry out one epoch of evolution and return an array of objects containing the following sets of information for the previous generation: |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Breeder(Evaluator eval, int pop_size, double mut_prob, double mate_rate, boolean elite_allowed, int num_villages, int mig_delay, int mig_size) throws java.lang.Exception
Breeder
object to control the evolutions of Chromosomes
.
IMPORTANT:The population size must be a multiple of the number of villages. There must be more than one elligible parent per village. Migration size must be smaller than village size.
An exception is thrown if there is a problem instantiating Chromosomes.
eval
- An Evaluator
object that evaluates the fitness of individual Chromosomes
pop_size
- Total number of chromosomes in the population.mut_prob
- Probability per bit of mutation in an offspring Chromosome
.mate_rate
- Fraction of population allowed to reproduce (between 0 to 1).elite_allowed
- Whether or not the best chromosome per village is cloned exactly during evolution.num_villages
- Number of vilages that segregate chromosomes.mig_delay
- Number of epochs between migrations between villages.mig_size
- Number of chromosomes exchanged between villages when exchange occurs.
java.lang.Exception
Method Detail |
---|
public java.lang.Object[] evolve() throws java.lang.Exception
- array of doubles representing the average fitness of each village
- array of doubles representing the average fitness of the members selected
to reproduce for each village
- the fitness of the best chromosome in the entire population
- the bit string making up the DNA of the best chromosome in the entire population
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |