Package org.opt4j.optimizers.ea
Class MatingCrossoverMutate
- java.lang.Object
-
- org.opt4j.optimizers.ea.MatingCrossoverMutate
-
- All Implemented Interfaces:
Mating
public class MatingCrossoverMutate extends java.lang.Object implements Mating
TheMatingCrossoverMutate
creates offspring from a given set of parents by usingCrossover
andMutate
.
-
-
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 aMatingCrossoverMutate
with a givenCrossover
,Mutate
,Copy
,Coupler
,CrossoverRate
,Rand
, andIndividualFactory
.
-
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 actualCoupler
process of two parents.
-
-
-
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
-
crossoverRate
protected final CrossoverRate crossoverRate
-
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 aMatingCrossoverMutate
with a givenCrossover
,Mutate
,Copy
,Coupler
,CrossoverRate
,Rand
, andIndividualFactory
.- Parameters:
crossover
- the crossover operatormutate
- the mutate operatorcopy
- the copy operatorcoupler
- the couplercrossoverRate
- the used crossover ratemutationRate
- the mutation raterandom
- the random number generatorindividualFactory
- 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 interfaceMating
- Parameters:
size
- the number of individuals to createparents
- 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 interfaceMating
- Parameters:
size
- the number of individuals to createparents
- 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. TheCoupler
is used to create pairs of parents, which are mated using theMutate
and, depending on theCrossoverRate
, theCrossover
operator.- Parameters:
size
- the number of individuals to createparents
- 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 actualCoupler
process of two parents.- Parameters:
parent1
- parent oneparent2
- parent twodoCrossover
- indicates whether the coupler shall take place- Returns:
- the two offspring individuals
-
-