Package org.opt4j.common.archive
Class BoundedArchive
- java.lang.Object
-
- org.opt4j.core.IndividualSet
-
- org.opt4j.core.optimizer.Archive
-
- org.opt4j.common.archive.AbstractArchive
-
- org.opt4j.common.archive.BoundedArchive
-
- All Implemented Interfaces:
Iterable<Individual>,Collection<Individual>,Set<Individual>
- Direct Known Subclasses:
AdaptiveGridArchive,CrowdingArchive
public abstract class BoundedArchive extends AbstractArchive
AnArchivewith bounded size.
-
-
Field Summary
Fields Modifier and Type Field Description protected intcapacityThe capacity of thisArchive-
Fields inherited from class org.opt4j.core.IndividualSet
individuals, listeners
-
-
Constructor Summary
Constructors Constructor Description BoundedArchive(int capacity)Constructs a bounded archive with the specified capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddCheckedIndividual(Individual individual)Adds theIndividualto thisArchivewithout further checks.booleanaddCheckedIndividuals(Collection<? extends Individual> c)Adds theIndividuals to thisArchivewithout further checks.intgetCapacity()Returns the capacity of thisBoundedArchive.voidsetCapacity(int capacity)Sets the capacity of thisBoundedArchive.-
Methods inherited from class org.opt4j.common.archive.AbstractArchive
update, updateWithNondominated
-
Methods inherited from class org.opt4j.core.IndividualSet
addListener, clear, contains, containsAll, isEmpty, iterator, remove, 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
-
capacity
protected int capacity
The capacity of thisArchive
-
-
Method Detail
-
setCapacity
public void setCapacity(int capacity)
Sets the capacity of thisBoundedArchive.- Parameters:
capacity- new capacity of this bounded archive- See Also:
getCapacity()
-
getCapacity
public int getCapacity()
Returns the capacity of thisBoundedArchive.- Returns:
- capacity of this bounded archive
- See Also:
setCapacity(int)
-
addCheckedIndividual
public boolean addCheckedIndividual(Individual individual)
Description copied from class:ArchiveAdds theIndividualto thisArchivewithout further checks. Must be used only if theIndividualis checked to be Pareto-dominant and, according to possible archive size restrictions, can be added to thisArchive.- Overrides:
addCheckedIndividualin classArchive- Parameters:
individual- the individual to be actually added to the archive- Returns:
- true
- Throws:
IndexOutOfBoundsException- if the capacity is reached.
-
addCheckedIndividuals
public boolean addCheckedIndividuals(Collection<? extends Individual> c)
Description copied from class:ArchiveAdds theIndividuals to thisArchivewithout further checks. Must be used only if theIndividuals are checked to be Pareto-dominant and, according to possible archive size restrictions, can all be added to thisArchive.- Overrides:
addCheckedIndividualsin classArchive- Parameters:
c- the individuals to be actually added to the archive- Returns:
- true
- Throws:
IndexOutOfBoundsException- if the capacity is reached.
-
-