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
TheMatingCrossoverMutatecreates offspring from a given set of parents by usingCrossoverandMutate.
-
-
Field Summary
Fields Modifier and Type Field Description protected Copy<Genotype>copyprotected Couplercouplerprotected Crossover<Genotype>crossoverprotected CrossoverRatecrossoverRateprotected IndividualFactoryindividualFactoryprotected Mutate<Genotype>mutateprotected MutationRatemutationRateprotected Randomrandom
-
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 aMatingCrossoverMutatewith 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 actualCouplerprocess 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 aMatingCrossoverMutatewith 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:MatingCreates offspring from a given set of parents.- Specified by:
getOffspringin 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:MatingCreates offspring from a given set of parents.- Specified by:
getOffspringin 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. TheCoupleris used to create pairs of parents, which are mated using theMutateand, depending on theCrossoverRate, theCrossoveroperator.- 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 actualCouplerprocess of two parents.- Parameters:
parent1- parent oneparent2- parent twodoCrossover- indicates whether the coupler shall take place- Returns:
- the two offspring individuals
-
-