art.ga
Class Events

java.lang.Object
  extended byart.ga.Events
Direct Known Subclasses:
CsEvents

public class Events
extends java.lang.Object

This class deal with all the operations performed by the GA, defined evolutionary operations (like selection for reproduction, selection for die, crossover and mutation).

Author:
Marco Lamieri and Gianluigi Ferraris.

Constructor Summary
Events(GaConfiguration configuration, Population pop)
          Constructor of the class.
 
Method Summary
 void crossover(Population pop)
          Execute the crossover on the chromosomes selected for reproduction of a given population.
 void evaluateFitness(Population pop, Fitness fitnessUserClass)
          Evaluate the fitness of all chromosome in a given population; it has to be used in case of a static problem with a fitness function described in a user class.
 void evolve(Population pop)
          Execute all the evolutionary operations to move to the next generation.
 void loadPopulation(java.io.File filename)
          Not implemented.
 void mutate(Population pop)
          Apply random mutations to the give population at the mutation rate written in the configuration file.
 void nextGeneration(Population pop)
          Technical operation required to move from the current generation to the next one.
 void savePopulation(Population pop)
          Not implemented.
 void selectChromosomeForDie(Population pop)
          Select the chromosomes that are going to die using the roulette wheel technique.
 void selectChromosomeForReproduction(Population pop)
          Select the chromosomes used as parents in crossover operation using the roulette wheel technique.
 void setFitnessEvaluated(boolean b)
          Define if the fitness has been evaluated for all the chromosomes of the population in the current generation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Events

public Events(GaConfiguration configuration,
              Population pop)
Constructor of the class. It create a random number generator specific for this object and initialize the parameters.

Parameters:
configuration - Configuration used for the events.
pop - Events are performed on this population.
Method Detail

crossover

public void crossover(Population pop)
Execute the crossover on the chromosomes selected for reproduction of a given population. In genetic algorithms, crossover is implemented by selecting a point in the character string and swapping all characters after that point. This selection point is generated randomly and the operation is applied to two individuals of the newly reproduced population. The result of the crossover genetic operation is two individuals who are possibly fitter than their parents. In any event, these individuals are added to the new generation being created. This genetic operator does not have to use only one crossover point. Instead, many crossover points can be chosen, and the genetic material exchanged at each point. If two crossover points are chosen, then, effectively, the genes between the points are exchanged.

Parameters:
pop - The population on which execute crossover
See Also:
evolve(Population)

evaluateFitness

public void evaluateFitness(Population pop,
                            Fitness fitnessUserClass)
Evaluate the fitness of all chromosome in a given population; it has to be used in case of a static problem with a fitness function described in a user class. It is not necessary for a standard use in AB simulations.

Parameters:
pop - Population on which compute the fitness
fitnessUserClass - User defined class describing the fitness function. This class must implement the Fitness interface
See Also:
Fitness, GaManager.computeBestSolution(Fitness)

evolve

public void evolve(Population pop)
Execute all the evolutionary operations to move to the next generation. The operations are: select chromosome for reproduction and for die, crossover and mutate.

Parameters:
pop - Population to evolve
See Also:
Fitness

loadPopulation

public void loadPopulation(java.io.File filename)
Not implemented.

Parameters:
filename - File from which load population.

mutate

public void mutate(Population pop)
Apply random mutations to the give population at the mutation rate written in the configuration file. This is a slight perturbation in the genetic material which occurs with a low frequency. Random points are chosen in the character string. A random allele is then generated and substituted to the current one at each of the mutation points. This operation is required in order to introduce new piece of information that are not present in the current population and can lead to a better solution.

When an extended alphabet is used (domain > 2 in configuration file) attention is paid to avoid the mutation from a value to the same value.

Parameters:
pop - Population to mutate

nextGeneration

public void nextGeneration(Population pop)
Technical operation required to move from the current generation to the next one.

Parameters:
pop -
See Also:
evolve(Population)

savePopulation

public void savePopulation(Population pop)
Not implemented.

Parameters:
pop - Population to save

selectChromosomeForDie

public void selectChromosomeForDie(Population pop)
Select the chromosomes that are going to die using the roulette wheel technique. In order to implement roulette-wheel selection of individuals, the normal procedure is to add together all fitness, generate a random number in the range of this sum and then add fitness until the random number is exceeded. The bottleneck in such a mechanism lies in the linear search through the list of fitness that must be done to find the selected individual. By this technique the fitter chromosomes have a higher probability to survive.

Parameters:
pop - Apply selection to this Population
See Also:
crossover(Population), evolve(Population), Population.getTotalFitness(), Population.getTotalFitness(), selectChromosomeForDie(Population)

selectChromosomeForReproduction

public void selectChromosomeForReproduction(Population pop)
Select the chromosomes used as parents in crossover operation using the roulette wheel technique. The number of parents is computed starting from turnover rate in configuration file. In order to implement roulette-wheel selection of individuals, the normal procedure is to add together all fitness, generate a random number in the range of this sum and then add fitness until the random number is exceeded. The bottleneck in such a mechanism lies in the linear search through the list of fitness that must be done to find the selected individual. By this technique the fitter chromosomes have a higher probability to be selected for reproduction.

Parameters:
pop - Apply selection to this Population
See Also:
crossover(Population), Population.getTotalFitness(), Population.getTotalFitness()

setFitnessEvaluated

public void setFitnessEvaluated(boolean b)
Define if the fitness has been evaluated for all the chromosomes of the population in the current generation.

Parameters:
b - Boolean defining if fitness is evaluated