DistributedEvolutionaryAlgorithmsFramework
Class Individual

java.lang.Object
  extended by DistributedEvolutionaryAlgorithmsFramework.Individual
All Implemented Interfaces:
java.lang.Comparable<Individual>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<Individual>

public class Individual
extends java.lang.Object
implements org.apache.hadoop.io.WritableComparable<Individual>

Individual used to populate Population


Constructor Summary
Individual(Population pop, java.io.DataInput in)
           
Individual(Population pop, double[] vals)
           
Individual(Population pop, int d)
           
 
Method Summary
 int compareTo(Individual o)
           
 double getFitness()
           
 double getGene(int i)
           
 double[] getGenotype()
           
 int getIndex()
           
 void randomize()
          Sets genes to random values within restrictions
 void readFields(java.io.DataInput in)
           
 void setFitness(double f)
          Sets Individuals fitness to given value f
 void setGene(int ind, double val)
          Sets one gene to defined value val
 void setIndex(int i)
          Sets population index to value i
 void setPopulation(Population pop)
          Sets population pointer to pop
 void setValue(int i, double value)
          Sets value of one gene
 void setValues(double[] values)
          Sets whole genotype
 java.lang.String toString()
           
 void write(java.io.DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Individual

public Individual(Population pop,
                  int d)
Parameters:
pop - Population in which Individual will be inserted into
d - Number of dimensions

Individual

public Individual(Population pop,
                  double[] vals)
Parameters:
pop - Population in which Individual will be inserted into
vals - Array of values used as genes

Individual

public Individual(Population pop,
                  java.io.DataInput in)
           throws java.io.IOException
Parameters:
pop - Population in which Individual will be inserted into
in - DataInput with file to be read from
Throws:
java.io.IOException
Method Detail

randomize

public void randomize()
Sets genes to random values within restrictions


getGenotype

public double[] getGenotype()
Returns:
genotype array

getGene

public double getGene(int i)
Parameters:
i - index of requested gene
Returns:
gene with given index

setGene

public void setGene(int ind,
                    double val)
Sets one gene to defined value val

Parameters:
ind - Index of gene to set
val - Value to set to the gene

setFitness

public void setFitness(double f)
Sets Individuals fitness to given value f

Parameters:
f - Value to set

getFitness

public double getFitness()
Returns:
fitness of Individual

getIndex

public int getIndex()
Returns:
population index

setIndex

public void setIndex(int i)
Sets population index to value i

Parameters:
i - Index to set

toString

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

setValues

public void setValues(double[] values)
Sets whole genotype

Parameters:
values -

setValue

public void setValue(int i,
                     double value)
Sets value of one gene

Parameters:
i - Index of gene to set
value - Value to set

setPopulation

public void setPopulation(Population pop)
Sets population pointer to pop

Parameters:
pop - Population to set

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

readFields

public void readFields(java.io.DataInput in)
                throws java.io.IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

compareTo

public int compareTo(Individual o)
Specified by:
compareTo in interface java.lang.Comparable<Individual>