public class MatingCrossoverMutate extends java.lang.Object implements Mating
MatingCrossoverMutate
creates offspring from a given set of
parents by using Crossover
and Mutate
.Modifier and Type | Field and 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 and 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 . |
Modifier and Type | Method and 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. |
protected final org.opt4j.operators.crossover.Crossover<org.opt4j.core.Genotype> crossover
protected final org.opt4j.operators.mutate.Mutate<org.opt4j.core.Genotype> mutate
protected final org.opt4j.operators.copy.Copy<org.opt4j.core.Genotype> copy
protected final Coupler coupler
protected final CrossoverRate crossoverRate
protected final org.opt4j.operators.mutate.MutationRate mutationRate
protected final java.util.Random random
protected final org.opt4j.core.IndividualFactory individualFactory
@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)
MatingCrossoverMutate
with a given Crossover
, Mutate
, Copy
, Coupler
, CrossoverRate
,
Rand
, and IndividualFactory
.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 factorypublic java.util.Collection<org.opt4j.core.Individual> getOffspring(int size, org.opt4j.core.Individual... parents)
Mating
getOffspring
in interface Mating
size
- the number of individuals to createparents
- the parentspublic java.util.Collection<org.opt4j.core.Individual> getOffspring(int size, java.util.Collection<org.opt4j.core.Individual> parents)
Mating
getOffspring
in interface Mating
size
- the number of individuals to createparents
- the parentsprotected java.util.Collection<org.opt4j.core.Individual> getOffspringInternal(int size, java.util.Collection<org.opt4j.core.Individual> parents)
Coupler
is used to create pairs of parents, which are mated
using the Mutate
and, depending on the CrossoverRate
, the
Crossover
operator.size
- the number of individuals to createparents
- the parentsprotected org.opt4j.operators.crossover.Pair<org.opt4j.core.Individual> mate(org.opt4j.core.Individual parent1, org.opt4j.core.Individual parent2, boolean doCrossover)
Coupler
process of two parents.parent1
- parent oneparent2
- parent twodoCrossover
- indicates whether the coupler shall take place