$darkmode
DENOPTIM
denoptim.ga.Population Class Reference

A collection of candidates. More...

Inheritance diagram for denoptim.ga.Population:
[legend]
Collaboration diagram for denoptim.ga.Population:
[legend]

Classes

class  XoverSitesAmongCandidates
 A data structure collecting crossover-compatible sites. More...
 

Public Member Functions

 Population (GAParameters settings)
 
boolean add (Candidate c)
 
void add (int index, Candidate c)
 
Candidate set (int index, Candidate c)
 
Candidate remove (int index)
 
boolean remove (Object c)
 
boolean removeAll (Collection<?> c)
 
void clear ()
 
boolean retainAll (Collection<?> c)
 
int getVersionID ()
 Returns an integer that represent the current status of the population. More...
 
Population clone ()
 Does not clone the cross-over compatibility relations between each pairs of population members. More...
 
List< CandidategetXoverPartners (Candidate memberA, List< Candidate > eligibleParents, FragmentSpace fragSpace)
 Returns a list of population members that can do crossover with the specified member. More...
 
List< XoverSitegetXoverSites (Candidate parentA, Candidate parentB)
 Returns a list of crossover sites between the two given parents. More...
 
void trim (int populationSize)
 Removes all the elements exceeding the given size. More...
 
double getMinFitness ()
 Gets the minimum value of the fitness in this population. More...
 
Candidate getMinFitnessMember ()
 Gets the Candidate with minimum value of the fitness in this population. More...
 
double getMaxFitness ()
 Gets the maximum value of the fitness in this population. More...
 
boolean isWithinPercentile (double value, double percentile)
 Checks if a given fitness value if within the given percentile of best candidates. More...
 
Candidate getCandidateNamed (String name)
 Returns the candidate with the given name, if present, or null. More...
 

Private Attributes

AtomicInteger populationUpdate = new AtomicInteger()
 An integer that changes every time we change the population. More...
 
XoverSitesAmongCandidates xoverCompatibilities
 Crossover compatibility between members. More...
 
GAParameters settings
 Parameters controlling the GA experiment. More...
 

Static Private Attributes

static final long serialVersionUID = 1L
 Version UID. More...
 

Detailed Description

A collection of candidates.

To speed-up operations such as the selection of parents for crossover, this class holds also compatibility relations between candidates. The latter are relevant when APClass compatibility rules are in use. Therefore, if FragmentSpace.useAPclassBasedApproach() returns false the population is just a list of candidates.

Author
Marco Foscato

Definition at line 47 of file Population.java.

Constructor & Destructor Documentation

◆ Population()

denoptim.ga.Population.Population ( GAParameters  settings)

Definition at line 71 of file Population.java.

References denoptim.programs.RunTimeParameters.ParametersType.FS_PARAMS, denoptim.fragspace.FragmentSpaceParameters.getFragmentSpace(), denoptim.programs.RunTimeParameters.getParameters(), denoptim.ga.Population.settings, denoptim.fragspace.FragmentSpace.useAPclassBasedApproach(), and denoptim.ga.Population.xoverCompatibilities.

Referenced by denoptim.ga.Population.clone().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ add() [1/2]

◆ add() [2/2]

void denoptim.ga.Population.add ( int  index,
Candidate  c 
)

Definition at line 98 of file Population.java.

References denoptim.ga.Population.populationUpdate.

◆ clear()

void denoptim.ga.Population.clear ( )

Definition at line 147 of file Population.java.

References denoptim.ga.Population.populationUpdate.

◆ clone()

Population denoptim.ga.Population.clone ( )

Does not clone the cross-over compatibility relations between each pairs of population members.

Definition at line 184 of file Population.java.

References denoptim.ga.Population.add(), denoptim.ga.Population.clone(), denoptim.ga.Population.XoverSitesAmongCandidates.clone(), denoptim.ga.Population.Population(), denoptim.ga.Population.settings, and denoptim.ga.Population.xoverCompatibilities.

Referenced by denoptim.ga.Population.clone(), and denoptim.ga.PopulationTest.testClone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCandidateNamed()

Candidate denoptim.ga.Population.getCandidateNamed ( String  name)

Returns the candidate with the given name, if present, or null.

Parameters
namethe name of the candidate to retrieve
Returns
the candidate with the given name, if present, or null.

Definition at line 515 of file Population.java.

◆ getMaxFitness()

double denoptim.ga.Population.getMaxFitness ( )

Gets the maximum value of the fitness in this population.

Returns
the maximum fitness value in this population

Definition at line 477 of file Population.java.

References denoptim.graph.Candidate.getFitness().

Referenced by denoptim.ga.Population.isWithinPercentile(), and denoptim.ga.PopulationTest.testGetMinMax().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMinFitness()

double denoptim.ga.Population.getMinFitness ( )

Gets the minimum value of the fitness in this population.

Returns
the minimum fitness value in this population, or the Double#MIN_VALUE

Definition at line 452 of file Population.java.

References denoptim.graph.Candidate.getFitness(), and denoptim.ga.Population.getMinFitnessMember().

Referenced by denoptim.ga.OffspringEvaluationTask.call(), denoptim.ga.Population.isWithinPercentile(), and denoptim.ga.PopulationTest.testGetMinMax().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMinFitnessMember()

Candidate denoptim.ga.Population.getMinFitnessMember ( )

Gets the Candidate with minimum value of the fitness in this population.

Returns
the population member with minimum fitness value.

Definition at line 464 of file Population.java.

References denoptim.graph.Candidate.getFitness().

Referenced by denoptim.ga.OffspringEvaluationTask.call(), and denoptim.ga.Population.getMinFitness().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVersionID()

int denoptim.ga.Population.getVersionID ( )

Returns an integer that represent the current status of the population.

Additions, removal or change of a population member triggers change of the returned value. The integer is a good way to check for population changes without looking at the actual population content.

Returns
an integer representing the version of the population.

Definition at line 173 of file Population.java.

References denoptim.ga.Population.populationUpdate.

Referenced by denoptim.ga.PopulationTest.testPopulationVersion().

Here is the caller graph for this function:

◆ getXoverPartners()

List< Candidate > denoptim.ga.Population.getXoverPartners ( Candidate  memberA,
List< Candidate eligibleParents,
FragmentSpace  fragSpace 
)

Returns a list of population members that can do crossover with the specified member.

Parameters
memberAa member that wants to do crossover and searches for a partner.
thesubset of population members we can consider as eligible parents.
Returns
the list of crossover-compatible population members.

Definition at line 370 of file Population.java.

References denoptim.ga.Population.XoverSitesAmongCandidates.contains(), denoptim.graph.Candidate.getGraph(), denoptim.programs.RunTimeParameters.getLogger(), denoptim.ga.Population.XoverSitesAmongCandidates.getMembersCompatibleWith(), denoptim.graph.Candidate.getName(), denoptim.ga.GraphOperations.locateCompatibleXOverPoints(), denoptim.programs.denovo.GAParameters.maxXOverableSubGraphSize, denoptim.ga.Population.XoverSitesAmongCandidates.put(), denoptim.graph.DGraph.sameAs(), denoptim.ga.Population.settings, and denoptim.ga.Population.xoverCompatibilities.

Referenced by denoptim.ga.EAUtils.performFBCC(), denoptim.ga.PopulationTest.testClone(), and denoptim.ga.PopulationTest.testXOverCompatibility().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getXoverSites()

List< XoverSite > denoptim.ga.Population.getXoverSites ( Candidate  parentA,
Candidate  parentB 
)

Returns a list of crossover sites between the two given parents.

The crossover sites are given using the same order used to specify the parents. This method should always be run after the Population#getXoverPartners(Candidate, ArrayList), which populated the crossover compatibility data.

Parameters
parentA
parentB
Returns
the list crossover sites.

Definition at line 423 of file Population.java.

References denoptim.ga.Population.XoverSitesAmongCandidates.get(), and denoptim.ga.Population.xoverCompatibilities.

Referenced by denoptim.ga.PopulationTest.compareSizeOfSites(), denoptim.ga.EAUtils.performFBCC(), and denoptim.ga.PopulationTest.testClone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isWithinPercentile()

boolean denoptim.ga.Population.isWithinPercentile ( double  value,
double  percentile 
)

Checks if a given fitness value if within the given percentile of best candidates.

Parameters
valuethe value of fitness to compare with the population.
percentilenumber in 0-1 range defining the desired percentile.
Returns
true is the value is among the best percentile% values in the current population, i.e., is larger than min + (100-percentile% * (max-min)).

Definition at line 496 of file Population.java.

References denoptim.ga.Population.getMaxFitness(), and denoptim.ga.Population.getMinFitness().

Referenced by denoptim.ga.OffspringEvaluationTask.call(), and denoptim.ga.PopulationTest.testIsInPercentile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove() [1/2]

Candidate denoptim.ga.Population.remove ( int  index)

Definition at line 116 of file Population.java.

References denoptim.ga.Population.populationUpdate.

Referenced by denoptim.ga.OffspringEvaluationTask.call(), and denoptim.ga.PopulationTest.testPopulationVersion().

Here is the caller graph for this function:

◆ remove() [2/2]

boolean denoptim.ga.Population.remove ( Object  c)

Definition at line 125 of file Population.java.

References denoptim.ga.Population.populationUpdate.

◆ removeAll()

boolean denoptim.ga.Population.removeAll ( Collection<?>  c)

Definition at line 136 of file Population.java.

References denoptim.ga.Population.populationUpdate.

◆ retainAll()

boolean denoptim.ga.Population.retainAll ( Collection<?>  c)

Definition at line 156 of file Population.java.

References denoptim.ga.Population.populationUpdate.

◆ set()

Candidate denoptim.ga.Population.set ( int  index,
Candidate  c 
)

Definition at line 107 of file Population.java.

References denoptim.ga.Population.populationUpdate.

Referenced by denoptim.ga.PopulationTest.testPopulationVersion().

Here is the caller graph for this function:

◆ trim()

void denoptim.ga.Population.trim ( int  populationSize)

Removes all the elements exceeding the given size.

Does not reorder the population prior to trimming!

Parameters
populationSizesize to trim down to.

Definition at line 435 of file Population.java.

References denoptim.programs.denovo.GAParameters.getPopulationSize(), denoptim.ga.Population.XoverSitesAmongCandidates.remove(), denoptim.ga.Population.settings, and denoptim.ga.Population.xoverCompatibilities.

Referenced by denoptim.ga.EvolutionaryAlgorithm.run().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ populationUpdate

AtomicInteger denoptim.ga.Population.populationUpdate = new AtomicInteger()
private

◆ serialVersionUID

final long denoptim.ga.Population.serialVersionUID = 1L
staticprivate

Version UID.

Definition at line 52 of file Population.java.

◆ settings

GAParameters denoptim.ga.Population.settings
private

◆ xoverCompatibilities

XoverSitesAmongCandidates denoptim.ga.Population.xoverCompatibilities
private

The documentation for this class was generated from the following file: