Search in sources :

Example 1 with CASHIntervalSplit

use of de.lmu.ifi.dbs.elki.algorithm.clustering.correlation.cash.CASHIntervalSplit in project elki by elki-project.

the class CASH method initHeap.

/**
 * Initializes the heap with the root intervals.
 *
 * @param heap the heap to be initialized
 * @param relation the database storing the parameterization functions
 * @param dim the dimensionality of the database
 * @param ids the ids of the database
 */
private void initHeap(ObjectHeap<IntegerPriorityObject<CASHInterval>> heap, Relation<ParameterizationFunction> relation, int dim, DBIDs ids) {
    CASHIntervalSplit split = new CASHIntervalSplit(relation, minPts);
    // determine minimum and maximum function value of all functions
    double[] minMax = determineMinMaxDistance(relation, dim);
    double d_min = minMax[0], d_max = minMax[1];
    double dIntervalLength = d_max - d_min;
    int numDIntervals = (int) FastMath.ceil(dIntervalLength / jitter);
    double dIntervalSize = dIntervalLength / numDIntervals;
    double[] d_mins = new double[numDIntervals], d_maxs = new double[numDIntervals];
    if (LOG.isVerbose()) {
        LOG.verbose(// 
        new StringBuilder().append("d_min ").append(d_min).append("\nd_max ").append(// 
        d_max).append("\nnumDIntervals ").append(// 
        numDIntervals).append("\ndIntervalSize ").append(dIntervalSize).toString());
    }
    // alpha intervals
    double[] alphaMin = new double[dim - 1], alphaMax = new double[dim - 1];
    Arrays.fill(alphaMax, Math.PI);
    for (int i = 0; i < numDIntervals; i++) {
        d_mins[i] = (i == 0) ? d_min : d_maxs[i - 1];
        d_maxs[i] = (i < numDIntervals - 1) ? d_mins[i] + dIntervalSize : d_max - d_mins[i];
        HyperBoundingBox alphaInterval = new HyperBoundingBox(alphaMin, alphaMax);
        ModifiableDBIDs intervalIDs = split.determineIDs(ids, alphaInterval, d_mins[i], d_maxs[i]);
        if (intervalIDs != null && intervalIDs.size() >= minPts) {
            CASHInterval rootInterval = new CASHInterval(alphaMin, alphaMax, split, intervalIDs, -1, 0, d_mins[i], d_maxs[i]);
            heap.add(new IntegerPriorityObject<>(rootInterval.priority(), rootInterval));
        }
    }
    if (LOG.isDebuggingFiner()) {
        LOG.debugFiner(new StringBuilder().append("heap.size: ").append(heap.size()).toString());
    }
}
Also used : CASHInterval(de.lmu.ifi.dbs.elki.algorithm.clustering.correlation.cash.CASHInterval) CASHIntervalSplit(de.lmu.ifi.dbs.elki.algorithm.clustering.correlation.cash.CASHIntervalSplit) ModifiableDBIDs(de.lmu.ifi.dbs.elki.database.ids.ModifiableDBIDs)

Aggregations

CASHInterval (de.lmu.ifi.dbs.elki.algorithm.clustering.correlation.cash.CASHInterval)1 CASHIntervalSplit (de.lmu.ifi.dbs.elki.algorithm.clustering.correlation.cash.CASHIntervalSplit)1 ModifiableDBIDs (de.lmu.ifi.dbs.elki.database.ids.ModifiableDBIDs)1