Documentation of 'org.jgap.impl.CrossoverOperator' Java class
CrossoverOperator
org.jgap.impl

Class CrossoverOperator

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable, GeneticOperator


    public class CrossoverOperator
    extends BaseGeneticOperator
    implements java.lang.Comparable
    The crossover operator randomly selects two Chromosomes from the population and "mates" them by randomly picking a gene and then swapping that gene and all subsequent genes between the two Chromosomes. The two modified Chromosomes are then added to the list of candidate Chromosomes. If you work with CompositeGenes, this operator expects them to contain genes of the same type (e.g. IntegerGene). If you have mixed types, please provide your own crossover operator. This CrossoverOperator supports both fixed and dynamic crossover rates. A fixed rate is one specified at construction time by the user. This operation is performed 1/m_crossoverRate as many times as there are Chromosomes in the population. Another possibility is giving the crossover rate as a percentage. A dynamic rate is determined by this class on the fly if no fixed rate is provided.
    Since:
    1.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      CrossoverOperator()
      Constructs a new instance of this CrossoverOperator without a specified crossover rate, this results in dynamic crossover rate being turned off.
      CrossoverOperator(Configuration a_configuration)
      Constructs a new instance of this CrossoverOperator without a specified crossover rate, this results in dynamic crossover rate being turned off.
      CrossoverOperator(Configuration a_configuration, double a_crossoverRatePercentage)
      Constructs a new instance of this CrossoverOperator with the given crossover rate.
      CrossoverOperator(Configuration a_configuration, double a_crossoverRatePercentage, boolean a_allowFullCrossOver)
      Constructs a new instance of this CrossoverOperator with the given crossover rate.
      CrossoverOperator(Configuration a_configuration, double a_crossoverRatePercentage, boolean a_allowFullCrossOver, boolean a_xoverNewAge)
      Constructs a new instance of this CrossoverOperator with the given crossover rate.
      CrossoverOperator(Configuration a_configuration, int a_desiredCrossoverRate)
      Constructs a new instance of this CrossoverOperator with the given crossover rate.
      CrossoverOperator(Configuration a_configuration, int a_desiredCrossoverRate, boolean a_allowFullCrossOver)
      Constructs a new instance of this CrossoverOperator with the given crossover rate.
      CrossoverOperator(Configuration a_configuration, int a_desiredCrossoverRate, boolean a_allowFullCrossOver, boolean a_xoverNewAge)
      Constructs a new instance of this CrossoverOperator with the given crossover rate.
      CrossoverOperator(Configuration a_configuration, IUniversalRateCalculator a_crossoverRateCalculator)
      Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.
      CrossoverOperator(Configuration a_configuration, IUniversalRateCalculator a_crossoverRateCalculator, boolean a_allowFullCrossOver)
      Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.
    • Constructor Detail

      • CrossoverOperator

        public CrossoverOperator()
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator without a specified crossover rate, this results in dynamic crossover rate being turned off. This means that the crossover rate will be fixed at populationsize/2.

        Attention: The configuration used is the one set with the static method Genotype.setConfiguration.

        Throws:
        InvalidConfigurationException
        Since:
        2.0
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator without a specified crossover rate, this results in dynamic crossover rate being turned off. This means that the crossover rate will be fixed at populationsize/2.
        Parameters:
        a_configuration - the configuration to use
        Throws:
        InvalidConfigurationException
        Since:
        3.0
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 IUniversalRateCalculator a_crossoverRateCalculator)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.
        Parameters:
        a_configuration - the configuration to use
        a_crossoverRateCalculator - calculator for dynamic crossover rate computation
        Throws:
        InvalidConfigurationException
        Since:
        3.0 (since 2.0 without a_configuration)
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 IUniversalRateCalculator a_crossoverRateCalculator,
                                 boolean a_allowFullCrossOver)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.
        Parameters:
        a_configuration - the configuration to use
        a_crossoverRateCalculator - calculator for dynamic crossover rate computation
        a_allowFullCrossOver - true: x-over before AND after x-over point, false: only x-over after x-over point
        Throws:
        InvalidConfigurationException
        Since:
        3.3.2
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 int a_desiredCrossoverRate)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with the given crossover rate.
        Parameters:
        a_configuration - the configuration to use
        a_desiredCrossoverRate - the desired rate of crossover
        Throws:
        InvalidConfigurationException
        Since:
        3.0 (since 2.0 without a_configuration)
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 int a_desiredCrossoverRate,
                                 boolean a_allowFullCrossOver)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with the given crossover rate. No new chromosomes are x-overed.
        Parameters:
        a_configuration - the configuration to use
        a_desiredCrossoverRate - the desired rate of crossover
        a_allowFullCrossOver - true: x-over before AND after x-over point, false: only x-over after x-over point
        Throws:
        InvalidConfigurationException
        Since:
        3.3.2
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 int a_desiredCrossoverRate,
                                 boolean a_allowFullCrossOver,
                                 boolean a_xoverNewAge)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with the given crossover rate.
        Parameters:
        a_configuration - the configuration to use
        a_desiredCrossoverRate - the desired rate of crossover
        a_allowFullCrossOver - true: x-over before AND after x-over point, false: only x-over after x-over point
        a_xoverNewAge - true: also x-over chromosomes with age of zero (newly created chromosomes)
        Throws:
        InvalidConfigurationException
        Since:
        3.3.2
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 double a_crossoverRatePercentage)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with the given crossover rate. No new chromosomes are x-overed.
        Parameters:
        a_configuration - the configuration to use
        a_crossoverRatePercentage - the desired rate of crossover in percentage of the population
        Throws:
        InvalidConfigurationException
        Since:
        3.0 (since 2.0 without a_configuration)
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 double a_crossoverRatePercentage,
                                 boolean a_allowFullCrossOver)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with the given crossover rate. No new chromosomes are x-overed.
        Parameters:
        a_configuration - the configuration to use
        a_crossoverRatePercentage - the desired rate of crossover in percentage of the population
        a_allowFullCrossOver - true: x-over before AND after x-over point, false: only x-over after x-over point
        Throws:
        InvalidConfigurationException
        Since:
        3.3.2.
      • CrossoverOperator

        public CrossoverOperator(Configuration a_configuration,
                                 double a_crossoverRatePercentage,
                                 boolean a_allowFullCrossOver,
                                 boolean a_xoverNewAge)
                          throws InvalidConfigurationException
        Constructs a new instance of this CrossoverOperator with the given crossover rate.
        Parameters:
        a_configuration - the configuration to use
        a_crossoverRatePercentage - the desired rate of crossover in percentage of the population
        a_allowFullCrossOver - true: x-over before AND after x-over point, false: only x-over after x-over point
        a_xoverNewAge - true: also x-over chromosomes with age of zero (newly created chromosomes)
        Throws:
        InvalidConfigurationException
        Since:
        3.3.2.
    • Method Detail

      • operate

        public void operate(Population a_population,
                            java.util.List a_candidateChromosomes)
        Does the crossing over.
        Specified by:
        operate in interface GeneticOperator
        Parameters:
        a_population - the population of chromosomes from the current evolution prior to exposure to crossing over
        a_candidateChromosomes - the pool of chromosomes that have been selected for the next evolved population
        Since:
        2.0
      • compareTo

        public int compareTo(java.lang.Object a_other)
        Compares the given object to this one.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        a_other - the instance against which to compare this instance
        Returns:
        a negative number if this instance is "less than" the given instance, zero if they are equal to each other, and a positive number if this is "greater than" the given instance
        Since:
        2.6
      • setAllowFullCrossOver

        public void setAllowFullCrossOver(boolean a_allowFullXOver)
        Parameters:
        a_allowFullXOver - x-over before and after a randomly chosen point
        Since:
        3.3.2
      • isAllowFullCrossOver

        public boolean isAllowFullCrossOver()
        Returns:
        x-over before and after a randomly chosen x-over point
        Since:
        3.3.2
      • getCrossOverRate

        public int getCrossOverRate()
        Returns:
        the crossover rate set
        Since:
        3.3.2
      • getCrossOverRatePercent

        public double getCrossOverRatePercent()
        Returns:
        the crossover rate set
        Since:
        3.3.2
      • setXoverNewAge

        public void setXoverNewAge(boolean a_xoverNewAge)
        Parameters:
        a_xoverNewAge - true: also x-over chromosomes with age of zero (newly created chromosomes)
        Since:
        3.3.2
      • isXoverNewAge

        public boolean isXoverNewAge()
        Returns:
        a_xoverNewAge true: also x-over chromosomes with age of zero (newly created chromosomes)
        Since:
        3.3.2

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.