org.opt4j.core.common.archive
Class BoundedArchive

java.lang.Object
  extended by org.opt4j.core.IndividualSet
      extended by org.opt4j.core.optimizer.Archive
          extended by org.opt4j.core.common.archive.AbstractArchive
              extended by org.opt4j.core.common.archive.BoundedArchive
All Implemented Interfaces:
java.lang.Iterable<Individual>, java.util.Collection<Individual>, java.util.Set<Individual>
Direct Known Subclasses:
AdaptiveGridArchive, CrowdingArchive

public abstract class BoundedArchive
extends AbstractArchive

An Archive with bounded size.


Field Summary
protected  int capacity
          The capacity of this Archive
 
Fields inherited from class org.opt4j.core.IndividualSet
individuals, listeners
 
Constructor Summary
BoundedArchive(int capacity)
          Constructs a bounded archive with the specified capacity.
 
Method Summary
 boolean addCheckedIndividual(Individual individual)
          Adds the Individual to this Archive without further checks.
 boolean addCheckedIndividuals(java.util.Collection<? extends Individual> c)
          Adds the Individuals to this Archive without further checks.
 int getCapacity()
          Returns the capacity of this BoundedArchive.
 void setCapacity(int capacity)
          Sets the capacity of this BoundedArchive.
 
Methods inherited from class org.opt4j.core.common.archive.AbstractArchive
update, updateWithNondominated
 
Methods inherited from class org.opt4j.core.optimizer.Archive
update
 
Methods inherited from class org.opt4j.core.IndividualSet
add, addAll, addAll, 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.Set
equals, hashCode
 

Field Detail

capacity

protected int capacity
The capacity of this Archive

Constructor Detail

BoundedArchive

@Inject
public BoundedArchive(int capacity)
Constructs a bounded archive with the specified capacity.

Parameters:
capacity - Capacity of this archive
Method Detail

setCapacity

public void setCapacity(int capacity)
Sets the capacity of this BoundedArchive.

Parameters:
capacity - new capacity of this bounded archive
See Also:
getCapacity()

getCapacity

public int getCapacity()
Returns the capacity of this BoundedArchive.

Returns:
capacity of this bounded archive
See Also:
setCapacity(int)

addCheckedIndividual

public boolean addCheckedIndividual(Individual individual)
Description copied from class: Archive
Adds the Individual to this Archive without further checks. Must be used only if the Individual is checked to be Pareto-dominant and, according to possible archive size restrictions, can be added to this Archive.

Overrides:
addCheckedIndividual in class Archive
Parameters:
individual - the individual to be actually added to the archive
Returns:
true
Throws:
java.lang.IndexOutOfBoundsException - if the capacity is reached.

addCheckedIndividuals

public boolean addCheckedIndividuals(java.util.Collection<? extends Individual> c)
Description copied from class: Archive
Adds the Individuals to this Archive without further checks. Must be used only if the Individuals are checked to be Pareto-dominant and, according to possible archive size restrictions, can all be added to this Archive.

Overrides:
addCheckedIndividuals in class Archive
Parameters:
c - the individuals to be actually added to the archive
Returns:
true
Throws:
java.lang.IndexOutOfBoundsException - if the capacity is reached.