Documentation of 'org.jgap.Population' Java class
Population
org.jgap

Class Population

    • Field Detail

      • CHROM_DELIMITER_HEADING

        public static final java.lang.String CHROM_DELIMITER_HEADING
        Represents the heading delimiter that is used to separate chromosomes in the persistent representation.
        See Also:
        Constant Field Values
      • CHROM_DELIMITER_CLOSING

        public static final java.lang.String CHROM_DELIMITER_CLOSING
        Represents the closing delimiter that is used to separate chromosomes in the persistent representation.
        See Also:
        Constant Field Values
    • Method Detail

      • addChromosome

        public void addChromosome(IChromosome a_toAdd)
        Adds a Chromosome to this Population. Does nothing when given null.
        Parameters:
        a_toAdd - the Chromosome to add
        Since:
        2.0
      • addChromosomes

        public void addChromosomes(Population a_population)
        Adds all the Chromosomes in the given Population. Does nothing on null or an empty Population.
        Parameters:
        a_population - the Population to add
        Since:
        2.0
      • setChromosomes

        public void setChromosomes(java.util.List a_chromosomes)
        Replaces all chromosomes in the population with the give list of chromosomes.
        Parameters:
        a_chromosomes - the chromosomes to make the population up from
      • setChromosome

        public void setChromosome(int a_index,
                                  IChromosome a_chromosome)
        Sets in the given Chromosome on the given index in the list of chromosomes. If the given index is exceeding the list by one, the chromosome is appended.
        Parameters:
        a_index - the index to set the Chromosome in
        a_chromosome - the Chromosome to be set
        Since:
        2.0
      • getChromosomes

        public java.util.List<IChromosome> getChromosomes()
        Returns:
        the list of Chromosome's in the Population. Don't modify the retrieved list by using clear(), remove(int) etc. If you do so, you need to call setChanged(true)
        Since:
        2.0
      • getChromosome

        public IChromosome getChromosome(int a_index)
        Parameters:
        a_index - the index of the Chromosome to be returned
        Returns:
        Chromosome at given index in the Population
        Since:
        2.0
      • size

        public int size()
        Returns:
        number of Chromosome's in the Population
        Since:
        2.0
      • iterator

        public java.util.Iterator iterator()
        Returns:
        Iterator for the Chromosome list in the Population. Please be aware that using remove() forces you to call setChanged(true)
        Since:
        2.0
      • toChromosomes

        public IChromosome[] toChromosomes()
        Returns:
        the Population converted into a list of Chromosome's
        Since:
        2.0
      • determineFittestChromosome

        public IChromosome determineFittestChromosome()
        Determines the fittest Chromosome in the Population (the one with the highest fitness value) and memorizes it. This is an optimized version compared to calling determineFittesChromosomes(1).
        Returns:
        the fittest Chromosome of the Population
        Since:
        2.0
      • determineFittestChromosome

        public IChromosome determineFittestChromosome(int a_startIndex,
                                                      int a_endIndex)
        Determines the fittest Chromosome in the population (the one with the highest fitness value) within the given indices and memorizes it. This is an optimized version compared to calling determineFittesChromosomes(1).
        Parameters:
        a_startIndex - index to begin the evaluation with
        a_endIndex - index to end the evaluation with
        Returns:
        the fittest Chromosome of the population within the given indices
        Since:
        3.0
      • isChanged

        public boolean isChanged()
        Returns:
        true: population's chromosomes (maybe) were changed, false: not changed for sure
        Since:
        2.6
      • contains

        public boolean contains(IChromosome a_chromosome)
        Determines whether the given chromosome is contained within the population.
        Parameters:
        a_chromosome - the chromosome to check
        Returns:
        true: chromosome contained within population
        Since:
        2.1
      • determineFittestChromosomes

        public java.util.List determineFittestChromosomes(int a_numberOfChromosomes)
        Sorts the Chromosome list and returns the fittest n Chromosomes in the population.
        Parameters:
        a_numberOfChromosomes - number of top performer chromosomes to be returned
        Returns:
        list of the fittest n Chromosomes of the population, or the fittest x Chromosomes with x = number of chromosomes in case n > x.
        Since:
        2.4
      • sortByFitness

        public void sortByFitness()
        Sorts the chromosomes within the population according to their fitness value using ChromosomFitnessComparator. The fittest chromosome is then at index 0.
        Since:
        2.6
      • getGenome

        public java.util.List getGenome(boolean a_resolveCompositeGenes)
        Returns the genotype of the population, i.e. the list of genes in the Population.
        Parameters:
        a_resolveCompositeGenes - true: split encountered CompositeGenes into their single (atomic) genes
        Returns:
        genotype of the population
        Since:
        2.3
      • isSorted

        public boolean isSorted()
      • equals

        public boolean equals(java.lang.Object a_pop)
        The equals-method.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        a_pop - the population instance to compare with
        Returns:
        true: given object equal to comparing one
        Since:
        2.6
      • compareTo

        public int compareTo(java.lang.Object a_pop)
        This method is not producing symmetric results as -1 is more often returned than 1 (see description of return value).
        Parameters:
        a_pop - the other population to compare
        Returns:
        1: a_pop is null or having fewer chromosomes or equal number of chromosomes but at least one not contained. 0: both populations containing exactly the same chromosomes. -1: this population contains fewer chromosomes than a_pop
        Since:
        2.6
      • clone

        public java.lang.Object clone()
        Specified by:
        clone in interface ICloneable
        Overrides:
        clone in class java.lang.Object
        Returns:
        deeply cloned population instance
        Since:
        3.2
      • clear

        public void clear()
        Clears the list of chromosomes. Normally, this should not be necessary. But especially in distributed computing, a fresh population has to be provided sometimes.
        Since:
        3.2
      • getPersistentRepresentation

        public java.lang.String getPersistentRepresentation()
        Returns a persistent representation of this chromosome, see interface Gene for description. Similar to CompositeGene's routine. But does not include all information of the chromosome (yet).
        Specified by:
        getPersistentRepresentation in interface IPersistentRepresentation
        Returns:
        string representation of this Chromosome's relevant parts of its current state
        Throws:
        java.lang.UnsupportedOperationException
        Since:
        3.2
      • hashCode

        public int hashCode()
        Hashcode function for the genotype, tries to create a unique hashcode for the chromosomes within the population. The logic for the hashcode is Step Result ---- ------ 1 31*0 + hashcode_0 = y(1) 2 31*y(1) + hashcode_1 = y(2) 3 31*y(2) + hashcode_2 = y(3) n 31*y(n-1) + hashcode_n-1 = y(n)
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the computed hashcode
        Since:
        3.5

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.