eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class Individual

java.lang.Object
  |
  +--mss.ea.core.Individual
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

public class Individual
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

Base class for an individual.

Since:
0.1
Version:
$Revision: 1.17 $ $Date: 2001/12/18 10:02:29 $
Author:
Andreas Rummler
See Also:
Serialized Form

Field Summary
protected  long birthDate
          Birthdate in milliseconds.
protected  ChromosomeSet cs
          Chromosome set, representing the genetic information.
protected  Fitness fs
          Fitness of individual.
protected  long id
          ID of the individual.
protected  java.lang.String name
          Name of the individual.
protected static java.lang.String namePrefix
          Prefix of the name of the individual.
protected static java.lang.String nameSuffix
          Suffix of the name of the individual.
protected  AbstractPopulation pop
          Deprecated. because of stream based concept this is not supported any longer
protected  Score sc
          Score of individual.
 
Constructor Summary
Individual()
          Constructor.
Individual(ChromosomeSet set)
          Constructor with initial chromosome set.
Individual(int chromosomeCount)
          Constructor with chromosome number.
Individual(java.lang.String name)
          Constructor with name.
Individual(java.lang.String name, ChromosomeSet set)
          Constructor with name and chromosome set.
Individual(java.lang.String name, int chromosomeCount)
          Constructor with name and number of chromosomes.
 
Method Summary
 java.lang.Object clone()
          Clones an individual.
 int compareTo(java.lang.Object o)
          Compares two individuals.
 boolean equalSet(Individual i)
          Deprecated. replaced by hasEqualSet( Individual )
 long getAge()
          Gets the age of the individual.
 ChromosomeSet getChromosomeSet()
          Gets the chromosome set.
 Fitness getFitness()
          Get the fitness of the individual.
 long getID()
          Gets the ID of the individual.
 java.lang.String getInfo()
          Returns information (name, age, score and fitness) about this individual as a string.
 java.lang.String getName()
          Returns the name (ID) of the individual.
 AbstractPopulation getPopulation()
          Deprecated. because of stream based concept this is not supported any longer
 Score getScore()
          Gets the score of the individual.
 boolean hasEqualSet(Individual i)
          Test for equal chromosome sets.
 boolean hasFitness()
          Checks if a fitness value has been set.
 boolean hasScore()
          Checks if a score has been set.
 void save()
          Saves the individual.
 void save(java.lang.String filename)
          Saves the individual to a given file.
 void setChromosomeSet(ChromosomeSet set)
          Sets a new chromosome set.
 void setFitness(Fitness f)
          Sets the fitness.
static void setIDPrefix(java.lang.String prefix)
          Sets the prefix of the ID.
static void setIDSuffix(java.lang.String suffix)
          Sets the suffix of the ID.
 void setName(java.lang.String name)
          Sets the name (ID) of the individual.
 void setPopulation(AbstractPopulation p)
          Deprecated. because of stream based concept this is not supported any longer
 void setScore(Score s)
          Sets the score of the individual.
 java.lang.String toString()
          Returns the chromosome representation of this individual as a string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pop

protected AbstractPopulation pop
Deprecated. because of stream based concept this is not supported any longer

Population this individual belongs to.

fs

protected Fitness fs
Fitness of individual.

sc

protected Score sc
Score of individual.

cs

protected ChromosomeSet cs
Chromosome set, representing the genetic information.

namePrefix

protected static java.lang.String namePrefix
Prefix of the name of the individual. The default is "ind_".

nameSuffix

protected static java.lang.String nameSuffix
Suffix of the name of the individual. The default is an empty string.

name

protected java.lang.String name
Name of the individual.

id

protected long id
ID of the individual.

birthDate

protected long birthDate
Birthdate in milliseconds.
Constructor Detail

Individual

public Individual()
Constructor. Creates an individual with zero chromosomes and sets the name to an unique ID.

Individual

public Individual(java.lang.String name)
Constructor with name. This creates an individual with zero chromosomes and a specific name.
Parameters:
name - name of individual

Individual

public Individual(int chromosomeCount)
Constructor with chromosome number. This creates an individual with an unique name and the given a specific number of chromosomes initialially set to hold a NullChromosome.
Parameters:
chromosomeCount - number of chromosomes

Individual

public Individual(java.lang.String name,
                  int chromosomeCount)
Constructor with name and number of chromosomes. This creates an indiviudal with the given name and the given number of chromosomes and initializes the chromosomes to hold NullChromosomes.
Parameters:
name - name of the individual
chromosomeCount - number of chromosomes

Individual

public Individual(ChromosomeSet set)
Constructor with initial chromosome set.
Parameters:
set - chromosome set

Individual

public Individual(java.lang.String name,
                  ChromosomeSet set)
Constructor with name and chromosome set.
Parameters:
name - name
set - initial chromosome set
Method Detail

getFitness

public Fitness getFitness()
Get the fitness of the individual.
Returns:
current fitness

setFitness

public void setFitness(Fitness f)
Sets the fitness.
Parameters:
f - new fitness

hasFitness

public boolean hasFitness()
Checks if a fitness value has been set.
Returns:
true if this individual has a fitness, false otherwise

getScore

public Score getScore()
Gets the score of the individual.
Returns:
current score

setScore

public void setScore(Score s)
Sets the score of the individual.
Parameters:
s - new score

hasScore

public boolean hasScore()
Checks if a score has been set.
Returns:
true if this individual has a score, false otherwise

getChromosomeSet

public ChromosomeSet getChromosomeSet()
Gets the chromosome set.
Returns:
chromosome set of the individual

setChromosomeSet

public void setChromosomeSet(ChromosomeSet set)
Sets a new chromosome set.
Parameters:
set - new chromosome set

getPopulation

public AbstractPopulation getPopulation()
Deprecated. because of stream based concept this is not supported any longer

Gets the population this individual belongs to.
Returns:
population this individual belongs to

setPopulation

public void setPopulation(AbstractPopulation p)
Deprecated. because of stream based concept this is not supported any longer

Sets the population this individual belongs to.
Parameters:
p - new population

compareTo

public int compareTo(java.lang.Object o)
Compares two individuals. The method is necessary to implement the interface Comparable. First the method does a cast from Object to Individual. Then checks are done, if both individuals have a score. If none has score 0 is returned. If only one individual has a score 1 or -1 is returned, indicating that the individual with the score set is better (smaller, natural order comparison). If both individuals contain a score, the scores are compared by calling the compareTo() method of this individuals score. The behaviour of the comparison is unsafe, so in every case an appropriate IndividualComparator should be used.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - individual to compare with
Returns:
result of the comparison
Throws:
ClassCastException - in case that o is not an individual

setIDPrefix

public static void setIDPrefix(java.lang.String prefix)
Sets the prefix of the ID.
Parameters:
prefix - prefix of ID

setIDSuffix

public static void setIDSuffix(java.lang.String suffix)
Sets the suffix of the ID.
Parameters:
suffix - suffix of ID

getName

public java.lang.String getName()
Returns the name (ID) of the individual.
Returns:
name of individual

setName

public void setName(java.lang.String name)
Sets the name (ID) of the individual.
Parameters:
name - new name

getAge

public long getAge()
Gets the age of the individual.
Returns:
age in milliseconds

getID

public long getID()
Gets the ID of the individual.
Returns:
ID of the individual

clone

public java.lang.Object clone()
Clones an individual. This method returns a complete copy of an individual. The cloned individual contains a copy the chromosome set, but does not have the same name and age.
Overrides:
clone in class java.lang.Object
Returns:
copy of the current object

getInfo

public java.lang.String getInfo()
Returns information (name, age, score and fitness) about this individual as a string.
Returns:
info string

toString

public java.lang.String toString()
Returns the chromosome representation of this individual as a string.
Overrides:
toString in class java.lang.Object
Returns:
string representation

equalSet

public boolean equalSet(Individual i)
Deprecated. replaced by hasEqualSet( Individual )

Test for equal chromosome sets. This method compares two individuals chromosome sets and returns true, if the sets contain the same genetic information. i individual to compare chromosome set to
Returns:
result of equality test

hasEqualSet

public boolean hasEqualSet(Individual i)
Test for equal chromosome sets. This method compares two individuals chromosome sets and returns true, if the sets contain the same genetic information. i individual to compare chromosome set to
Returns:
result of equality test

save

public void save()
Saves the individual. The individual is written to a file called .ifo. The file suffix stands for Individual File Object.

save

public void save(java.lang.String filename)
Saves the individual to a given file.
Parameters:
filename - name of the file

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS