Package org.opt4j.core
Class Individual
- java.lang.Object
-
- org.opt4j.core.Individual
-
- Direct Known Subclasses:
Particle
public class Individual extends Object
The
Individual
class forms a single solution for the given optimization problem.An
Individual
contains theGenotype
,Phenotype
, andObjectives
: Initially, theIndividual
contains only aGenotype
. TheDecoder
decodes theGenotype
into aPhenotype
and adds it to theIndividual
. Finally, thePhenotype
is evaluated and the resultingObjectives
are added to theIndividual
.- See Also:
Genotype
,Phenotype
,Objectives
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Individual.State
The possible states of anIndividual
.
-
Field Summary
Fields Modifier and Type Field Description protected Genotype
genotype
protected Set<IndividualStateListener>
individualStateListeners
protected Objectives
objectives
protected Phenotype
phenotype
protected Individual.State
state
-
Constructor Summary
Constructors Modifier Constructor Description protected
Individual()
Constructs anIndividual
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Genotype
getGenotype()
Returns the genotype.Objectives
getObjectives()
Returns the objectives.Phenotype
getPhenotype()
Returns the phenotype.Individual.State
getState()
Returns theIndividual.State
of theIndividual
.boolean
isDecoded()
Indicates whether thisIndividual
is already decoded.boolean
isEvaluated()
Indicates whether thisIndividual
is already evaluated.void
setGenotype(Genotype genotype)
Sets the genotype.protected void
setIndividualStatusListeners(Set<IndividualStateListener> individualStateListeners)
Sets the list ofIndividualStateListener
s that are called if theIndividual.State
of this individual changes.void
setObjectives(Objectives objectives)
Sets the objectives.void
setPhenotype(Phenotype phenotype)
Sets the phenotype.void
setState(Individual.State state)
Sets the state of theIndividual
.
-
-
-
Field Detail
-
genotype
protected Genotype genotype
-
phenotype
protected Phenotype phenotype
-
objectives
protected Objectives objectives
-
individualStateListeners
protected Set<IndividualStateListener> individualStateListeners
-
state
protected Individual.State state
-
-
Constructor Detail
-
Individual
@Inject protected Individual()
Constructs anIndividual
.
-
-
Method Detail
-
getPhenotype
public Phenotype getPhenotype()
Returns the phenotype.- Returns:
- the phenotype
- See Also:
setPhenotype(org.opt4j.core.Phenotype)
-
getObjectives
public Objectives getObjectives()
Returns the objectives.- Returns:
- the objectives
- See Also:
setObjectives(org.opt4j.core.Objectives)
-
getGenotype
public Genotype getGenotype()
Returns the genotype.- Returns:
- the genotype
- See Also:
setGenotype(org.opt4j.core.Genotype)
-
setGenotype
public void setGenotype(Genotype genotype)
Sets the genotype.- Parameters:
genotype
- the genotype to be set- See Also:
getGenotype()
-
setPhenotype
public void setPhenotype(Phenotype phenotype)
Sets the phenotype.- Parameters:
phenotype
- the phenotype to be set- See Also:
getPhenotype()
-
setObjectives
public void setObjectives(Objectives objectives)
Sets the objectives.- Parameters:
objectives
- the objectives to be set- See Also:
getObjectives()
-
isDecoded
public boolean isDecoded()
Indicates whether thisIndividual
is already decoded.- Returns:
true
if this individual is decoded
-
isEvaluated
public boolean isEvaluated()
Indicates whether thisIndividual
is already evaluated.- Returns:
true
if this inividual is evaluated
-
setState
public void setState(Individual.State state)
Sets the state of theIndividual
.- Parameters:
state
- the new status- See Also:
getState()
-
getState
public Individual.State getState()
Returns theIndividual.State
of theIndividual
.- Returns:
- the current state
- See Also:
setState(org.opt4j.core.Individual.State)
-
setIndividualStatusListeners
protected void setIndividualStatusListeners(Set<IndividualStateListener> individualStateListeners)
Sets the list ofIndividualStateListener
s that are called if theIndividual.State
of this individual changes.- Parameters:
individualStateListeners
- the listener for a changing status.
-
-