public class AdaptiveGridArchive extends NondominatedPopulation
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:
NondominatedPopulation.DuplicateMode
Modifier and Type | Field and Description |
---|---|
protected int |
capacity
The maximum capacity of this archive.
|
protected int[] |
density
The number of solutions in each grid cell.
|
protected double[] |
maximum
The maximum objective value for each dimension.
|
protected double[] |
minimum
The minimum objective value for each dimension.
|
protected int |
numberOfDivisions
The number of divisions this archive uses to split each objective.
|
protected Problem |
problem
The problem for which this archive is used.
|
comparator, duplicateMode
Constructor and Description |
---|
AdaptiveGridArchive(int capacity,
Problem problem,
int numberOfDivisions)
Constructs an adaptive grid archive with the specified capacity with the
specified number of divisions along each objective.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adaptGrid()
Computes new lower and upper bounds and recalculates the densities of
each grid cell.
|
boolean |
add(Solution solution)
If
newSolution is dominates any solution or is non-dominated with
all solutions in this population, the dominated solutions are removed and
newSolution is added to this population. |
void |
clear()
Removes all solutions from this population.
|
protected int |
findDensestCell()
Returns the index of the grid cell with the largest density.
|
int |
findIndex(Solution solution)
Returns the index of the specified solution in this adaptive grid
archive, or
-1 if the solution is not within the current lower
and upper bounds. |
int |
getBisections()
Returns the equivalent number of bisections to produce the number of divisions.
|
int |
getCapacity()
Returns the maximum number of solutions stored in this archive.
|
int |
getDensity(int index)
Returns the density of the solution at the given index.
|
static int |
getMaximumBisections(int numberOfObjectives)
Calculates the largest possible value for the
bisections parameter. |
int |
getNumberOfDivisions()
Returns the number of divisions this archive uses to split each objective.
|
Problem |
getProblem()
Returns the problem for which this archive is used.
|
void |
loadState(java.io.ObjectInputStream stream)
Loads the state of this object from the stream.
|
protected Solution |
pickSolutionFromDensestCell()
Returns a solution residing in the densest grid cell.
|
void |
remove(int index)
Removes the solution at the specified index from this population.
|
boolean |
remove(Solution solution)
Removes the specified solution from this population, if present.
|
void |
saveState(java.io.ObjectOutputStream stream)
Writes the state of this object to the stream.
|
forceAddWithoutCheck, getComparator, isDuplicate, replace
addAll, addAll, asList, asList, asTabularData, contains, containsAll, containsAll, get, indexOf, isEmpty, iterator, removeAll, removeAll, size, sort, truncate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
display, saveCSV
display
checkTypeSafety, getState, setState, writeTypeSafety
protected final int capacity
protected final Problem problem
protected final int numberOfDivisions
protected double[] minimum
protected double[] maximum
protected int[] density
public AdaptiveGridArchive(int capacity, Problem problem, int numberOfDivisions)
capacity
- the capacity of this archiveproblem
- the problem for which this archive is usednumberOfDivisions
- the number of divisions this archive uses to
split each objectiveFrameworkException
- if
pow(numberOfDivisions, numberOfObjectives)
exceeds the
storage capacity of an arraypublic static int getMaximumBisections(int numberOfObjectives)
bisections
parameter. This is limited by
the available Java heap size and the maximum integer value (2^31-1), whichever is smaller.numberOfObjectives
- the number of objectivespublic int getBisections()
public int getCapacity()
public int getNumberOfDivisions()
public Problem getProblem()
public boolean add(Solution solution)
NondominatedPopulation
newSolution
is dominates any solution or is non-dominated with
all solutions in this population, the dominated solutions are removed and
newSolution
is added to this population. Otherwise,
newSolution
is dominated and is not added to this population.add
in class NondominatedPopulation
solution
- the solution to be addedtrue
if the population was modified as a result of this method; false
otherwise.public void remove(int index)
Population
remove
in class Population
index
- the index of the solution to be removedpublic boolean remove(Solution solution)
Population
remove
in class Population
solution
- the solution to be removedtrue
if this population was modified as a result of this method; false
otherwisepublic void clear()
Population
clear
in class Population
protected int findDensestCell()
protected Solution pickSolutionFromDensestCell()
protected void adaptGrid()
public int findIndex(Solution solution)
-1
if the solution is not within the current lower
and upper bounds.solution
- the specified solution-1
if the solution is not within the current
lower and upper boundspublic int getDensity(int index)
index
- the solution indexpublic void saveState(java.io.ObjectOutputStream stream) throws java.io.IOException
Stateful
super.saveState(stream)
followed by writing each
field.saveState
in interface Stateful
saveState
in class Population
stream
- the streamjava.io.IOException
- if an I/O error occurredpublic void loadState(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Stateful
Stateful.saveState(ObjectOutputStream)
.loadState
in interface Stateful
loadState
in class Population
stream
- the streamjava.io.IOException
- if an I/O error occurredjava.lang.ClassNotFoundException
- if the stream referenced a class that is not definedCopyright 2009-2024 David Hadka and other contributors. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage.