art.ga
Class GaConfiguration

java.lang.Object
  extended byart.ga.GaConfiguration
Direct Known Subclasses:
CsConfiguration

public class GaConfiguration
extends java.lang.Object

This class manage all the parameters of the GA reading them from an XML file. Basically all the parameters are read from an XML file and stored in memory. All the other classes know which is their Configuration instance and ask to their instance for the required information via get methods. In this way is possible to create instance of other classes (like for example create two different Populations) that use two different Configuration, and than different parameters. This can be very useful in AB model

Author:
Marco Lamieri and Gianluigi Ferraris

Constructor Summary
GaConfiguration()
          The constructor of the class.
 
Method Summary
 int getChromosomeLength()
          Get the number of genomes contained in each chromosome.
 int getChromosomeToReturn()
          If the most diffused or the fittest chromosome must be returned to the user.
 int getCrossOverPointNumber(int family)
          Get the number of crossover point of each genome of a given genome's family.
 double getCrossOverRate(int family)
          Get the probability of cross over of each genome.
 int getDomain(int family)
          Get the domain or the alphabet of a given genome.
 java.lang.String getGenomeLabel(int i)
          Return the genome label deined in the configuration file.
 int getGenomeLength(int family)
          Get the number of genes for this genome.
 int getGenomeType(int family)
          Get if the genome must be random (each gene can have any value) or univocal (each gene must be unique within the genome).
 int getLogStatistics()
          This option enable or disable logging of some statistics on the evolution process.
 double getMutationRate(int family)
          Get the mutation rate.
 int getPopulationSize()
          Get the size of population, that means the number of chromosomes managed by the ga.
 java.lang.String getProjectDesc()
          Desription of the project defined in the configuration file.
 java.lang.String getProjectName()
          Name of the project in the configuration file.
 java.lang.String getProjectType()
          Type of the project ("ga" or "cs").
 MyRandomMaker getRandomMaker()
          Get a random number generator.
 int getStoppingMethod()
          Stopping method (at convergence, at generation or never).
 double getStoppingValue()
          Value to stop at, depend on stopping method.
 double getTurnoverRate()
          Get the part of the population that is going to become parents in order to produce the next generation.
 int getVerboseness()
          Get the desired level of verbosity during the run.
 void initGenomeArrays(int i)
          Initialize the array of genomes after the genomes length are defined.
 boolean isFittestNeverDie()
          Option to let the fittest Chromosome never die during evolutions.
 boolean isMutateAdults()
          If also the adults or only the baby (age==0) are subject to mutation.
 boolean isNormalizeFitness()
          Get if the fitness rescaled and normalized has been computed.
 boolean isPlotGraph()
          If graph must be plotted.
 void readParametersFromFile(java.lang.String fileName, java.lang.String projectName, java.lang.String projectType)
          Read the values from the given XML file and set the referring parameters in the configuration.
 void setChromosomeLength(double length)
          Set the number of genomes contained in each chromosome.
 void setChromosomeToReturn(double chromosomeToReturn)
          If must be returned to the user the most diffused or the fittest chromosome.
 void setCrossOverPointNumber(int family, double val)
          Set the number of crossover point of each genome of a given genome's family.
 void setCrossOverRate(int family, double val)
          Set the probability of cross over of each genome.
 void setDomain(int family, double val)
          Set the domain or the alphabet of a given genome.
 void setFittestNeverDie(double i)
          Option to let the fittest Chromosome never die during evolutions.
 void setGenomeLabel(int family, java.lang.String label)
          Label of each genome defined in the configuration file.
 void setGenomeLength(int family, double val)
          Get the number of genes for this genome.
 void setGenomeType(int family, double val)
          Set if the genome must be random (each gene can have any value) or univocal (each gene must be unique within the genome).
 void setLogStatistics(double i)
          This option enable or disable logging of some statistics on the evolution process.
 void setMutateAdults(double i)
          If also the adults or only the baby (age==0) are subject to mutation.
 void setMutationRate(int family, double val)
          Set the mutation rate.
 void setNormalizeFitness(double i)
          Set the fitness rescaled and normalized in order to manage negative fitness value and improve performance.
 void setPlotGraph(double i)
          If plot the graphs.
 void setPopulationSize(double i)
          Set the size of population, that means the number of chromosomes managed by the ga.
 void setProjectDesc(java.lang.String projectDesc)
          Set project description.
 void setProjectName(java.lang.String projectName)
          Set project name.
 void setProjectType(java.lang.String pt)
          Set project type.
 void setRandomSeed(double rs)
          Set a random number generator for this configuration.
 void setStoppingMethod(double stoppingMethod)
          Set the stopping method.
 void setStoppingValue(double stoppingValue)
          Set the stopping value.
 void setTurnoverRate(double l)
          Set the part of the population that is going to become parents in order to produce the next generation.
 void setVerboseness(double logType)
          Set the desired level of verbosity during the run.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GaConfiguration

public GaConfiguration()
The constructor of the class. Create the directory "./log" where log files will be placed.

Method Detail

getChromosomeLength

public int getChromosomeLength()
Get the number of genomes contained in each chromosome. It represents the number of rules that define a solution.

Returns:
Number of genomes contained in each chromosome

getChromosomeToReturn

public int getChromosomeToReturn()
If the most diffused or the fittest chromosome must be returned to the user.

Returns:
Returns the chromosomeToReturn.

getCrossOverPointNumber

public int getCrossOverPointNumber(int family)
Get the number of crossover point of each genome of a given genome's family. The crossover point is where the genome is trimmed in order to switch the genetic information from the two parents and define the new children during the crossover operation. The genome's family is the number of different genomes present in each chromosome.

Parameters:
family - The genome on which consider the parameters.
Returns:
The number of crossover points in each genome subject to crossover operation. The normal value is 1.
See Also:
Events.crossover(Population)

getCrossOverRate

public double getCrossOverRate(int family)
Get the probability of cross over of each genome.

Parameters:
family - The genome on which consider the parameters.
Returns:
The cross over rate. This rate identify the probability of cross over of each chromosome of the population.

getDomain

public int getDomain(int family)
Get the domain or the alphabet of a given genome. The domain is the number of states in which a gene can be. The valid values start from 0 to domain-1. It is something like the alphabet used by the genes. Usually a standard ga has a binary alphabet, than the domain will be 2 (that mens 2 possible modes: 0 and 1).

Parameters:
family - The genome on which consider the parameters.
Returns:
The domain or alphabet of this genome.

getGenomeLabel

public java.lang.String getGenomeLabel(int i)
Return the genome label deined in the configuration file.

Returns:
Returns the genomeLabel.

getGenomeLength

public int getGenomeLength(int family)
Get the number of genes for this genome.

Parameters:
family - The genome on which consider the parameters.
Returns:
Number of gene.
See Also:
Genome

getGenomeType

public int getGenomeType(int family)
Get if the genome must be random (each gene can have any value) or univocal (each gene must be unique within the genome).

Parameters:
family - The genome on which consider the parameters.
Returns:
Random (0) or univocal (1)
See Also:
Genome

getLogStatistics

public int getLogStatistics()
This option enable or disable logging of some statistics on the evolution process. The statistics are written in file: "./log/populationStatistics.txt" and "./log/chromosomeStatistics.txt". The allowed values are:

See Also:
Log.logStats(Population)

getMutationRate

public double getMutationRate(int family)
Get the mutation rate. This rate identify the probability of random mutation applied to each gene.

Parameters:
family - The genome on which consider the parameters.
Returns:
Mutattion rate.

getPopulationSize

public int getPopulationSize()
Get the size of population, that means the number of chromosomes managed by the ga.

Returns:
Population size.
See Also:
Population

getProjectDesc

public java.lang.String getProjectDesc()
Desription of the project defined in the configuration file.

Returns:
Returns the projectDesc.

getProjectName

public java.lang.String getProjectName()
Name of the project in the configuration file.

Returns:
Returns the projectName.

getProjectType

public java.lang.String getProjectType()
Type of the project ("ga" or "cs").

Returns:
Returns the projectType.

getRandomMaker

public MyRandomMaker getRandomMaker()
Get a random number generator.

Returns:
Random number generator
See Also:
MyRandomMaker

getStoppingMethod

public int getStoppingMethod()
Stopping method (at convergence, at generation or never).

Returns:
Returns the stoppingMethod.

getStoppingValue

public double getStoppingValue()
Value to stop at, depend on stopping method.

Returns:
Returns the stoppingValue.

getTurnoverRate

public double getTurnoverRate()
Get the part of the population that is going to become parents in order to produce the next generation.

Returns:
Turn over rate

getVerboseness

public int getVerboseness()
Get the desired level of verbosity during the run. The options allowed are:

Returns:
Verboseness

isFittestNeverDie

public boolean isFittestNeverDie()
Option to let the fittest Chromosome never die during evolutions. In same case this option can improve the performance of the ga.

Returns:
Returns the fittestNeverDie.

isMutateAdults

public boolean isMutateAdults()
If also the adults or only the baby (age==0) are subject to mutation.

Returns:
Returns the adultMutation option.

isNormalizeFitness

public boolean isNormalizeFitness()
Get if the fitness rescaled and normalized has been computed.

Returns:
If normalized fitness is computed at current generation.

isPlotGraph

public boolean isPlotGraph()
If graph must be plotted.

Returns:
Returns the plotGraph.

readParametersFromFile

public void readParametersFromFile(java.lang.String fileName,
                                   java.lang.String projectName,
                                   java.lang.String projectType)
Read the values from the given XML file and set the referring parameters in the configuration. The file can be created with a normal text editor.

Parameters:
fileName - XML file name with extension as relative path (for istance "./config/jGolem.xml")
projectName - Project of the XML file fileName from wich read parameters.
projectType - Type of project ("ga" for genetic algoritm and "cs" for classifier system)

setChromosomeLength

public void setChromosomeLength(double length)
Set the number of genomes contained in each chromosome. It represents the number of rules that define a Solution.

Parameters:
length - Number of genomes contained in each chromosome

setChromosomeToReturn

public void setChromosomeToReturn(double chromosomeToReturn)
If must be returned to the user the most diffused or the fittest chromosome.

Parameters:
chromosomeToReturn - The chromosomeToReturn to set.

setCrossOverPointNumber

public void setCrossOverPointNumber(int family,
                                    double val)
Set the number of crossover point of each genome of a given genome's family. The crossover point is where the genome is trimmed in order to switch the genetic information from the two parents and define the new children during the crossover operation. The genome's family is the number of different genomes present in each chromosome.

Parameters:
family - The genome on which consider the parameters.
Returns:
The number of crossover points in each genome subject to crossover operation. The normal value is 1.

setCrossOverRate

public void setCrossOverRate(int family,
                             double val)
Set the probability of cross over of each genome.

Parameters:
family - The genome on which consider the parameters.
val - The cross over rate to set for this genome. This rate identify the probability of cross over of each chromosome of the population.

setDomain

public void setDomain(int family,
                      double val)
Set the domain or the alphabet of a given genome. The domain is the number of states in which a gene can be. The valid values start from 0 to domain-1. It is something like the alphabet used by the genes. Usually a standard ga has a binary alphabet, than the domain will be 2 (that means 2 possible modes: 0 and 1).

Parameters:
family - The genome on which consider the parameters.
val - The domain or alphabet to set for this genome.

setFittestNeverDie

public void setFittestNeverDie(double i)
Option to let the fittest Chromosome never die during evolutions. In same case this option can improve the performance of the ga.

Parameters:
i - The fittestNeverDie to set.

setGenomeLabel

public void setGenomeLabel(int family,
                           java.lang.String label)
Label of each genome defined in the configuration file.

Parameters:
label - The genomeLabel to set.

setGenomeLength

public void setGenomeLength(int family,
                            double val)
Get the number of genes for this genome.

Parameters:
family - The genome on which consider the parameters.
val - Number of gene to set for this genome.
See Also:
Genome

setGenomeType

public void setGenomeType(int family,
                          double val)
Set if the genome must be random (each gene can have any value) or univocal (each gene must be unique within the genome).

Parameters:
family - The genome on which consider the parameters.
val - Random (0) or univocal (1)
See Also:
Genome

setLogStatistics

public void setLogStatistics(double i)
This option enable or disable logging of some statistics on the evolution process. The statistics are written in file: "./log/populationStatistics.txt" and "./log/chromosomeStatistics.txt". The allowed values are:

Parameters:
i - Statistics logging option
See Also:
Log.logStats(Population)

setMutateAdults

public void setMutateAdults(double i)
If also the adults or only the baby (age==0) are subject to mutation.

Parameters:
i - The adultMutation to set.

setMutationRate

public void setMutationRate(int family,
                            double val)
Set the mutation rate. This rate identify the probability of random mutation applied to each gene.

Parameters:
family - The genome on which consider the parameters.
val - Mutattion rate to set for the genome.

setNormalizeFitness

public void setNormalizeFitness(double i)
Set the fitness rescaled and normalized in order to manage negative fitness value and improve performance.

Parameters:
i - Normalized fitness.

setPlotGraph

public void setPlotGraph(double i)
If plot the graphs.

Parameters:
i - The plotGraph to set.

setPopulationSize

public void setPopulationSize(double i)
Set the size of population, that means the number of chromosomes managed by the ga.

Parameters:
i - Population size.
See Also:
Population

setProjectDesc

public void setProjectDesc(java.lang.String projectDesc)
Set project description.

Parameters:
projectDesc - The projectDesc to set.

setProjectName

public void setProjectName(java.lang.String projectName)
Set project name.

Parameters:
projectName - The projectName to set.

setProjectType

public void setProjectType(java.lang.String pt)
Set project type.

Parameters:
pt - The projectType to set.

setRandomSeed

public void setRandomSeed(double rs)
Set a random number generator for this configuration.

Parameters:
rs - Random seed
See Also:
MyRandomMaker

setStoppingMethod

public void setStoppingMethod(double stoppingMethod)
Set the stopping method.

Parameters:
stoppingMethod - The stoppingMethod to set.

setStoppingValue

public void setStoppingValue(double stoppingValue)
Set the stopping value.

Parameters:
stoppingValue - The stoppingValue to set.

setTurnoverRate

public void setTurnoverRate(double l)
Set the part of the population that is going to become parents in order to produce the next generation.

Parameters:
l - Turn over rate

setVerboseness

public void setVerboseness(double logType)
Set the desired level of verbosity during the run. The options allowed are:

Parameters:
logType - Verboseness

initGenomeArrays

public void initGenomeArrays(int i)
Initialize the array of genomes after the genomes length are defined.

Parameters:
i -