messif.pivotselection
Class ClusterPivotChooser

java.lang.Object
  extended by messif.pivotselection.AbstractPivotChooser
      extended by messif.pivotselection.ClusterPivotChooser
All Implemented Interfaces:
java.io.Serializable, BucketFilter, BucketFilterAfterAdd, BucketFilterAfterRemove

public class ClusterPivotChooser
extends AbstractPivotChooser
implements java.io.Serializable, BucketFilterAfterAdd, BucketFilterAfterRemove

This pivot chooser selects a varying number of pivots based on cluster sizes which are limited by the parameter passed to the constructor. Clustering of the sample set is done by creating as compact clusters as possible. The cluster radius (maximum distance within the cluster for the cluster's centroid) is less than the threshold passed in the constructor. The clusteriods (pivots, centers of clusters) are selected as the objects having lowest sum of distances to all other objects in the cluster. CAVEAT: This pivot chooser ignores the parameter count passed in all selectPivot(int, messif.objects.util.AbstractObjectIterator) methods.

See Also:
Serialized Form

Nested Class Summary
protected  class ClusterPivotChooser.Cluster
          Class encapsulating objects of one cluster and storing the cluster's radius.
protected  class ClusterPivotChooser.Pair
          Class encapsulating two clusters and the diameters of a cluster that would be produced be merging these clusters.
protected  class ClusterPivotChooser.PrecomputedDistances
          A cache for distances between a pair of objects
 
Field Summary
protected  float maxClusterRadius
          Threshold on the maximum distance within a single cluster.
static int SAMPLE_SET_SIZE
          Size of the data sample used to create clusters.
 
Fields inherited from class messif.pivotselection.AbstractPivotChooser
counterBucketReadBuckets, counterObjectDistComp, counterPivotDistComp, counterPivotReadBuckets, preselectedPivots, sampleProviders
 
Constructor Summary
ClusterPivotChooser(float radius)
          Creates a new instance of ClusterPivotChooser.
 
Method Summary
 void filterAfterAdd(LocalAbstractObject object, LocalBucket bucket)
          Filter object after its insertion into a bucket.
 void filterAfterRemove(LocalAbstractObject object, LocalBucket bucket)
          Filter object after its removal from a bucket.
protected  void selectPivot(int count, AbstractObjectIterator<? extends LocalAbstractObject> sampleSetIterator)
          This method carries out the actual pivot selection and must be implemented by subclasses.
 
Methods inherited from class messif.pivotselection.AbstractPivotChooser
addPivot, clear, deregisterSampleProvider, getLastPivot, getNextPivot, getPivot, getPivot, iterator, registerSampleProvider, removeLastPivot, selectPivot, selectPivot, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAMPLE_SET_SIZE

public static int SAMPLE_SET_SIZE
Size of the data sample used to create clusters.


maxClusterRadius

protected float maxClusterRadius
Threshold on the maximum distance within a single cluster.

Constructor Detail

ClusterPivotChooser

public ClusterPivotChooser(float radius)
Creates a new instance of ClusterPivotChooser.

Parameters:
radius - maximum radius of cluster created
Method Detail

selectPivot

protected void selectPivot(int count,
                           AbstractObjectIterator<? extends LocalAbstractObject> sampleSetIterator)
Description copied from class: AbstractPivotChooser
This method carries out the actual pivot selection and must be implemented by subclasses. The implementation must select at least count pitvots and add them by addPivot method.

Specified by:
selectPivot in class AbstractPivotChooser
Parameters:
count - Number of pivots to generate
sampleSetIterator - Iterator over the sample set of objects to choose new pivots from

filterAfterAdd

public void filterAfterAdd(LocalAbstractObject object,
                           LocalBucket bucket)
Description copied from interface: BucketFilterAfterAdd
Filter object after its insertion into a bucket.

Specified by:
filterAfterAdd in interface BucketFilterAfterAdd
Parameters:
object - the inserted object
bucket - bucket, where the object is stored

filterAfterRemove

public void filterAfterRemove(LocalAbstractObject object,
                              LocalBucket bucket)
Description copied from interface: BucketFilterAfterRemove
Filter object after its removal from a bucket.

Specified by:
filterAfterRemove in interface BucketFilterAfterRemove
Parameters:
object - the removed object
bucket - bucket, where the object has been stored