Class Individual

java.lang.Object
dealib.components.Individual
All Implemented Interfaces:
Comparable

public class Individual extends Object implements 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

    Constructors
    Constructor
    Description
    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 Type
    Method
    Description
    int
    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
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Individual

      public Individual(Execution exe)
      Constructor of an Individual, given the configuration of the current execution.
      Parameters:
      exe - configuration of the current execution.
    • Individual

      public Individual(Execution exe, int G)
      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

      public 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.
      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

      public double updateFitness() throws IncompatibleConfigurationException
      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

      public String toString()
      Gets a string representing the visualization by console of the Individual.
      Overrides:
      toString in class Object
      Returns:
      string representing the current state of the Individual.
    • compareTo

      public int compareTo(Object t)
      Compares two Individuals: the individual with minimum fitness has preference over the other individual.
      Specified by:
      compareTo in interface Comparable
      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.