Package dealib.components
Class Population
java.lang.Object
dealib.components.Population
Population is a class representing the structure and functionalities of a
Population in differential evolution.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Alicia Vazquez Ramos
-
Constructor Summary
ConstructorsConstructorDescriptionPopulation
(Execution exe) Default constructor.Population
(Execution exe, ArrayList<Individual> p) Constructor given a set of individuals. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIndividual
(Individual ind) Adds a new Individual to the Population.void
evaluatePopulation
(Evaluator evaluator) Evaluates all the individuals of the Population given an Evaluator.Gets a list with all the individuals of the population.Gets a list with all the individuals of the population ordered by fitness.Gets the best individual of the population.int
Gets current generation in the evolution of the population.int
Gets the index of a given Individual in the unordered population.int
Gets the index of a given Individual in the ordered population.getIndividual
(int index) Gets an Individual of the unordered population given an index.getKBestIndividual
(int k) Gets the best k individual in the ordered population by fitness.int
getNextG()
Gets the next generation in the evolution of the population.int
getNP()
Gets the number of individuals of the Population.getNRandDistinctIndividuals
(int numIndividuals) Gets N random individuals from the Population which are distinct among them.getNRandDistinctIndividuals
(int ind, int numIndividuals) Gets N random individuals from the Population which are distinct among them and disintct from the given the index of an Individual ind.getNRandDistinctIndividuals
(Individual ind, int numIndividuals) Gets N random individuals from the Population which are distinct among them and disintct from the given Individual ind.int
Gets the lower bound of the active subpopulation if mechanism for subpopulations is active.int
Gets the upper bound of the active subpopulation if mechanism for subpopulations is active.void
Increments the current generation in the evolution of the population.boolean
Checks if the mechanism for subpopulations is active or not.void
reducePopulation
(double factor) Reduces the Population given a reduction factor.void
replaceIndividual
(int i, Individual ind) Replaces an Individual at position i by the given Individual ind.void
setActiveSubPopulations
(boolean b) Sets a new value for the mechanism of subpopulations: it can activated (TRUE) or deactivated (FALSE).void
Sets a new Population and increments the generation value in its evolution.void
setSubPopLB
(int lb) Lower bound of the active subpopulation if subpopulations mechanism is active.void
setSubPopUB
(int ub) Upper bound of the active subpopulation if subpopulations mechanism is active.toString()
Gets a string representing the visualization by console of the Population.
-
Constructor Details
-
Population
Default constructor.- Parameters:
exe
- configuration of the current execution.
-
Population
Constructor given a set of individuals.- Parameters:
exe
- configuration of the current execution.p
- population.
-
-
Method Details
-
getAllIndividuals
Gets a list with all the individuals of the population.- Returns:
- a list with all the individuals.
-
getAllOrderedIndividuals
Gets a list with all the individuals of the population ordered by fitness.- Returns:
- a list with all the individuals ordered by fitness.
-
getCurrentG
public int getCurrentG()Gets current generation in the evolution of the population.- Returns:
- the current generation.
-
getNextG
public int getNextG()Gets the next generation in the evolution of the population.- Returns:
- the next generation.
-
getNP
public int getNP()Gets the number of individuals of the Population.- Returns:
- current size of the Population.
-
getIndividual
Gets an Individual of the unordered population given an index.- Parameters:
index
- the position of the required Individual in the unordered population.- Returns:
- the Individual stored in the given position.
-
getIndexOfIndividual
Gets the index of a given Individual in the unordered population.- Parameters:
ind
- Individual searched.- Returns:
- the index of the Individual in the unordered population, -1 if not found.
-
getIndexOfOrderedIndividual
Gets the index of a given Individual in the ordered population.- Parameters:
ind
- Individual searched.- Returns:
- the index of the Individual in the ordered population, -1 if not found.
-
getKBestIndividual
Gets the best k individual in the ordered population by fitness.- Parameters:
k
- the kth individual.- Returns:
- the Individual stored in the given position in the ordered population.
-
getBestIndividual
Gets the best individual of the population.- Returns:
- the best individual of the population.
-
getSubPopLB
public int getSubPopLB()Gets the lower bound of the active subpopulation if mechanism for subpopulations is active.- Returns:
- lower bound of active subpopulation.
-
getSubPopUB
public int getSubPopUB()Gets the upper bound of the active subpopulation if mechanism for subpopulations is active.- Returns:
- upper bound of active subpopulation.
-
getNRandDistinctIndividuals
Gets N random individuals from the Population which are distinct among them.- Parameters:
numIndividuals
- number of individuals to be generated.- Returns:
- an array of individuals.
-
getNRandDistinctIndividuals
Gets N random individuals from the Population which are distinct among them and disintct from the given the index of an Individual ind. If the subpopulations mechanism is active it searchs from the active subpopulation.- Parameters:
ind
- index of the Individual to be distinct.numIndividuals
- number of individuals to be generated.- Returns:
- an array of individuals.
-
getNRandDistinctIndividuals
Gets N random individuals from the Population which are distinct among them and disintct from the given Individual ind. If the subpopulations mechanism is active it searchs from the active subpopulation.- Parameters:
ind
- Individual to be distinct.numIndividuals
- number of individuals to be generated.- Returns:
- an array of individuals.
-
isActiveSubPopulations
public boolean isActiveSubPopulations()Checks if the mechanism for subpopulations is active or not.- Returns:
- TRUE if it is active, FALSE otherwise.
-
setActiveSubPopulations
public void setActiveSubPopulations(boolean b) Sets a new value for the mechanism of subpopulations: it can activated (TRUE) or deactivated (FALSE).- Parameters:
b
- the new state for subpopulation mechanism.
-
setSubPopLB
public void setSubPopLB(int lb) Lower bound of the active subpopulation if subpopulations mechanism is active.- Parameters:
lb
- the lower bound of the active subpopulation.
-
setSubPopUB
public void setSubPopUB(int ub) Upper bound of the active subpopulation if subpopulations mechanism is active.- Parameters:
ub
- the upper bound of the active subpopulation.
-
setNextPopulation
Sets a new Population and increments the generation value in its evolution.- Parameters:
p
- new set of individuals of the next population.
-
incrPopulationG
public void incrPopulationG()Increments the current generation in the evolution of the population. -
addIndividual
Adds a new Individual to the Population.- Parameters:
ind
- new Individual.
-
replaceIndividual
Replaces an Individual at position i by the given Individual ind.- Parameters:
i
- position where set the new individual indind
- new individual for position i.
-
evaluatePopulation
Evaluates all the individuals of the Population given an Evaluator.- Parameters:
evaluator
- the way each individual is going to be evaluated.- Throws:
IncompatibleConfigurationException
- when the dimension of the problem does not fit with the dimensionality of the function used as evaluator.
-
reducePopulation
public void reducePopulation(double factor) Reduces the Population given a reduction factor.- Parameters:
factor
- reduction factor.
-
toString
Gets a string representing the visualization by console of the Population.
-