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
FieldsModifier and TypeFieldDescriptionprotected final Couplerprotected final CrossoverRateprotected final IndividualFactoryprotected final MutationRateprotected final Random -
Constructor Summary
ConstructorsConstructorDescriptionMatingCrossoverMutate(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
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 actualCouplerprocess 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 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 Details
-
getOffspring
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
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
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
Performs the actualCouplerprocess of two parents.- Parameters:
parent1- parent oneparent2- parent twodoCrossover- indicates whether the coupler shall take place- Returns:
- the two offspring individuals
-