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
TheAdaptiveGridArchiveuses 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 classAdaptiveGridArchive.CellA singleAdaptiveGridArchive.Cellof the grid.
-
Field Summary
Fields Modifier and Type Field Description protected Map<Long,AdaptiveGridArchive.Cell>cellsprotected intdimprotected intdivprotected List<Individual>extremaprotected booleanisInitprotected double[]lbprotected Randrandomprotected 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 voidaddToCell(Iterable<Individual> individuals)Adds allIndividuals to theirsAdaptiveGridArchive.Cells and theAdaptiveGridArchive.Cells to thecore.optimizer.Archive.protected booleandetermineBounds(Collection<Individual> individuals)Determines the new bounds for the individuals and returnstrueif the bounds have changed.protected AdaptiveGridArchive.CellgetCell(Individual individual)Returns the appropriateAdaptiveGridArchive.Cellfor the givenIndividual.protected AdaptiveGridArchive.CellgetMostCrowdedCell()Returns the most crowdedAdaptiveGridArchive.Cell.protected voidinit(Individual individual)Initialize theArchive.booleanremove(Object o)protected voidremoveFromCell(Individual individual)Removes thisIndividualfrom itsAdaptiveGridArchive.Celland removes theAdaptiveGridArchive.Cellfrom theArchiveif it is empty.protected booleanupdateWithNondominated(Collection<Individual> candidates)Adds newcandidateswhich 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:AbstractArchiveAdds newcandidateswhich are already checked to be not Pareto-dominated by any other individual in thisArchive. AllIndividuals in theArchivewhich were dominated by the candidates have already been removed.- Specified by:
updateWithNondominatedin 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.Cellfor 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:
removein interfaceCollection<Individual>- Specified by:
removein interfaceSet<Individual>- Overrides:
removein classIndividualSet
-
addToCell
protected void addToCell(Iterable<Individual> individuals)
Adds allIndividuals to theirsAdaptiveGridArchive.Cells and theAdaptiveGridArchive.Cells to thecore.optimizer.Archive.- Parameters:
individuals- the individuals to be added
-
removeFromCell
protected void removeFromCell(Individual individual)
Removes thisIndividualfrom itsAdaptiveGridArchive.Celland removes theAdaptiveGridArchive.Cellfrom theArchiveif 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 returnstrueif the bounds have changed.- Parameters:
individuals- the individuals- Returns:
trueif the bounds have changed
-
-