Individuals
Class GEIndividual

java.lang.Object
  extended by Individuals.AbstractIndividual
      extended by Individuals.GEIndividual
All Implemented Interfaces:
Individual, java.lang.Cloneable, java.lang.Comparable<Individual>

public class GEIndividual
extends AbstractIndividual

GEIndividual. Has a genotype, Phenotype and a GEGrammar. Has fields for validity and mapped status. Only has one chromosome and grammar

Author:
Blip

Field Summary
 
Fields inherited from class Individuals.AbstractIndividual
age, evaluated, fitness, parentUIDs
 
Constructor Summary
GEIndividual()
          Creates a new instance of GEIndividual
GEIndividual(GEGrammar g, Phenotype p, Genotype gen, Fitness f)
          Create new GEindividual instance
 
Method Summary
 Individual clone()
          Clone this individual, invialidate and return the clone
 int[] getCrossoverPoints()
           
 Genotype getGenotype()
          Get the genotype
static GEIndividual getIndividual(GEGrammar grammar, Phenotype phen, Genotype genotype, Fitness fitness)
          Factory method for creating GEIndivdual with different grammars
 Mapper getMapper()
          Get the map use to map input and output
 int[] getMutationPoints()
           
 java.util.ArrayList<Fitness> getParents()
           
 Phenotype getPhenotype()
          Get phenotype
 java.lang.String getPhenotypeString(int map)
          Get a String representation of the output(Phenotype)
 int getPreviouslyUsedCodons()
          Get number of codons used for mapping previoulsy.
 int getUsedCodons()
          Get number of codons used for mapping
 int getUsedWraps()
          Get number of wraps used for mapping
 void invalidate()
          Invalidate the individual.
 boolean isMapped()
          Is the individual mapped
 boolean isValid()
          Get the validity of the individual
 void map(int map)
          Setting these both here so as to negate the need for multiple copies of the Mapper.
 void revalidate(GEIndividual ind)
          Sets the values reset by invalidate to the values from the individual passed in.
 void setCrossoverPoints(int[] crossoverPoints)
           
 void setGenotype(Genotype g)
          Invalidates the individual because a change has been made to the genotype.
 void setMapped(boolean mapped)
          Set the mapped status of the individual
 void setMapper(Mapper m)
          Set mapper
 void setMutationPoints(int[] mutationPoints)
           
 void setParents(java.util.ArrayList<Fitness> parents)
           
 void setPhenotype(Phenotype p)
          Set phenotype
 void setPreviouslyUsedCodons(int previouslyUsedCodons)
           
 void setUsedCodons(int usedCodons)
          Set how many codons were used
 void setUsedWraps(int usedWraps)
          Set how many wraps were used
 void setValid(boolean b)
          Set the validity of the individual
 java.lang.String toString()
           
 boolean wasPreviouslyValid()
          Find out whether individual was *previously* valid.
 
Methods inherited from class Individuals.AbstractIndividual
compareTo, getAge, getFitness, getParentUIDs, getUID, increaseUIDCounter, isEvaluated, setAge, setEvaluated, setFitness, setParentUIDs
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GEIndividual

public GEIndividual()
Creates a new instance of GEIndividual


GEIndividual

public GEIndividual(GEGrammar g,
                    Phenotype p,
                    Genotype gen,
                    Fitness f)
Create new GEindividual instance

Parameters:
g - mapper(grammar)
p - output(phenotype)
gen - input(genotype)
f - fitness
Method Detail

getIndividual

public static GEIndividual getIndividual(GEGrammar grammar,
                                         Phenotype phen,
                                         Genotype genotype,
                                         Fitness fitness)
Factory method for creating GEIndivdual with different grammars

Parameters:
grammar - grammar
phen - phenotype
genotype - genotype
fitness - fitness
Returns:
new GEIndividual

revalidate

public void revalidate(GEIndividual ind)
Sets the values reset by invalidate to the values from the individual passed in.

Parameters:
ind - individual which values are taken from

invalidate

public void invalidate()
Invalidate the individual.


isMapped

public boolean isMapped()
Is the individual mapped

Returns:
mapped

setMapped

public void setMapped(boolean mapped)
Set the mapped status of the individual

Parameters:
mapped - status of the individuals mapping

isValid

public boolean isValid()
Description copied from interface: Individual
Get the validity of the individual

Returns:
validity of the individual

setValid

public void setValid(boolean b)
Description copied from interface: Individual
Set the validity of the individual

Parameters:
b - validity to be set

wasPreviouslyValid

public boolean wasPreviouslyValid()
Find out whether individual was *previously* valid. Used in NGramUpdateOperator, because it needs to know, after selection has invalidated everything, whether individuals are "really" valid.

Returns:
whether it was valid before being invalidated by clone().

setUsedCodons

public void setUsedCodons(int usedCodons)
Set how many codons were used

Parameters:
usedCodons - number of codons used

setUsedWraps

public void setUsedWraps(int usedWraps)
Set how many wraps were used

Parameters:
usedWraps - number of wraps used

map

public void map(int map)
Setting these both here so as to negate the need for multiple copies of the Mapper.

Specified by:
map in interface Individual
Specified by:
map in class AbstractIndividual
Parameters:
map - index to use

getPhenotypeString

public java.lang.String getPhenotypeString(int map)
Description copied from interface: Individual
Get a String representation of the output(Phenotype)

Specified by:
getPhenotypeString in interface Individual
Specified by:
getPhenotypeString in class AbstractIndividual
Parameters:
map - phenotype to chose
Returns:
output string

getGenotype

public Genotype getGenotype()
Description copied from interface: Individual
Get the genotype

Specified by:
getGenotype in interface Individual
Specified by:
getGenotype in class AbstractIndividual
Returns:
genotype

getMapper

public Mapper getMapper()
Description copied from interface: Individual
Get the map use to map input and output

Specified by:
getMapper in interface Individual
Specified by:
getMapper in class AbstractIndividual
Returns:
map used

setMapper

public void setMapper(Mapper m)
Description copied from interface: Individual
Set mapper

Specified by:
setMapper in interface Individual
Specified by:
setMapper in class AbstractIndividual
Parameters:
m - mapper

setGenotype

public void setGenotype(Genotype g)
Invalidates the individual because a change has been made to the genotype. Sets the new genotype in the indivudual as well as in the mapper

Specified by:
setGenotype in interface Individual
Specified by:
setGenotype in class AbstractIndividual
Parameters:
g - genotype

setPhenotype

public void setPhenotype(Phenotype p)
Description copied from interface: Individual
Set phenotype

Specified by:
setPhenotype in interface Individual
Specified by:
setPhenotype in class AbstractIndividual
Parameters:
p - phenotype

getPhenotype

public Phenotype getPhenotype()
Description copied from interface: Individual
Get phenotype

Specified by:
getPhenotype in interface Individual
Specified by:
getPhenotype in class AbstractIndividual
Returns:
phenotype

clone

public Individual clone()
Clone this individual, invialidate and return the clone

Specified by:
clone in interface Individual
Specified by:
clone in class AbstractIndividual
Returns:
Individual cloned and invalidated individual

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getUsedCodons

public int getUsedCodons()
Get number of codons used for mapping

Returns:
codons used for mapping

setPreviouslyUsedCodons

public void setPreviouslyUsedCodons(int previouslyUsedCodons)

getPreviouslyUsedCodons

public int getPreviouslyUsedCodons()
Get number of codons used for mapping previoulsy. Used when the individual gets invalidated but previous information is needed

Returns:
codons used for mapping previously

getUsedWraps

public int getUsedWraps()
Get number of wraps used for mapping

Returns:
wraps used

getCrossoverPoints

public int[] getCrossoverPoints()

getMutationPoints

public int[] getMutationPoints()

getParents

public java.util.ArrayList<Fitness> getParents()

setCrossoverPoints

public void setCrossoverPoints(int[] crossoverPoints)

setMutationPoints

public void setMutationPoints(int[] mutationPoints)

setParents

public void setParents(java.util.ArrayList<Fitness> parents)