Documentation of 'smile.gap.BitString' Java class
BitString
smile.gap

Class BitString

  • All Implemented Interfaces:
    java.lang.Comparable<Chromosome>, Chromosome


    public class BitString
    extends java.lang.Object
    implements Chromosome
    The standard bit string representation of the solution domain. Here are some general guides on parameter setting.

    Crossover rate determines how often will be crossover performed. If there is no crossover, offspring is exact copy of parents. If there is a crossover, offspring is made from parts of parents' chromosome. If crossover rate is 100%, then all offspring is made by crossover. If it is 0%, whole new generation is made from exact copies of chromosomes from old population. However, it this does not mean that the new generation is the same because of mutation. Crossover is made in hope that new chromosomes will have good parts of old chromosomes and maybe the new chromosomes will be better. However it is good to leave some part of population survive to next generation. Crossover rate generally should be high, about 80% - 95%. However some results show that for some problems crossover rate about 60% is the best.

    Mutation rate determines how often will be parts of chromosome mutated. If there is no mutation, offspring is taken after crossover (or copy) without any change. If mutation is performed, part of chromosome is changed. Mutation is made to prevent falling GA into local extreme, but it should not occur very often, because then GA will in fact change to random search. Best rates reported are about 0.5% - 1%.

    • Field Detail

      • length

        public final int length
        The length of chromosome.
    • Constructor Detail

      • BitString

        public BitString(int length,
                         FitnessMeasure<BitString> measure)
        Constructor. Two point cross over, cross over rate 0.9, mutation rate 0.01.
        Parameters:
        length - the length of bit string.
        measure - the fitness measure.
      • BitString

        public BitString(int length,
                         FitnessMeasure<BitString> measure,
                         BitString.Crossover crossover,
                         double crossoverRate,
                         double mutationRate)
        Constructor.
        Parameters:
        length - the length of bit string.
        measure - the fitness measure.
        crossover - the strategy of crossover operation.
        crossoverRate - the crossover rate.
        mutationRate - the mutation rate.
      • BitString

        public BitString(int[] bits,
                         FitnessMeasure<BitString> measure)
        Constructor. Two point cross over, cross over rate 0.9, mutation rate 0.01.
        Parameters:
        bits - the bit string of chromosome.
        measure - the fitness measure.
      • BitString

        public BitString(int[] bits,
                         FitnessMeasure<BitString> measure,
                         BitString.Crossover crossover,
                         double crossoverRate,
                         double mutationRate)
        Constructor.
        Parameters:
        bits - the bit string of chromosome.
        measure - the fitness measure.
        crossover - the strategy of crossover operation.
        crossoverRate - the crossover rate.
        mutationRate - the mutation rate.
    • Method Detail

      • bits

        public int[] bits()
        Returns the bit string of chromosome.
      • compareTo

        public int compareTo(Chromosome o)
        Specified by:
        compareTo in interface java.lang.Comparable<Chromosome>
      • fitness

        public double fitness()
        Description copied from interface: Chromosome
        Returns the fitness of chromosome.
        Specified by:
        fitness in interface Chromosome
      • crossover

        public BitString[] crossover(Chromosome another)
        Description copied from interface: Chromosome
        Returns a pair of offsprings by crossovering this one with another one according to the crossover rate, which determines how often will be crossover performed. If there is no crossover, offspring is exact copy of parents. Various crossover strategies can be employed.
        Specified by:
        crossover in interface Chromosome
      • mutate

        public void mutate()
        Description copied from interface: Chromosome
        For genetic algorithms, this method mutates the chromosome randomly. The offspring may have no changes since the mutation rate is usually very low. For Lamarckian algorithms, this method actually does the local search such as such as hill-climbing.
        Specified by:
        mutate in interface Chromosome

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.