final int dim = DatabaseUtil.dimensionality(relation);
// init heap
Heap<IntegerPriorityObject<CASHInterval>> heap = new Heap<IntegerPriorityObject<CASHInterval>>();
ModifiableDBIDs noiseIDs = DBIDUtil.newHashSet(relation.getDBIDs());
initHeap(heap, relation, dim, noiseIDs);
if(logger.isDebugging()) {
StringBuffer msg = new StringBuffer();
msg.append("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
msg.append("\nXXXX dim ").append(dim);
msg.append("\nXXXX database.size ").append(relation.size());
msg.append("\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
logger.debugFine(msg.toString());
}
else if(logger.isVerbose()) {
StringBuffer msg = new StringBuffer();
msg.append("XXXX dim ").append(dim).append(" database.size ").append(relation.size());
logger.verbose(msg.toString());
}
// get the ''best'' d-dimensional intervals at max level
while(!heap.isEmpty()) {
CASHInterval interval = determineNextIntervalAtMaxLevel(heap);
if(logger.isDebugging()) {
logger.debugFine("next interval in dim " + dim + ": " + interval);
}
else if(logger.isVerbose()) {
logger.verbose("next interval in dim " + dim + ": " + interval);
}
// only noise left
if(interval == null) {
break;
}
// do a dim-1 dimensional run
ModifiableDBIDs clusterIDs = DBIDUtil.newHashSet();
if(dim > minDim + 1) {
ModifiableDBIDs ids;
Matrix basis_dim_minus_1;
if(adjust) {
ids = DBIDUtil.newHashSet();
basis_dim_minus_1 = runDerivator(relation, dim, interval, ids);
}
else {
ids = interval.getIDs();
basis_dim_minus_1 = determineBasis(SpatialUtil.centroid(interval));
}
if(ids.size() != 0) {
MaterializedRelation<ParameterizationFunction> db = buildDB(dim, basis_dim_minus_1, ids, relation);
// add result of dim-1 to this result
Clustering<Model> res_dim_minus_1 = doRun(db, progress);
for(Cluster<Model> cluster : res_dim_minus_1.getAllClusters()) {
res.addCluster(cluster);