Esempio n. 1
0
void GCParamsUnitTest::testGCParams() {
  GCParams writeLogging(true, false, false, false,
                        false, false, false, false);
  GCParams readBarriers(false, true, false, false,
                        false, false, false, false);
  GCParams clusterize(false, false, true, false,
                      false, false, false, false);
  GCParams generational(false, false, false, true,
                        false, false, false, false);
  GCParams doublePtrs(false, false, false, false,
                      true, false, false, false);
  GCParams copyFuncs(false, false, false, false,
                     false, true, false, false);
  GCParams moveFuncs(false, false, false, false,
                     false, false, true, false);
  GCParams traceFuncs(false, false, false, false,
                      false, false, false, true);
  CPPUNIT_ASSERT(writeLogging.writeLogging);
  CPPUNIT_ASSERT(readBarriers.readBarriers);
  CPPUNIT_ASSERT(clusterize.clusterize);
  CPPUNIT_ASSERT(generational.generational);
  CPPUNIT_ASSERT(doublePtrs.doublePtrs);
  CPPUNIT_ASSERT(copyFuncs.copyFuncs);
  CPPUNIT_ASSERT(moveFuncs.moveFuncs);
  CPPUNIT_ASSERT(traceFuncs.traceFuncs);
}
Esempio n. 2
0
    WeightedPageRank(graph_t &graph, Profiler& pfiler, std::vector<vertex_descriptor>& on, int c, float a, float e, float mc, int mr) :
	g(graph), profiler(pfiler), ordered_nodes(on), cluster_size(c), alpha(a), epsilon_divider(e), max_conductance(mc), max_reclusters(mr)
	{
	    // allocate our memory
	    num_verts = num_vertices(g);
	    p.resize(num_verts, 0.0); //= new std::vector<float>(num_verts, 0.0);
	    r.resize(num_verts, 0.0); // = new std::vector<float>(num_verts, 0.0);
	    color_map.resize(num_verts, WHITE);// = new std::vector<int>(num_verts, WHITE);
	    weighted_degree.resize(num_verts, 0);// = new std::vector<float>(num_verts, 0);
	    cluster_map = new int[num_verts];
	    for (int x = 0; x < num_verts; x++)
	    {
		cluster_map[x] = -1;
	    }
	    
	    p_comp = new p_comp_class(&p);
	    cluster_consider = new PropertyMaxQueue(num_verts, *p_comp, ident);
	    
	    degreemap = get(vertex_distance, g);
	    weightmap = get(edge_weight, g);

	    // calculate rest of params
	    epsilon = 1.0 / (epsilon_divider * (float)cluster_size);
	    max_nodes_consider = (int)((4.0f/3.0f)*(float)cluster_size);
	    min_nodes_consider = (int)((2.0f/3.0f)*(float)cluster_size);
	    geo_ratio = alpha * (1.0 - alpha) / 2.0;
	    
	    initialize_degrees();

	    // we automatically generate clusters on instantiation
	    clusterize();
	}
Esempio n. 3
0
void kmeans(list<article_entry*> &l) {
	// Normalize vectors
	printf("Normalizing vectors\n");
	for(int i=0; i<l.size(); i++)
		normalize(l.get(i));
	clusterize(CLUSTERS, l);
}
Esempio n. 4
0
 Clusterizer(Vunit& unit, const Scale& scale)
     : m_unit(unit)
     , m_scale(scale)
     , m_blocks(sortBlocks(unit)) {
   initClusters();
   clusterize();
   sortClusters();
   splitHotColdClusters();
   FTRACE(1, "{}", toString());
 }
Esempio n. 5
0
void Clusterizer::addHits(HitInfo*& rHitInfo, const unsigned int& rNhits)
{
  if(Basis::debugSet())
	  debug("addHits(...,rNhits="+IntToStr(rNhits)+")");

  _hitInfo = rHitInfo;
  _Nclusters = 0;

  if(rNhits>0 && _actualEventNumber != 0 && rHitInfo[0].eventNumber == _actualEventNumber)
	  warning("addHits: Hit chunks not aligned at events. Clusterizer will not work properly");

  for(unsigned int i = 0; i<rNhits; i++){
	  if(_actualEventNumber != rHitInfo[i].eventNumber){
		  clusterize();
		  addHitClusterInfo(i);
		  clearActualEventVariables();
	  }
	  _actualEventNumber = rHitInfo[i].eventNumber;
	  addHit(i);
  }
//  //manually add remaining hit data
  clusterize();
  addHitClusterInfo(rNhits);
}
Esempio n. 6
0
void PoleExtractor::elaborateCloud(const pcl::PointCloud<pcl::PointXYZ>::Ptr &source,
                                   std::shared_ptr< std::vector< Pole::Ptr > > &polesVector)
{
    polesVector.reset();
    std::vector< Pole::Ptr > vector;
    polesVector = std::make_shared< std::vector< Pole::Ptr > >(vector);

    std::shared_ptr< std::vector<pcl::PointIndices> >
            clusterIndices;

    // Extract clusters
    clusterize(source,
               clusterIndices);

    std::shared_ptr< std::vector< std::shared_ptr<Pole> > >
            tempPolesVector;

    // Extract poles
    polesFromClusters(source,
                      clusterIndices,
                      tempPolesVector);

    // Update actual poles vector with new ones,
    // terminate lost-tracked poles and update tracked poles.

    // If the first call just copy the temp vector, all poles are new
    if (0 == actual_poles_vector_->size())
    {
        for (auto p : *tempPolesVector)
        {
            p->setStatus(Pole::VALID);
            polesVector->push_back(p);
            actual_poles_vector_->push_back(p);
        }
//        clearNoise();
        return;
    }

    // I have to iterate actual poles and searche in the temp the nearest neighbor within a
    // fixed ray. If no poles are found -> lost-track, else the pole must be updated.
    // Finally I have to add new poles (the unmatched) to the list.

    // I use a greedy and fast approach
    std::vector< std::shared_ptr<Pole> >::iterator
            actual_it = actual_poles_vector_->begin();

    for (; actual_it != actual_poles_vector_->end(); actual_it++)
    {
        // Ignore track-lost poles from update
        if ((*actual_it)->getStatus() == Pole::LOST_TRACK)
        {
            // the -- post operation is due to the for incrementation
            actual_poles_vector_->erase(actual_it--);
            continue;
        }

        double minDistance = 1 + maximum_pole_distance_;
        std::shared_ptr<Pole> nearestNeighbor;

        std::vector< std::shared_ptr<Pole> >::iterator
                temp_it = tempPolesVector->begin();
        for (; temp_it != tempPolesVector->end(); temp_it++)
        {
            // Check if the actual temp pole has been already ASSOCIATED or not
            if ((*temp_it)->getStatus() != Pole::ASSOCIATED)
            {
                // Compute the distance
                double dx = (*actual_it)->getCentroid().x - (*temp_it)->getCentroid().x;
                double dy = (*actual_it)->getCentroid().y - (*temp_it)->getCentroid().y;
                double distance = sqrt(dx*dx + dy*dy);

                // Check and update the nearest neighbor
                if (distance < maximum_pole_distance_ && distance < minDistance)
                {
                    minDistance = distance;
                    nearestNeighbor = (*temp_it);
                }
            }
        }

        // Check if it is a lost-track pole
        if (minDistance >= maximum_pole_distance_)
        {
            (*actual_it)->setStatus(Pole::LOST_TRACK);
            //std::cout << "POLE ID:\t" << (*actual_it)->ID() << " SET LOST_TRACK" << std::endl;
        }
        else
        {
            // Update the pole with its new position and points
            nearestNeighbor->setStatus(Pole::ASSOCIATED);

            (*actual_it)->updateCentroid(nearestNeighbor->getCentroid());
            //std::cout << "POLE ID:\t" << (*actual_it)->ID() << " N-NEIGHBOR FOUND" << std::endl;

            std::shared_ptr< const std::vector<cv::Point2f> >
                    tempPointsVector= nearestNeighbor->getPointsVector();
            (*actual_it)->updatePointsVector(tempPointsVector);
        }
    }

    // Now add the new poles
    std::vector< Pole::Ptr >::iterator
            temp_it = tempPolesVector->begin();
    for (; temp_it != tempPolesVector->end(); temp_it++)
    {
        if (Pole::JUST_SCANNED == (*temp_it)->getStatus())
        {
            (*temp_it)->setStatus(Pole::VALID);
            actual_poles_vector_->push_back((*temp_it));
        }
    }

//    clearNoise();

    // Copy all the poles to the output array
    for (auto i : *actual_poles_vector_)
    {
        polesVector->push_back(i);
    }
}