Package elki.clustering.hierarchical
Class HACAM.Instance
- java.lang.Object
 - 
- elki.clustering.hierarchical.AGNES.Instance
 - 
- elki.clustering.hierarchical.Anderberg.Instance
 - 
- elki.clustering.hierarchical.HACAM.Instance
 
 
 
 
- 
public static class HACAM.Instance extends Anderberg.Instance
Main worker instance of AGNES.- Author:
 - Erich Schubert
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<ModifiableDBIDs>clustersCluster to members mapprotected DistanceQuery<?>dqDistance queryprotected DBIDArrayIterixIterators into the object ids.protected DBIDArrayIteriyIterators into the object ids.protected DBIDArrayMIterprotsIterator into the prototypesprotected double[]tdsTotal deviations (for minimum sum increase only)protected HACAM.VariantvariantLinkage variant to use- 
Fields inherited from class elki.clustering.hierarchical.Anderberg.Instance
bestd, besti 
- 
Fields inherited from class elki.clustering.hierarchical.AGNES.Instance
builder, end, linkage, mat 
 - 
 
- 
Constructor Summary
Constructors Constructor Description Instance(HACAM.Variant variant)Constructor. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static doubledistanceSum(DistanceQuery<?> dq, DBIDIter i, DBIDs cy, double distsum, double minDistSum)Find the maximum distance of one object to a set.protected intfindMerge()Perform the next merge step.private static doublefindPrototype(DistanceQuery<?> dq, DBIDs cx, DBIDs cy, DBIDVar prototype, double minDistSum)Find the prototypes.private static doublefindPrototypeSingleton(DistanceQuery<?> dq, DBIDs cx, DBIDRef cy, DBIDVar prototype)Find the prototypes.protected voidmerge(int x, int y)Execute the cluster merge.ClusterMergeHistoryrun(ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder)Run the main algorithm.ClusterPrototypeMergeHistoryrun(ArrayDBIDs ids, ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder, DistanceQuery<?> dq, DBIDArrayMIter prots)Run HACAM linkageprotected voidupdateEntry(int x, int y)Update entry at x,y for distance matrix distancesprivate voidupdateMatrices(int x, int y)Update the entries of the matrices that contain a distance to y, the newly merged cluster.- 
Methods inherited from class elki.clustering.hierarchical.Anderberg.Instance
findBest, initializeNNCache, merge, updateCache, updateMatrix 
- 
Methods inherited from class elki.clustering.hierarchical.AGNES.Instance
shrinkActiveSet 
 - 
 
 - 
 
- 
- 
Field Detail
- 
variant
protected HACAM.Variant variant
Linkage variant to use 
- 
clusters
protected it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<ModifiableDBIDs> clusters
Cluster to members map 
- 
tds
protected double[] tds
Total deviations (for minimum sum increase only) 
- 
dq
protected DistanceQuery<?> dq
Distance query 
- 
prots
protected DBIDArrayMIter prots
Iterator into the prototypes 
- 
ix
protected DBIDArrayIter ix
Iterators into the object ids. 
- 
iy
protected DBIDArrayIter iy
Iterators into the object ids. 
 - 
 
- 
Constructor Detail
- 
Instance
public Instance(HACAM.Variant variant)
Constructor.- Parameters:
 variant- HACAM variant to use
 
 - 
 
- 
Method Detail
- 
run
public ClusterMergeHistory run(ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder)
Description copied from class:AGNES.InstanceRun the main algorithm.- Overrides:
 runin classAnderberg.Instance- Parameters:
 mat- Distance matrixbuilder- Result builder- Returns:
 - Cluster history
 
 
- 
run
public ClusterPrototypeMergeHistory run(ArrayDBIDs ids, ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder, DistanceQuery<?> dq, DBIDArrayMIter prots)
Run HACAM linkage- Parameters:
 ids- Object idsmat- Distance matrixbuilder- Result builderdq- Distance queryprots- Iterator into prototypes- Returns:
 - Cluster merge history
 
 
- 
findMerge
protected int findMerge()
Description copied from class:Anderberg.InstancePerform the next merge step.Due to the cache, this is now O(n) each time, instead of O(n*n).
- Overrides:
 findMergein classAnderberg.Instance- Returns:
 - x, for shrinking the working set.
 
 
- 
merge
protected void merge(int x, int y)Execute the cluster merge.- Parameters:
 x- first cluster to merge, withx > yy- second cluster to merge, withy < x
 
- 
updateMatrices
private void updateMatrices(int x, int y)Update the entries of the matrices that contain a distance to y, the newly merged cluster.- Parameters:
 x- first cluster to merge, withx > yy- second cluster to merge, withy < x
 
- 
updateEntry
protected void updateEntry(int x, int y)Update entry at x,y for distance matrix distances- Parameters:
 x- index of cluster,x > yy- index of cluster,y < x
 
- 
findPrototype
private static double findPrototype(DistanceQuery<?> dq, DBIDs cx, DBIDs cy, DBIDVar prototype, double minDistSum)
Find the prototypes.- Parameters:
 dq- Distance querycx- First setcy- Second setprototype- Prototype output variableminDistSum- Previously best distance.- Returns:
 - New best distance
 
 
- 
findPrototypeSingleton
private static double findPrototypeSingleton(DistanceQuery<?> dq, DBIDs cx, DBIDRef cy, DBIDVar prototype)
Find the prototypes.- Parameters:
 dq- Distance querycx- First setcy- Singleton objectprototype- Prototype output variable- Returns:
 - New best distance
 
 
- 
distanceSum
private static double distanceSum(DistanceQuery<?> dq, DBIDIter i, DBIDs cy, double distsum, double minDistSum)
Find the maximum distance of one object to a set.- Parameters:
 dq- Distance queryi- Current objectcy- Set of candidatesdistsum- Current summinDistSum- Early stopping threshold- Returns:
 - Distance sum
 
 
 - 
 
 -