Class HACAM.Instance

  • Enclosing class:
    HACAM<O>

    public static class HACAM.Instance
    extends Anderberg.Instance
    Main worker instance of AGNES.
    Author:
    Erich Schubert
    • 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)
    • Constructor Detail

      • Instance

        public Instance​(HACAM.Variant variant)
        Constructor.
        Parameters:
        variant - HACAM variant to use
    • Method Detail

      • findMerge

        protected int findMerge()
        Description copied from class: Anderberg.Instance
        Perform the next merge step.

        Due to the cache, this is now O(n) each time, instead of O(n*n).

        Overrides:
        findMerge in class Anderberg.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, with x > y
        y - second cluster to merge, with y < 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, with x > y
        y - second cluster to merge, with y < x
      • updateEntry

        protected void updateEntry​(int x,
                                   int y)
        Update entry at x,y for distance matrix distances
        Parameters:
        x - index of cluster, x > y
        y - 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 query
        cx - First set
        cy - Second set
        prototype - Prototype output variable
        minDistSum - 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 query
        cx - First set
        cy - Singleton object
        prototype - 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 query
        i - Current object
        cy - Set of candidates
        distsum - Current sum
        minDistSum - Early stopping threshold
        Returns:
        Distance sum