Package org.opt4j.common.archive
Class AdaptiveGridArchive
- java.lang.Object
-
- org.opt4j.core.IndividualSet
-
- org.opt4j.core.optimizer.Archive
-
- org.opt4j.common.archive.AbstractArchive
-
- org.opt4j.common.archive.BoundedArchive
-
- org.opt4j.common.archive.AdaptiveGridArchive
-
- All Implemented Interfaces:
Iterable<Individual>
,Collection<Individual>
,Set<Individual>
public class AdaptiveGridArchive extends BoundedArchive
TheAdaptiveGridArchive
uses an adaptive grid in order to bound the size of theArchive
.- See Also:
- "Properties of an Adaptive Archiving Algorithm for Storing Nondominated Vectors, J. Knowles, D. Corne, Transactions of Evolutionary Computation, Vol. 7, No. 2, April 2003"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AdaptiveGridArchive.Cell
A singleAdaptiveGridArchive.Cell
of the grid.
-
Field Summary
Fields Modifier and Type Field Description protected Map<Long,AdaptiveGridArchive.Cell>
cells
protected int
dim
protected int
div
protected List<Individual>
extrema
protected boolean
isInit
protected double[]
lb
protected Rand
random
protected double[]
ub
-
Fields inherited from class org.opt4j.common.archive.BoundedArchive
capacity
-
Fields inherited from class org.opt4j.core.IndividualSet
individuals, listeners
-
-
Constructor Summary
Constructors Constructor Description AdaptiveGridArchive(int capacity, int div, Rand random)
Constructs anAdaptiveGridArchive
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToCell(Iterable<Individual> individuals)
Adds allIndividual
s to theirsAdaptiveGridArchive.Cell
s and theAdaptiveGridArchive.Cell
s to thecore.optimizer.Archive
.protected boolean
determineBounds(Collection<Individual> individuals)
Determines the new bounds for the individuals and returnstrue
if the bounds have changed.protected AdaptiveGridArchive.Cell
getCell(Individual individual)
Returns the appropriateAdaptiveGridArchive.Cell
for the givenIndividual
.protected AdaptiveGridArchive.Cell
getMostCrowdedCell()
Returns the most crowdedAdaptiveGridArchive.Cell
.protected void
init(Individual individual)
Initialize theArchive
.boolean
remove(Object o)
protected void
removeFromCell(Individual individual)
Removes thisIndividual
from itsAdaptiveGridArchive.Cell
and removes theAdaptiveGridArchive.Cell
from theArchive
if it is empty.protected boolean
updateWithNondominated(Collection<Individual> candidates)
Adds newcandidates
which are already checked to be not Pareto-dominated by any other individual in thisArchive
.-
Methods inherited from class org.opt4j.common.archive.BoundedArchive
addCheckedIndividual, addCheckedIndividuals, getCapacity, setCapacity
-
Methods inherited from class org.opt4j.common.archive.AbstractArchive
update
-
Methods inherited from class org.opt4j.core.IndividualSet
addListener, clear, contains, containsAll, isEmpty, iterator, removeAll, removeListener, retainAll, size, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
-
-
-
Field Detail
-
isInit
protected boolean isInit
-
div
protected final int div
-
random
protected final Rand random
-
cells
protected final Map<Long,AdaptiveGridArchive.Cell> cells
-
extrema
protected final List<Individual> extrema
-
lb
protected double[] lb
-
ub
protected double[] ub
-
dim
protected int dim
-
-
Constructor Detail
-
AdaptiveGridArchive
@Inject public AdaptiveGridArchive(int capacity, int div, Rand random)
Constructs anAdaptiveGridArchive
.- Parameters:
capacity
- the capacitydiv
- the divisionsrandom
- the random number generator
-
-
Method Detail
-
updateWithNondominated
protected boolean updateWithNondominated(Collection<Individual> candidates)
Description copied from class:AbstractArchive
Adds newcandidates
which are already checked to be not Pareto-dominated by any other individual in thisArchive
. AllIndividual
s in theArchive
which were dominated by the candidates have already been removed.- Specified by:
updateWithNondominated
in classAbstractArchive
- Parameters:
candidates
- the non-dominated individuals which can be added- Returns:
- true if one or more candidates are added to the archive
-
init
protected void init(Individual individual)
Initialize theArchive
.- Parameters:
individual
- one random individual
-
getCell
protected AdaptiveGridArchive.Cell getCell(Individual individual)
Returns the appropriateAdaptiveGridArchive.Cell
for the givenIndividual
.- Parameters:
individual
- the individual- Returns:
- the cell
-
getMostCrowdedCell
protected AdaptiveGridArchive.Cell getMostCrowdedCell()
Returns the most crowdedAdaptiveGridArchive.Cell
.- Returns:
- the most crowded cell
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<Individual>
- Specified by:
remove
in interfaceSet<Individual>
- Overrides:
remove
in classIndividualSet
-
addToCell
protected void addToCell(Iterable<Individual> individuals)
Adds allIndividual
s to theirsAdaptiveGridArchive.Cell
s and theAdaptiveGridArchive.Cell
s to thecore.optimizer.Archive
.- Parameters:
individuals
- the individuals to be added
-
removeFromCell
protected void removeFromCell(Individual individual)
Removes thisIndividual
from itsAdaptiveGridArchive.Cell
and removes theAdaptiveGridArchive.Cell
from theArchive
if it is empty.- Parameters:
individual
- the individual to be removed
-
determineBounds
protected boolean determineBounds(Collection<Individual> individuals)
Determines the new bounds for the individuals and returnstrue
if the bounds have changed.- Parameters:
individuals
- the individuals- Returns:
true
if the bounds have changed
-
-