Package org.opt4j.optimizer.ea
Class MatingCrossoverMutate
- java.lang.Object
-
- org.opt4j.optimizer.ea.MatingCrossoverMutate
-
- All Implemented Interfaces:
Mating
public class MatingCrossoverMutate extends Object implements Mating
TheMatingCrossoverMutate
creates offspring from a given set of parents by usingCrossover
andMutate
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Copy<Genotype>
copy
protected Coupler
coupler
protected Crossover<Genotype>
crossover
protected CrossoverRate
crossoverRate
protected IndividualFactory
individualFactory
protected Mutate<Genotype>
mutate
protected MutationRate
mutationRate
protected Random
random
-
Constructor Summary
Constructors Constructor Description 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
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<Individual>
getOffspring(int size, Collection<Individual> parents)
Creates offspring from a given set of parents.Collection<Individual>
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 Detail
-
coupler
protected final Coupler coupler
-
crossoverRate
protected final CrossoverRate crossoverRate
-
mutationRate
protected final MutationRate mutationRate
-
random
protected final Random random
-
individualFactory
protected final IndividualFactory individualFactory
-
-
Constructor Detail
-
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 Detail
-
getOffspring
public Collection<Individual> getOffspring(int size, 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 Collection<Individual> getOffspring(int size, Collection<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 Collection<Individual> getOffspringInternal(int size, Collection<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 Pair<Individual> mate(Individual parent1, 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
-
-