Class MatingCrossoverMutate

  • All Implemented Interfaces:
    Mating

    public class MatingCrossoverMutate
    extends java.lang.Object
    implements Mating
    The MatingCrossoverMutate creates offspring from a given set of parents by using Crossover and Mutate.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.opt4j.operators.copy.Copy<org.opt4j.core.Genotype> copy  
      protected Coupler coupler  
      protected org.opt4j.operators.crossover.Crossover<org.opt4j.core.Genotype> crossover  
      protected CrossoverRate crossoverRate  
      protected org.opt4j.core.IndividualFactory individualFactory  
      protected org.opt4j.operators.mutate.Mutate<org.opt4j.core.Genotype> mutate  
      protected org.opt4j.operators.mutate.MutationRate mutationRate  
      protected java.util.Random random  
    • Constructor Summary

      Constructors 
      Constructor Description
      MatingCrossoverMutate​(org.opt4j.operators.crossover.Crossover<org.opt4j.core.Genotype> crossover, org.opt4j.operators.mutate.Mutate<org.opt4j.core.Genotype> mutate, org.opt4j.operators.copy.Copy<org.opt4j.core.Genotype> copy, Coupler coupler, CrossoverRate crossoverRate, org.opt4j.operators.mutate.MutationRate mutationRate, org.opt4j.core.common.random.Rand random, org.opt4j.core.IndividualFactory individualFactory)
      Constructs a MatingCrossoverMutate with a given Crossover , Mutate, Copy, Coupler, CrossoverRate, Rand, and IndividualFactory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<org.opt4j.core.Individual> getOffspring​(int size, java.util.Collection<org.opt4j.core.Individual> parents)
      Creates offspring from a given set of parents.
      java.util.Collection<org.opt4j.core.Individual> getOffspring​(int size, org.opt4j.core.Individual... parents)
      Creates offspring from a given set of parents.
      protected java.util.Collection<org.opt4j.core.Individual> getOffspringInternal​(int size, java.util.Collection<org.opt4j.core.Individual> parents)
      Creates offspring from a given set of parents.
      protected org.opt4j.operators.crossover.Pair<org.opt4j.core.Individual> mate​(org.opt4j.core.Individual parent1, org.opt4j.core.Individual parent2, boolean doCrossover)
      Performs the actual Coupler process of two parents.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • crossover

        protected final org.opt4j.operators.crossover.Crossover<org.opt4j.core.Genotype> crossover
      • mutate

        protected final org.opt4j.operators.mutate.Mutate<org.opt4j.core.Genotype> mutate
      • copy

        protected final org.opt4j.operators.copy.Copy<org.opt4j.core.Genotype> copy
      • coupler

        protected final Coupler coupler
      • mutationRate

        protected final org.opt4j.operators.mutate.MutationRate mutationRate
      • random

        protected final java.util.Random random
      • individualFactory

        protected final org.opt4j.core.IndividualFactory individualFactory
    • Constructor Detail

      • MatingCrossoverMutate

        @Inject
        public MatingCrossoverMutate​(org.opt4j.operators.crossover.Crossover<org.opt4j.core.Genotype> crossover,
                                     org.opt4j.operators.mutate.Mutate<org.opt4j.core.Genotype> mutate,
                                     org.opt4j.operators.copy.Copy<org.opt4j.core.Genotype> copy,
                                     Coupler coupler,
                                     CrossoverRate crossoverRate,
                                     org.opt4j.operators.mutate.MutationRate mutationRate,
                                     org.opt4j.core.common.random.Rand random,
                                     org.opt4j.core.IndividualFactory individualFactory)
        Constructs a MatingCrossoverMutate with a given Crossover , Mutate, Copy, Coupler, CrossoverRate, Rand, and IndividualFactory.
        Parameters:
        crossover - the crossover operator
        mutate - the mutate operator
        copy - the copy operator
        coupler - the coupler
        crossoverRate - the used crossover rate
        mutationRate - the mutation rate
        random - the random number generator
        individualFactory - the individual factory
    • Method Detail

      • getOffspring

        public java.util.Collection<org.opt4j.core.Individual> getOffspring​(int size,
                                                                            org.opt4j.core.Individual... parents)
        Description copied from interface: Mating
        Creates offspring from a given set of parents.
        Specified by:
        getOffspring in interface Mating
        Parameters:
        size - the number of individuals to create
        parents - the parents
        Returns:
        the offspring
      • getOffspring

        public java.util.Collection<org.opt4j.core.Individual> getOffspring​(int size,
                                                                            java.util.Collection<org.opt4j.core.Individual> parents)
        Description copied from interface: Mating
        Creates offspring from a given set of parents.
        Specified by:
        getOffspring in interface Mating
        Parameters:
        size - the number of individuals to create
        parents - the parents
        Returns:
        the offspring
      • getOffspringInternal

        protected java.util.Collection<org.opt4j.core.Individual> getOffspringInternal​(int size,
                                                                                       java.util.Collection<org.opt4j.core.Individual> parents)
        Creates offspring from a given set of parents. The Coupler is used to create pairs of parents, which are mated using the Mutate and, depending on the CrossoverRate, the Crossover operator.
        Parameters:
        size - the number of individuals to create
        parents - the parents
        Returns:
        the offspring
      • mate

        protected org.opt4j.operators.crossover.Pair<org.opt4j.core.Individual> mate​(org.opt4j.core.Individual parent1,
                                                                                     org.opt4j.core.Individual parent2,
                                                                                     boolean doCrossover)
        Performs the actual Coupler process of two parents.
        Parameters:
        parent1 - parent one
        parent2 - parent two
        doCrossover - indicates whether the coupler shall take place
        Returns:
        the two offspring individuals