Package dealib.components
Class Individual
java.lang.Object
dealib.components.Individual
- All Implemented Interfaces:
Comparable
Individual is a class representing the structure and functionalities of an
individual in differential evolution.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Alicia Vazquez Ramos
-
Constructor Summary
ConstructorsConstructorDescriptionIndividual
(Execution exe) Constructor of an Individual, given the configuration of the current execution.Individual
(Execution exe, int G) Constructor of an Individual, given the configuration of the current execution and the generation, G, when it was created.Individual
(Execution exp, int G, double[] genotype) Constructor of an Individual, given the configuration of the current execution, the generation, G, when it was created and the genotype to be stored by the Individual. -
Method Summary
Modifier and TypeMethodDescriptionint
Compares two Individuals: the individual with minimum fitness has preference over the other individual.void
copyGenotype
(double[] genotype) Copies a given genotype to the current genotype of the Individual.double
Gets the fitness of the Individual.int
getG()
Gets the generation when the Individual was created.double
getGene
(int i) Gets the value of a given index gene, i, in the Individual genotype.double[]
Gets a reference to the Individual genotype.void
setFitness
(double fitness) Sets a new fitness value for the Individual.void
setG
(int G) Sets the generation when the Individual was created.void
setGene
(int i, double gene) Sets a new value for a given index gene, i, in the Individual genotype.void
setGenotype
(double[] genotype) Sets a new genotype for the Individual.toString()
Gets a string representing the visualization by console of the Individual.double
Updates fitness calling the evaluator configured in the current execution of an experiment.
-
Constructor Details
-
Individual
Constructor of an Individual, given the configuration of the current execution.- Parameters:
exe
- configuration of the current execution.
-
Individual
Constructor of an Individual, given the configuration of the current execution and the generation, G, when it was created.- Parameters:
exe
- configuration of the current execution.G
- generation when the Individual was created.
-
Individual
Constructor of an Individual, given the configuration of the current execution, the generation, G, when it was created and the genotype to be stored by the Individual.- Parameters:
exp
- configuration of the current execution.G
- generation when the Individual was created.genotype
-
-
-
Method Details
-
getG
public int getG()Gets the generation when the Individual was created.- Returns:
- the generation when the Individual was created.
-
getGenotype
public double[] getGenotype()Gets a reference to the Individual genotype.- Returns:
- the Individual genotype.
-
getFitness
public double getFitness()Gets the fitness of the Individual.- Returns:
- last update of the fitness of the Individual.
-
getGene
public double getGene(int i) Gets the value of a given index gene, i, in the Individual genotype.- Parameters:
i
- index of the gene.- Returns:
- the current value of the gene in position i.
-
setG
public void setG(int G) Sets the generation when the Individual was created.- Parameters:
G
- the generation when the Individual was created.
-
setGenotype
public void setGenotype(double[] genotype) Sets a new genotype for the Individual.- Parameters:
genotype
- new genotype reference for the Individual.
-
setFitness
public void setFitness(double fitness) Sets a new fitness value for the Individual.- Parameters:
fitness
- new fitness value.
-
setGene
public void setGene(int i, double gene) Sets a new value for a given index gene, i, in the Individual genotype.- Parameters:
i
- index of the gene.gene
- new value of the updated gene in position i.
-
copyGenotype
public void copyGenotype(double[] genotype) Copies a given genotype to the current genotype of the Individual.- Parameters:
genotype
- new genotype to be copied.
-
updateFitness
Updates fitness calling the evaluator configured in the current execution of an experiment.- Returns:
- a new value for fitness.
- Throws:
IncompatibleConfigurationException
- when the dimension of the problem does not fit with the dimensionality of the function used as evaluator.
-
toString
Gets a string representing the visualization by console of the Individual. -
compareTo
Compares two Individuals: the individual with minimum fitness has preference over the other individual.- Specified by:
compareTo
in interfaceComparable
- Parameters:
t
- other individual to be compared.- Returns:
- 1 if this Individual has preference over the other Individual, -1 if the other Individual has preference over the this Individual and 0 if both are equal.
-