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
AnArchive
with bounded size.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
capacity
The 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 boolean
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
getCapacity()
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 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: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
public boolean addCheckedIndividuals(Collection<? extends Individual> c)
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.
-
-