|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjenes.population.Individual<T>
T
- The type of chromosome.public final class Individual<T extends Chromosome>
Individual represents a solution processed by a genetic algorithm.
It is made of a Chromosome
representing its genoma, and a score representing its fitness.
To be valid, the score must be non-negative.
A key point is how to compare individuals.
There two ways in comparing individuals: by fitness and chromosome.
The compareTo(Individual)
method tests if scores are equal or which one is bigger
regardless at their genoma.
The equals(Individual)
methods compares the chromosome. In order to gain efficiency in
comparing individuals, the isSameChromosomeSameFitness()
property is used to shortcut
the procedure.
If this property is true, equals
returns true according to the score, thus avoiding to
perform an expensive chromosome comparison.
Indeed, by setting the sameChromosomeSameFitness
property to true, we assume that is not possible
to have two different chromosome with the same score. Appliability fo this property depends on the
problem and search landscape characteristics.
Obviously, we assume that individuals with the same chromosome must show the fitness value.
In complex search spaces, not every solution is feasible. The solution feasability is controlled
by the legal
property.
Population
,
Chromosome
,
Serialized FormConstructor Summary | |
---|---|
Individual(Individual<T> ind)
Constructs a new Individual as a copy of another Individual . |
|
Individual(T chromosome)
Creates an Individual with the specified genome. |
|
Individual(T chromosome,
double score)
Creates an Individual with the specified genome and a given score (fitness value). |
Method Summary | |
---|---|
Individual<T> |
clone()
Returns a cloned instance of this class |
int |
compareTo(Individual<T> ind)
Compares this individual with the specified individual. |
boolean |
equals(Individual<T> ind)
Indicates whether the other individual is "equal to" this one. |
T |
getChromosome()
Returns the Individual 's genome |
int |
getChromosomeLength()
Returns the chromosome's length |
double |
getScore()
Returns the Individual 's fitness value
This score is meaningful only if isEvaluated() returns true. |
boolean |
isEvaluated()
Tests if the Individual is evaluated |
boolean |
isLegal()
Tests if this Individual is a legal individual i.e is a feasible solution. |
static boolean |
isSameChromosomeSameFitness()
Return true if individual with the same chromosome must have also the same fitness (if evaluated), false otherwise |
void |
randomize()
Randomizes the genome (chromosome) of this individual |
void |
setAs(Individual<T> individual)
Sets this Individual 's genome equal
to the specified Individual 's one |
void |
setChromosome(T chromosome)
Sets the Individual 's genome |
void |
setLegal(boolean legal)
Sets the legal state of this individual |
void |
setNotEvaluated()
Sets this individual as not evaluated. |
static void |
setSameChromosomeSameFitness(boolean sameChromosomeSameFitness)
Set to true if individual with the same chromosome must have also the same fitness (if evaluated), false otherwise |
void |
setScore(double score)
Sets the Individual 's fitness value. |
java.lang.String |
toCompleteString()
Returns a full textual representation of this Individual |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Individual(T chromosome)
Individual
with the specified genome.
It results not evaluated.
chromosome
- individual's genomepublic Individual(T chromosome, double score)
Individual
with the specified genome and a given score (fitness value).
chromosome
- individual's genomescore
- individual's scorepublic Individual(Individual<T> ind)
Individual
as a copy of another Individual
.
ind
- the source Individual
.Method Detail |
---|
public final T getChromosome()
Individual
's genome
public final void setChromosome(T chromosome)
Individual
's genome
chromosome
- the Individual
's genomepublic final double getScore()
Individual
's fitness value
This score is meaningful only if isEvaluated()
returns true.
Otherwise the score is equal to Double.NaN
.
Individual
's fitness valuepublic final void setScore(double score)
Individual
's fitness value.
score
- the Individual
's fitness valuepublic final void setNotEvaluated()
public final Individual<T> clone()
clone
in class java.lang.Object
public final void randomize()
public final void setAs(Individual<T> individual)
Individual
's genome equal
to the specified Individual
's one
individual
- the instance to copy aspublic final boolean isEvaluated()
Individual
is evaluated
true
if the Individual
is evaluated; false
otherwisepublic final java.lang.String toCompleteString()
public final java.lang.String toString()
toString
in class java.lang.Object
public final boolean isLegal()
true
if this individual is a legal solution; flase
otherwise.public final void setLegal(boolean legal)
legal
- true
if legal; false
otherwise.public final int compareTo(Individual<T> ind)
compareTo
in interface java.lang.Comparable<Individual<T extends Chromosome>>
ind
- the individual to be compared.public final boolean equals(Individual<T> ind)
ind
- the reference individual with which to compare.
true
if this individual is the same as the ind argument; false
otherwise.public final int getChromosomeLength()
public static final boolean isSameChromosomeSameFitness()
public static final void setSameChromosomeSameFitness(boolean sameChromosomeSameFitness)
sameChromosomeSameFitness
- the sameChromosomeSameFitness value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |