Package org.opt4j.optimizers.ea
Class ElitismSelector
- java.lang.Object
-
- org.opt4j.optimizers.ea.ElitismSelector
-
- All Implemented Interfaces:
Selector
public class ElitismSelector extends java.lang.Object implements Selector
TheElitismSelector
is a single objective elitism select. If a multi-objective problem is optimized, the objectives are summed up to a single value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ElitismSelector.FitnessComparator
Comparator that sorts theIndividual
s based on their fitness values.
-
Constructor Summary
Constructors Constructor Description ElitismSelector(org.opt4j.core.common.random.Rand random)
Constructs anElitismSelector
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
calculateFitness(java.util.Collection<org.opt4j.core.Individual> individuals)
Calculates the fitness of theIndividual
s: the sum of all double values (these always have to be minimized) of the objectives.java.util.Collection<org.opt4j.core.Individual>
getLames(int lambda, java.util.Collection<org.opt4j.core.Individual> population)
Selects a subset oflambda
Individual
s and returns it as a newCollection
.java.util.Collection<org.opt4j.core.Individual>
getParents(int mu, java.util.Collection<org.opt4j.core.Individual> population)
Selects a subset ofIndividual
s and returns it as a newCollection
.void
init(int maxsize)
Sets the maximal number ofIndividual
s.
-
-
-
Constructor Detail
-
ElitismSelector
@Inject public ElitismSelector(org.opt4j.core.common.random.Rand random)
Constructs anElitismSelector
.- Parameters:
random
- the random number generator
-
-
Method Detail
-
getLames
public java.util.Collection<org.opt4j.core.Individual> getLames(int lambda, java.util.Collection<org.opt4j.core.Individual> population)
Description copied from interface:Selector
Selects a subset oflambda
Individual
s and returns it as a newCollection
. These individuals can be erased in the next generation.
-
getParents
public java.util.Collection<org.opt4j.core.Individual> getParents(int mu, java.util.Collection<org.opt4j.core.Individual> population)
Description copied from interface:Selector
Selects a subset ofIndividual
s and returns it as a newCollection
. These so called parents can be used to form the next generation.- Specified by:
getParents
in interfaceSelector
- Parameters:
mu
- the number of parents to selectpopulation
- the list of individuals- Returns:
- the parents
-
calculateFitness
protected void calculateFitness(java.util.Collection<org.opt4j.core.Individual> individuals)
Calculates the fitness of theIndividual
s: the sum of all double values (these always have to be minimized) of the objectives.- Parameters:
individuals
- the individuals to process
-
-