Package org.opt4j.optimizer.ea
Class ElitismSelector
- java.lang.Object
-
- org.opt4j.optimizer.ea.ElitismSelector
-
- All Implemented Interfaces:
Selector
public class ElitismSelector extends 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(Rand random)
Constructs anElitismSelector
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
calculateFitness(Collection<Individual> population)
Calculates the fitness of theIndividual
s: the sum of all double values (these always have to be minimized) of the objectives.Collection<Individual>
getLames(int lambda, Collection<Individual> population)
Collection<Individual>
getParents(int mu, Collection<Individual> population)
Selects a subset ofIndividual
s and returns it as a newCollection
.void
init(int maxsize)
Sets the maximal number ofIndividual
s.
-
-
-
Field Detail
-
random
protected final Random random
-
fitness
protected final Map<Individual,Double> fitness
-
-
Constructor Detail
-
ElitismSelector
@Inject public ElitismSelector(Rand random)
Constructs anElitismSelector
.- Parameters:
random
- the random number generator
-
-
Method Detail
-
getLames
public Collection<Individual> getLames(int lambda, Collection<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 Collection<Individual> getParents(int mu, Collection<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(Collection<Individual> population)
Calculates the fitness of theIndividual
s: the sum of all double values (these always have to be minimized) of the objectives.- Parameters:
population
-
-
init
public void init(int maxsize)
Description copied from interface:Selector
Sets the maximal number ofIndividual
s.
-
-