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
An
Archive with bounded size.-
Field Summary
FieldsFields inherited from class org.opt4j.core.IndividualSet
individuals, listeners -
Constructor Summary
ConstructorsConstructorDescriptionBoundedArchive(int capacity) Constructs a bounded archive with the specified capacity. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddCheckedIndividual(Individual individual) Adds theIndividualto thisArchivewithout further checks.booleanaddCheckedIndividuals(Collection<? extends Individual> c) Adds theIndividuals to thisArchivewithout further checks.intReturns the capacity of thisBoundedArchive.voidsetCapacity(int capacity) Sets the capacity of thisBoundedArchive.Methods inherited from class org.opt4j.common.archive.AbstractArchive
update, updateWithNondominatedMethods inherited from class org.opt4j.core.IndividualSet
addListener, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeListener, retainAll, size, toArray, toArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Field Details
-
capacity
protected int capacityThe capacity of thisArchive
-
-
Constructor Details
-
BoundedArchive
@Inject public BoundedArchive(int capacity) Constructs a bounded archive with the specified capacity.- Parameters:
capacity- Capacity of this archive
-
-
Method Details
-
setCapacity
public void setCapacity(int capacity) Sets the capacity of thisBoundedArchive.- Parameters:
capacity- new capacity of this bounded archive- See Also:
-
getCapacity
public int getCapacity()Returns the capacity of thisBoundedArchive.- Returns:
- capacity of this bounded archive
- See Also:
-
addCheckedIndividual
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
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.
-