void CLARANSClustering::startClustering(const ClusterMethodParameters* pParameters, Document *pDocument, ClusteringResult *pClusteringResult) { mpDocument = pDocument; mpClusteringResult = pClusteringResult; this->mpDocument->setDistanceType(pParameters->dataType); // retrieve parameters: const CLARANSParameters *pParams = (const CLARANSParameters*)(pParameters); std::cout << "CLARANS parameters: numClust = " << pParams->numClust << ", numLocal = " << pParams->numLocal << ", maxNeighbor = " << pParams->maxNeighbor << std::endl; mpClusteringResult->deleteClustering(); // delete probably old clustering result const int nSamples = this->mpDocument->nParsedImages(); const int nClusts = pParams->numClust; if (nSamples < 2) { throw NoDataException("No data found for clustering!"); } if (pParameters->dataType == FEATURES_BASED && this->mpDocument->nFeatures() < 2) { throw NoDataException("No features found for clustering!"); } // get pointer to image chars: std::vector<ImageChar*> *imageCharVecPointer = this->mpDocument->getImageCharsVecPointer(); // INITIALIZATION: // srand(time(NULL)); // FIXME!!!!!!!!!!!!! double minCost = 1e32f; minCost = 1e32f; double actCost = 0.0f; double newCost = 0.0f; std::vector<int> currentNode; getRandomNode(nSamples, nClusts, currentNode); actCost = getNodeCost(nSamples, currentNode); std::cout << "Starting node: "; printNode(currentNode); // LOOP: int j = 1; j=1; std::vector<int> neighborNode; getRandomNeighbor(nSamples, currentNode, neighborNode); // determine a random neighbor node newCost = getNodeCost(nSamples, neighborNode); std::cout << "Finished CLARANS clustering!" << std::endl; return; } // end startClustering(...)
// SAH costs, raw and batched float getCost(int numChildNodes,int numTris) const { return getNodeCost(numChildNodes) + getTriangleCost(numTris); }