lio.individuals
Class Individual

java.lang.Object
  extended by lio.individuals.Individual
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
BitChain, ContChain, Permutation

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

This abstract class contains the common features and methods for each kind of individual.


Field Summary
protected  boolean evaluated
          Determines whether the individual has been evaluated or not.
protected static int maxSize
          Maximum size of the individuals.
protected  int size
          Current size of each individuals.
protected  double value
          Numeric result of the evaluation of the individual.
 
Constructor Summary
Individual()
           
 
Method Summary
 void change()
          Notifies a change in the individual's data.
abstract  java.lang.Object clone()
          Clones an individual.
 int compareTo(java.lang.Object o)
          Compares this Individual with the specified individual for order.
static int getMaxSize()
          Returns the maximum size that can have an individual.
 int getSize()
          Returns the size of the individual.
 boolean isEvaluated()
          Returns true if the individual has been already evaluated.
static void setMaxSize(int pMaxSize)
          Setter for property size.
 void setSize(int size)
          Setter for property size.
 void setValue(double pValue, boolean pEvaluated)
          Sets value without carryng out the evaluation.
abstract  java.lang.String toString()
          Returns a string representation of the individual.
 double value()
          Returns the value corresponding to the evaluation of the individual.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxSize

protected static int maxSize
Maximum size of the individuals. In most cases it corresponds with the size of the problem.


size

protected int size
Current size of each individuals. In most cases, it will be the same as the maxSize;


evaluated

protected boolean evaluated
Determines whether the individual has been evaluated or not.


value

protected double value
Numeric result of the evaluation of the individual.

Constructor Detail

Individual

public Individual()
Method Detail

isEvaluated

public boolean isEvaluated()
Returns true if the individual has been already evaluated.

Returns:
Whether the individual has already been evaluated or not.

value

public double value()
Returns the value corresponding to the evaluation of the individual. If it hasn't already been evaluated, the evaluation is carried out.

Returns:
Fitness of the individual.

change

public void change()
Notifies a change in the individual's data. It sets evaluate to false, since value may not correspond to the new composition.


clone

public abstract java.lang.Object clone()
Clones an individual. It allows to copy individuals instead of references.

Overrides:
clone in class java.lang.Object
Returns:
an object similar to this.

getSize

public int getSize()
Returns the size of the individual.

Returns:
Size of the individual.

getMaxSize

public static int getMaxSize()
Returns the maximum size that can have an individual.

Returns:
Size of the individual.

toString

public abstract java.lang.String toString()
Returns a string representation of the individual.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of the individual.

setSize

public void setSize(int size)
Setter for property size.

Parameters:
size - New value of property size.

setMaxSize

public static void setMaxSize(int pMaxSize)
Setter for property size.

Parameters:
size - New value of property size.

compareTo

public int compareTo(java.lang.Object o)
Compares this Individual with the specified individual for order. Comparison is done by fitness values.

Specified by:
compareTo in interface java.lang.Comparable
Returns:
a negative integer, zero, or a positive integer as this individual is less than, equal to, or greater than the specified individual.

setValue

public void setValue(double pValue,
                     boolean pEvaluated)
Sets value without carryng out the evaluation.

Parameters:
pValue - the evaluation value for this object.