Class AdaptiveGridArchive
java.lang.Object
org.moeaframework.core.population.Population
org.moeaframework.core.population.NondominatedPopulation
org.moeaframework.core.population.AdaptiveGridArchive
- All Implemented Interfaces:
 Iterable<Solution>,Copyable<Population>,Stateful,Displayable,Formattable<Solution>
Adaptive grid archive.  Divides objective space into a number of grid cells, maintaining a count of the number of
 solutions within each grid cell.  When the size of the archive exceeds a specified capacity, a solution from the
 most crowded grid cell is selected and removed from the archive.
 
 This implementation currently stores the density of each grid cell in an array.  As such,
 pow(numberOfDivisions, numberOfObjectives) can not exceed the storage capacity of an array, or
 pow(2, 32).  We may consider at some point using sparse arrays to remove this limitation.
 
References:
- Knowles, J.D. and Corne, D.W., "Approximating the Nondominated Front using the Pareto Archived Evolution Strategy," Evolutionary Computation, vol. 8, no. 2, pp. 149-172, 2000.
 - Knowles, J.D. and Corne, D.W., "Properties of an Adaptive Archiving for Storing Nondominated Vectors," IEEE Transactions on Evolutionary Computation, vol. 7, no. 2, pp. 100-116, 2003.
 
- 
Nested Class Summary
Nested classes/interfaces inherited from class org.moeaframework.core.population.NondominatedPopulation
NondominatedPopulation.DuplicateMode - 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intThe maximum capacity of this archive.The number of solutions in each grid cell.protected double[]The maximum objective value for each dimension.protected double[]The minimum objective value for each dimension.protected final intThe number of divisions this archive uses to split each objective.protected final ProblemThe problem for which this archive is used.Fields inherited from class org.moeaframework.core.population.NondominatedPopulation
comparator, duplicateMode - 
Constructor Summary
ConstructorsConstructorDescriptionAdaptiveGridArchive(int capacity, Problem problem, int numberOfDivisions) Constructs an adaptive grid archive with the specified capacity with the specified number of divisions along each objective. - 
Method Summary
Modifier and TypeMethodDescriptionprotected voidComputes new lower and upper bounds and recalculates the densities of each grid cell.booleanIfnewSolutionis dominates any solution or is non-dominated with all solutions in this population, the dominated solutions are removed andnewSolutionis added to this population.voidclear()Removes all solutions from this population.copy()Returns a copy of this population.protected intReturns the index of the grid cell with the largest density.intReturns the index of the specified solution in this adaptive grid archive, or-1if the solution is not within the current lower and upper bounds.intReturns the equivalent number of bisections to produce the number of divisions.intReturns the maximum number of solutions stored in this archive.intgetDensity(int index) Returns the density of the solution at the given index.static intgetMaximumBisections(int numberOfObjectives) Calculates the largest possible value for thebisectionsparameter.intReturns the number of divisions this archive uses to split each objective.Returns the problem for which this archive is used.voidloadState(ObjectInputStream stream) Loads the state of this object from the stream.protected SolutionReturns a solution residing in the densest grid cell.voidremove(int index) Removes the solution at the specified index from this population.booleanRemoves the specified solution from this population, if present.voidsaveState(ObjectOutputStream stream) Writes the state of this object to the stream.Methods inherited from class org.moeaframework.core.population.NondominatedPopulation
forceAddWithoutCheck, getComparator, getDuplicateMode, isDuplicate, load, load, load, replaceMethods inherited from class org.moeaframework.core.population.Population
addAll, addAll, asList, asTabularData, contains, containsAll, containsAll, filter, get, getLowerBounds, getUpperBounds, indexOf, isEmpty, iterator, removeAll, removeAll, removeAll, save, save, size, sort, truncateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.moeaframework.util.format.Displayable
displayMethods inherited from interface org.moeaframework.util.format.Formattable
display, display, display, save, save, saveMethods inherited from interface java.lang.Iterable
forEach, spliterator 
- 
Field Details
- 
capacity
protected final int capacityThe maximum capacity of this archive. - 
problem
The problem for which this archive is used. - 
numberOfDivisions
protected final int numberOfDivisionsThe number of divisions this archive uses to split each objective. - 
minimum
protected double[] minimumThe minimum objective value for each dimension. - 
maximum
protected double[] maximumThe maximum objective value for each dimension. - 
density
The number of solutions in each grid cell. 
 - 
 - 
Constructor Details
- 
AdaptiveGridArchive
Constructs an adaptive grid archive with the specified capacity with the specified number of divisions along each objective.- Parameters:
 capacity- the capacity of this archiveproblem- the problem for which this archive is usednumberOfDivisions- the number of divisions this archive uses to split each objective- Throws:
 FrameworkException- ifpow(numberOfDivisions, numberOfObjectives)exceeds the storage capacity of an array
 
 - 
 - 
Method Details
- 
getMaximumBisections
public static int getMaximumBisections(int numberOfObjectives) Calculates the largest possible value for thebisectionsparameter. This is limited by the available Java heap size and the maximum integer value (2^31-1), whichever is smaller.- Parameters:
 numberOfObjectives- the number of objectives- Returns:
 - the maximum number of bisections
 
 - 
getBisections
public int getBisections()Returns the equivalent number of bisections to produce the number of divisions.- Returns:
 - the number of bisections
 
 - 
getCapacity
public int getCapacity()Returns the maximum number of solutions stored in this archive.- Returns:
 - the maximum number of solutions stored in this archive
 
 - 
getNumberOfDivisions
public int getNumberOfDivisions()Returns the number of divisions this archive uses to split each objective.- Returns:
 - the number of divisions this archive uses to split each objective
 
 - 
getProblem
Returns the problem for which this archive is used.- Returns:
 - the problem for which this archive is used
 
 - 
add
Description copied from class:NondominatedPopulationIfnewSolutionis dominates any solution or is non-dominated with all solutions in this population, the dominated solutions are removed andnewSolutionis added to this population. Otherwise,newSolutionis dominated and is not added to this population.- Overrides:
 addin classNondominatedPopulation- Parameters:
 solution- the solution to be added- Returns:
 trueif the population was modified as a result of this method;falseotherwise.
 - 
remove
public void remove(int index) Description copied from class:PopulationRemoves the solution at the specified index from this population.- Overrides:
 removein classPopulation- Parameters:
 index- the index of the solution to be removed
 - 
remove
Description copied from class:PopulationRemoves the specified solution from this population, if present.- Overrides:
 removein classPopulation- Parameters:
 solution- the solution to be removed- Returns:
 trueif this population was modified as a result of this method;falseotherwise
 - 
clear
public void clear()Description copied from class:PopulationRemoves all solutions from this population.- Overrides:
 clearin classPopulation
 - 
findDensestCell
protected int findDensestCell()Returns the index of the grid cell with the largest density.- Returns:
 - the index of the grid cell with the largest density
 
 - 
pickSolutionFromDensestCell
Returns a solution residing in the densest grid cell. If there are more than one such solution or multiple cells with the same density, the first solution encountered is returned.- Returns:
 - a solution residing in the densest grid cell
 
 - 
adaptGrid
protected void adaptGrid()Computes new lower and upper bounds and recalculates the densities of each grid cell. - 
findIndex
Returns the index of the specified solution in this adaptive grid archive, or-1if the solution is not within the current lower and upper bounds.- Parameters:
 solution- the specified solution- Returns:
 - the index of the specified solution in this adaptive grid archive, or 
-1if the solution is not within the current lower and upper bounds 
 - 
getDensity
public int getDensity(int index) Returns the density of the solution at the given index.- Parameters:
 index- the solution index- Returns:
 - the density of the solution at the given index
 
 - 
copy
Description copied from class:PopulationReturns a copy of this population. This can be thought of as a "deep copy", which creates a copy of both the population itself and copies of the individual solutions in the population. Consequently, the returned copy is completely independent, such that any modifications to the contents or order will not impact the original.Since creating such a "deep copy" can be expensive, prefer using the constructor
Population(Iterable)orPopulation.addAll(Iterable)whenever possible. These alternatives are useful when filtering or reordering the solutions, but the solutions themselves are left unchanged.- Specified by:
 copyin interfaceCopyable<Population>- Overrides:
 copyin classNondominatedPopulation- Returns:
 - the copy of this population
 
 - 
saveState
Description copied from interface:StatefulWrites the state of this object to the stream. The order that objects are written to the stream is important. We recommend first callingsuper.saveState(stream)followed by writing each field.- Specified by:
 saveStatein interfaceStateful- Overrides:
 saveStatein classPopulation- Parameters:
 stream- the stream- Throws:
 IOException- if an I/O error occurred
 - 
loadState
Description copied from interface:StatefulLoads the state of this object from the stream. The order for reading objects from the stream must match the order they are written to the stream inStateful.saveState(ObjectOutputStream).- Specified by:
 loadStatein interfaceStateful- Overrides:
 loadStatein classPopulation- Parameters:
 stream- the stream- Throws:
 IOException- if an I/O error occurredClassNotFoundException- if the stream referenced a class that is not defined
 
 -