Package org.opt4j.optimizer.ea
Class MatingCrossoverMutate
java.lang.Object
org.opt4j.optimizer.ea.MatingCrossoverMutate
- All Implemented Interfaces:
Mating
The
MatingCrossoverMutate
creates offspring from a given set of
parents by using Crossover
and Mutate
.-
Field Summary
Modifier and TypeFieldDescriptionprotected final Coupler
protected final CrossoverRate
protected final IndividualFactory
protected final MutationRate
protected final Random
-
Constructor Summary
ConstructorDescriptionMatingCrossoverMutate
(Crossover<Genotype> crossover, Mutate<Genotype> mutate, Copy<Genotype> copy, Coupler coupler, CrossoverRate crossoverRate, MutationRate mutationRate, Rand random, IndividualFactory individualFactory) Constructs aMatingCrossoverMutate
with a givenCrossover
,Mutate
,Copy
,Coupler
,CrossoverRate
,Rand
, andIndividualFactory
. -
Method Summary
Modifier and TypeMethodDescriptiongetOffspring
(int size, Collection<Individual> parents) Creates offspring from a given set of parents.getOffspring
(int size, Individual... parents) Creates offspring from a given set of parents.protected Collection<Individual>
getOffspringInternal
(int size, Collection<Individual> parents) Creates offspring from a given set of parents.protected Pair<Individual>
mate
(Individual parent1, Individual parent2, boolean doCrossover) Performs the actualCoupler
process of two parents.
-
Field Details
-
crossover
-
mutate
-
copy
-
coupler
-
crossoverRate
-
mutationRate
-
random
-
individualFactory
-
-
Constructor Details
-
MatingCrossoverMutate
@Inject public MatingCrossoverMutate(Crossover<Genotype> crossover, Mutate<Genotype> mutate, Copy<Genotype> copy, Coupler coupler, CrossoverRate crossoverRate, MutationRate mutationRate, Rand random, 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 Details
-
getOffspring
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
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
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
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
-