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
Fields inherited from class org.opt4j.core.IndividualSet
individuals, listeners
-
Constructor Summary
ConstructorDescriptionBoundedArchive
(int capacity) Constructs a bounded archive with the specified capacity. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addCheckedIndividual
(Individual individual) Adds theIndividual
to thisArchive
without further checks.boolean
addCheckedIndividuals
(Collection<? extends Individual> c) Adds theIndividual
s to thisArchive
without further checks.int
Returns the capacity of thisBoundedArchive
.void
setCapacity
(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 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:Archive
Adds theIndividual
to thisArchive
without further checks. Must be used only if theIndividual
is checked to be Pareto-dominant and, according to possible archive size restrictions, can be added to thisArchive
.- Overrides:
addCheckedIndividual
in 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:Archive
Adds theIndividual
s to thisArchive
without further checks. Must be used only if theIndividual
s are checked to be Pareto-dominant and, according to possible archive size restrictions, can all be added to thisArchive
.- Overrides:
addCheckedIndividuals
in classArchive
- Parameters:
c
- the individuals to be actually added to the archive- Returns:
- true
- Throws:
IndexOutOfBoundsException
- if the capacity is reached.
-