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
TheElitismSelectoris 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 classElitismSelector.FitnessComparatorComparator that sorts theIndividuals 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 voidcalculateFitness(Collection<Individual> population)Calculates the fitness of theIndividuals: 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 ofIndividuals and returns it as a newCollection.voidinit(int maxsize)Sets the maximal number ofIndividuals.
-
-
-
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:SelectorSelects a subset oflambdaIndividuals 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:SelectorSelects a subset ofIndividuals and returns it as a newCollection. These so called parents can be used to form the next generation.- Specified by:
getParentsin 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 theIndividuals: 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:SelectorSets the maximal number ofIndividuals.
-
-