art.ga
Class Chromosome

java.lang.Object
  extended byart.ga.Chromosome
All Implemented Interfaces:
GaSolution
Direct Known Subclasses:
Classifier, Message

public class Chromosome
extends java.lang.Object
implements GaSolution

This class contains methods useful to interact with the chromosome, that is a representation in the genetic algorithm's formalism of a "solution" of the simulated agent. Each individual corresponds to a solution of the agent. Each chromosome is composed by different genomes, the genome represent a "rule". A solution is composed by different rules. This is not a standard Holland's approach to genetic algorithm, the standard approach use a single genome for each chromosome and than the solution coincide with the only one rule).

Author:
Marco Lamieri and Gianluigi Ferraris

Constructor Summary
Chromosome(GaConfiguration configuration, Population population)
          Constructor of the class
 
Method Summary
 int getAge()
          Get how many generation ago the Chromosome is born.
 Genome[] getBody()
          Get the Genomes composing the Chromosome's instance.
 boolean getChild()
          Get if the chromosome has been generated in the last evolution occurred.
 double getFitness()
          Get the Chromosome's fitness.
 Genome getGenome(int position)
          Get a specific Genome of the Chromosome identified by the position in the body's array.
 Population getMyPopulation()
          Get the Population the Chromosome's instance belong to.
 int getNumberOfRules()
           
 double getRescaledFitness()
          Get the fitness rescaled for the roulette wheel selection.
 int[] getRule(int ruleNumber)
           
 boolean getSelectedForDie()
          Get if the Chromosome has been selected for die during the "selection for die" event of the last evolution.
 boolean getSelectedForReproduction()
          Get if the Chromosome has been selected for reproduction during the "selection for reproduction" event of the last evolution.
 void initializeChromosome()
          Initialize the Chromosome with generated genomes.
 boolean isFitnessEvaluated()
          Get if fitness has been evaluated for the Chromosome since the last evolution.
 void print()
          Print to screen some Chromosome's information.
 void print(boolean printGenomeDetails)
          Print to screen some Chromosome's information.
 void setAge(int age)
          Get how many generation ago the Chromosome is born.
 void setBody(Genome[] body)
          Set the Genomes composing the Chromosome's instance.
 void setChild(boolean child)
          Set if the chromosome has been generated in the last evolution occurred.
 void setFitness(double fitness)
          Set the Chromosome's fitness.
 void setFitnessEvaluated(boolean b)
          Set if fitness has been evaluated for the Chromosome since the last evolution.
 void setRescaledFitness(double scaleFactor)
          Compute and set the fitness rescaled for the roulette wheel selection.
 void setRescaledFitnessEvaluated(boolean b)
          Set if the fitness is rescaled.
 void setSelectedForDie(boolean option)
          Set if the Chromosome has been selected for die during the "selection for die" event of the last evolution.
 void setSelectedForReproduction(boolean option)
          Set if the Chromosome has been selected for reproduction during the "selection for reproduction" event of the last evolution.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Chromosome

public Chromosome(GaConfiguration configuration,
                  Population population)
Constructor of the class

Parameters:
configuration - Configuration from which get required parameters
population - Population the Chromosome's instance belonging to.
Method Detail

getAge

public int getAge()
Get how many generation ago the Chromosome is born.

Returns:
Chromosome's age.

getBody

public Genome[] getBody()
Get the Genomes composing the Chromosome's instance. Each Chromosome (solution) is composed by many genomes (rules).

Returns:
Array of Genomes composing chromosome.

getChild

public boolean getChild()
Get if the chromosome has been generated in the last evolution occurred. This is useful to avoid improper crossover.

Returns:
True if the Chromosome is a "child"

getFitness

public double getFitness()
Get the Chromosome's fitness.

Specified by:
getFitness in interface GaSolution
Returns:
Fitness
See Also:
Events.evaluateFitness(Population, Fitness), GaManager.setFitness(GaSolution, double)

getGenome

public Genome getGenome(int position)
Get a specific Genome of the Chromosome identified by the position in the body's array.

Parameters:
position - Position in the body[] array of the requested Genome
Returns:
The requested Genome

getMyPopulation

public Population getMyPopulation()
Get the Population the Chromosome's instance belong to.

Returns:
Belonging Population

getSelectedForDie

public boolean getSelectedForDie()
Get if the Chromosome has been selected for die during the "selection for die" event of the last evolution.

Returns:
If selected for die
See Also:
Events.selectChromosomeForDie(Population)

getSelectedForReproduction

public boolean getSelectedForReproduction()
Get if the Chromosome has been selected for reproduction during the "selection for reproduction" event of the last evolution.

Returns:
If selected for reproduction
See Also:
Events.selectChromosomeForReproduction(Population)

isFitnessEvaluated

public boolean isFitnessEvaluated()
Get if fitness has been evaluated for the Chromosome since the last evolution.

Returns:
If fitness has been evaluated
See Also:
Events.evaluateFitness(Population, Fitness), GaManager.setFitness(GaSolution, double)

print

public void print(boolean printGenomeDetails)
Print to screen some Chromosome's information.

Parameters:
printGenomeDetails - Option if print also information on the Genomes composing the printing Chromosome.

print

public void print()
Print to screen some Chromosome's information.

Specified by:
print in interface GaSolution

setAge

public void setAge(int age)
Get how many generation ago the Chromosome is born.

Parameters:
age - Chromosome's age

setBody

public void setBody(Genome[] body)
Set the Genomes composing the Chromosome's instance. Each Chromosome (solution) is composed by many genomes (rules).

Parameters:
body - Array of Genomes composing chromosome.

setChild

public void setChild(boolean child)
Set if the chromosome has been generated in the last evolution occurred. This is useful to avoid improper crossover.

Parameters:
child - True if the Chromosome is a "child"

setFitness

public void setFitness(double fitness)
Set the Chromosome's fitness.

Specified by:
setFitness in interface GaSolution
Parameters:
fitness - Fitness
See Also:
Events.evaluateFitness(Population, Fitness), GaManager.setFitness(GaSolution, double)

setFitnessEvaluated

public void setFitnessEvaluated(boolean b)
Set if fitness has been evaluated for the Chromosome since the last evolution.

Parameters:
b - If fitness has been evaluated
See Also:
Events.evaluateFitness(Population, Fitness), GaManager.setFitness(GaSolution, double)

initializeChromosome

public void initializeChromosome()
Initialize the Chromosome with generated genomes.


setSelectedForDie

public void setSelectedForDie(boolean option)
Set if the Chromosome has been selected for die during the "selection for die" event of the last evolution.

Parameters:
option - If selected for die
See Also:
Events.selectChromosomeForDie(Population)

setSelectedForReproduction

public void setSelectedForReproduction(boolean option)
Set if the Chromosome has been selected for reproduction during the "selection for reproduction" event of the last evolution.

Parameters:
option - If selected for reproduction
See Also:
Events.selectChromosomeForReproduction(Population)

getRescaledFitness

public double getRescaledFitness()
Get the fitness rescaled for the roulette wheel selection.

Returns:
Rescaled fitness

setRescaledFitnessEvaluated

public void setRescaledFitnessEvaluated(boolean b)
Set if the fitness is rescaled.

Parameters:
b - If fitness rescaled

setRescaledFitness

public void setRescaledFitness(double scaleFactor)
Compute and set the fitness rescaled for the roulette wheel selection.

Parameters:
scaleFactor - Scale factor computed as -(minFitness-(stDev/1000))

getRule

public int[] getRule(int ruleNumber)
Specified by:
getRule in interface GaSolution

getNumberOfRules

public int getNumberOfRules()
Specified by:
getNumberOfRules in interface GaSolution