|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectes.udc.gii.common.eaf.algorithm.population.Individual
public class Individual
Field Summary | |
---|---|
private org.apache.commons.math.util.DoubleArray[] |
chromosomes
|
private FitnessComparator<Individual> |
comparator
|
private java.util.List<java.lang.Double> |
constraints
|
private double |
fitness
|
private java.util.List<java.lang.Double> |
objectives
|
private boolean |
serializeEvalResults
|
private boolean |
serializeGenotype
|
private int |
violatedConstraints
|
Constructor Summary | |
---|---|
Individual()
Creates a new instance of Individual |
|
Individual(org.apache.commons.math.util.DoubleArray[] chromosomes)
Creates a new instance of Individual with a DoubleArray of chromosomes. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Clones the current individual. |
void |
configure(org.apache.commons.configuration.Configuration conf)
Configures the current individual. |
void |
copyEvalResults(Individual other)
Copies the evaluation results of this individual to the passed individual. |
void |
copyGenotype(Individual other)
Copies the genotype of this individual to the passed individual. |
boolean |
equals(java.lang.Object obj)
Tests if two individuals are or are not equals. |
void |
generate()
Generates the chromosomes of the Individual with values in [-1.0,1.0] |
double[] |
getChromosomeAt(int index)
Returns the chromosome at index of the individual. |
org.apache.commons.math.util.DoubleArray[] |
getChromosomes()
Returns the chromosomes of the individual. |
FitnessComparator<Individual> |
getComparator()
|
java.util.List<java.lang.Double> |
getConstraints()
Returns the values of the contraint functions evaluate with the chromosomes of this Individual. |
int |
getDimension()
|
double |
getFitness()
Returns the fitness value of the Individual. |
java.util.List<java.lang.Double> |
getObjectives()
Restuns the value of the objective functions evaluate with the chromosomes of this Individual. |
int |
getViolatedConstraints()
Returns the number of violated constraints. |
int |
hashCode()
Resturns the hashCode of an Individual. |
boolean |
isSerializeEvalResults()
Before and while serialization this method returns true if
the evaluation results should be serialized and false
otherwise. |
boolean |
isSerializeGenotype()
Before and while serialization this method returns true if
the genotype information should be serialized and false
otherwise. |
void |
readExternal(java.io.ObjectInput in)
This method is called whenever an instance of this class has to be de-serialized. |
void |
setChromosomeAt(int index,
double[] chromosome)
Sets a double array chromosome to the current individual at position index. |
void |
setChromosomes(org.apache.commons.math.util.DoubleArray[] chromosomes)
Sets an array of chromosomes to the current Individual. |
void |
setComparator(FitnessComparator<Individual> comparator)
|
void |
setConstraints(java.util.List<java.lang.Double> constraints)
Sets the values of the constraint functions evaluate by this individual. |
void |
setDimension(int[] dimensions)
|
void |
setFitness(double fitness)
Sets the fitness value of the Individual. |
void |
setObjectives(java.util.List<java.lang.Double> objectives)
Sets the values of the objectives functions evaluate by this individual. |
void |
setSerializeEvalResults(boolean serializePhenotype)
This method controls the behaviour of the serialization of an instance of this class. |
void |
setSerializeGenotype(boolean serializeGenotype)
This method controls the behaviour of the serialization of an instance of this class. |
void |
setViolatedConstraints(int violatedConstraints)
Sets the number of violated constraints of the Individual. |
java.lang.String |
toString()
Resturns a String representation of the Individual. |
void |
writeExternal(java.io.ObjectOutput out)
This method is called whenever an instance of this class has to be serialized. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private double fitness
private java.util.List<java.lang.Double> objectives
private java.util.List<java.lang.Double> constraints
private int violatedConstraints
private org.apache.commons.math.util.DoubleArray[] chromosomes
private boolean serializeEvalResults
private boolean serializeGenotype
private FitnessComparator<Individual> comparator
Constructor Detail |
---|
public Individual()
public Individual(org.apache.commons.math.util.DoubleArray[] chromosomes)
chromosomes
- DoubleArray of the individual's chromosomes.Method Detail |
---|
public void configure(org.apache.commons.configuration.Configuration conf)
configure
in interface Configurable
conf
- configuration's parameters to configure the current individual.public FitnessComparator<Individual> getComparator()
public void setComparator(FitnessComparator<Individual> comparator)
public double getFitness()
public void setFitness(double fitness)
fitness
- the new fitness value of the Individual.public org.apache.commons.math.util.DoubleArray[] getChromosomes()
public double[] getChromosomeAt(int index)
index
- index of the chromosome to return.
public void setChromosomes(org.apache.commons.math.util.DoubleArray[] chromosomes)
chromosomes
- a new array of chromosomes.public void setChromosomeAt(int index, double[] chromosome)
index
- position to set the new chromosome.chromosome
- a chromosme to be set at position index.public int getViolatedConstraints()
public void setViolatedConstraints(int violatedConstraints)
violatedConstraints
- number of violated constraints.public java.util.List<java.lang.Double> getObjectives()
public void setObjectives(java.util.List<java.lang.Double> objectives)
objectives
- list of values of the objective functions.public java.util.List<java.lang.Double> getConstraints()
public void setConstraints(java.util.List<java.lang.Double> constraints)
constraints
- list of values of the objective functions.public void setSerializeGenotype(boolean serializeGenotype)
true
means that the genotype information
will be serialized (and hence will be transmitted, for example, via sockets).
Setting false
means that the genotype information won't be
serialized.
serializeGenotype
- public void setSerializeEvalResults(boolean serializePhenotype)
true
means that the evaluation results
(objectives, contraint values, ...)
will be serialized (and hence will be transmitted, for example, via sockets).
Setting false
means that this information won't be
serialized.
serializeGenotype
- public boolean isSerializeGenotype()
true
if
the genotype information should be serialized and false
otherwise.
While de-serialization this method returns true
if
the genotype information should be de-serialized. After de-serialization
it returns true
if genotype information has been
de-serialized. It returns false
otherwise.
public boolean isSerializeEvalResults()
true
if
the evaluation results should be serialized and false
otherwise.
While de-serialization this method returns true
if
the evaluation results should be de-serialized. After de-serialization
it returns true
if the evaluation results heve been
de-serialized. It returns false
otherwise.
public void generate()
public int getDimension()
public void setDimension(int[] dimensions)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- another Individual to compare.
public int hashCode()
hashCode
in class java.lang.Object
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
It might write to the output out
the evaluation results
or the genotype information or both, deppending on the value of
Individual#getSerializeEvalResults and Individual#getSerializeGenotype,
which are always writen at the beginning of the output to know later what
type of information is contained in the data.
Subclasses should override this method if they introduce new attibutes.
Remember to call super.writeExternal()
in order to
be sure that the state of the parent class is serialized.
writeExternal
in interface java.io.Externalizable
out
- - DataOutput to write the serialized bytes to.
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
It sets the values of Individual#getSerializeEvalResults and Individual#getSerializeGenotype accordingly to the information received so that subclasses can rely on them to know what kind of information is to be read.
Subclasses should override this method if they introduce new attibutes.
Remember to call super.readExternal()
in order to
be sure that the state of the parent class is de-serialized and the values
of Individual#getSerializeEvalResults and Individual#getSerializeGenotype
contain the right information.
readExternal
in interface java.io.Externalizable
in
- - DataInput from which the bytes are read.
java.io.IOException
java.lang.ClassNotFoundException
public void copyEvalResults(Individual other)
Subclasses of
Individual have to override this method and call
super.copyEvalResults()
in order to handle the copy of the
possible extra attibutes introduced in the subclass.
other
- - The individual into which the phenotype of this object will
be copied.
public void copyGenotype(Individual other)
Subclasses of
Individual have to override this method and call
super.copyGenotype()
in order to handle the copy of the
extra genotype information introduced in the subclass.
other
- - The individual into which the genotype of this object will
be copied.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |