Exemplo n.º 1
0
 const Cluster operator-(const Cluster &c, const Point &p)
 {
     Cluster subtracted;
     subtracted.__cpy(c.__points);
     subtracted.remove(p);
     return subtracted;
 }
Exemplo n.º 2
0
int main(int argc, char const *argv[])
{
    freopen("in.txt", "r", stdin);
    int W, H;
    cin >> W >> H;
    vector<string> grid(H);
    vector<Cluster> vc;
    for (int i = 0; i < H; i++)
        cin >> grid[i];
    char index = 'a';
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '1') {
                Cluster c = find_cluster(grid, i, j);
                c.index = index;
                for (vector<Cluster>::iterator it = vc.begin(); it != vc.end(); it++) {
                    if (it->same(c)) {
                        c.index = it->index;
                        break;
                    }
                }
                if (c.index == index) {
                    index++;
                    vc.PB(c);
                }
                c.paint(grid);
            }
        }
    }
    for (int i = 0; i < H; i++) {
        cout << grid[i] << endl;
    }
    return 0;
}
Exemplo n.º 3
0
Cluster* Community::prepareCluster(const Cluster* rootCluster) const
{
	Cluster* cluster = new Cluster();
	map<int, vector<int> > comm;
	vector<int> order;
	for (int i = 0; i < g->n; i++)
	{
		if (!comm.count(n2c[i]))
		{
			comm[n2c[i]] = vector<int>();
			order.push_back(n2c[i]);
		}

		comm[n2c[i]].push_back(i);
	}

	for (int ci = 0; ci < (int)order.size(); ci++)
	{
		int cIndex = order[ci];
		Cluster* subCluster = new Cluster();
		for (int i = 0; i < (int)comm[cIndex].size(); i++)
		{
			int vIndex = comm[cIndex][i];
			if (rootCluster->containsVertices())
				subCluster->addVertex(rootCluster->getVertexes()[vIndex]);
			else
				subCluster->addSubCluster(rootCluster->getSubClusters()[vIndex]);
		}

		cluster->addSubCluster(subCluster);
	}

	return cluster;
}
Exemplo n.º 4
0
int main(const int argc, const char** argv)
{
    if (argc < 7) {
        std::cout << "Usage: cluster NUM_PT M_MEAN M_STD R0 DT NUM_ITERS" << std::endl;
        return 1;
    }

    size_t num_pts = std::stoull(argv[1]);
    double mass_mean = std::atof(argv[2]);
    double mass_std = std::atof(argv[3]);
    double rad0 = std::atof(argv[4]);
    double timestep = std::atof(argv[5]);
    size_t num_iters = std::stoull(argv[6]);

    auto integrator = std::function<decltype(rk4)>(rk4);
    Cluster cl (num_pts, mass_mean, mass_std, rad0, integrator);

    arma::cube snapshots (num_pts, 9, num_iters);
    snapshots.slice(0) = cl.getStateMatrix();

    for (int i = 1; i < num_iters; i++) {
        cl.update(timestep);
        snapshots.slice(i) = cl.getStateMatrix();
    }

    snapshots.save("result.h5", arma::hdf5_binary);

    return 0;
}
            TEST_F(MemberAttributeTest, testInitialValues) {
                HazelcastServer instance(*g_srvFactory);
                std::auto_ptr<HazelcastClient> hazelcastClient(getNewClient());
                Cluster cluster = hazelcastClient->getCluster();
                std::vector<Member> members = cluster.getMembers();
                ASSERT_EQ(1U,members.size());
                Member &member = members[0];
                ASSERT_TRUE(member.lookupAttribute("intAttr"));
                ASSERT_EQ("211", *member.getAttribute("intAttr"));

                ASSERT_TRUE(member.lookupAttribute("boolAttr"));
                ASSERT_EQ("true", *member.getAttribute("boolAttr"));

                ASSERT_TRUE(member.lookupAttribute("byteAttr"));
                ASSERT_EQ("7", *member.getAttribute("byteAttr"));

                ASSERT_TRUE(member.lookupAttribute("doubleAttr"));
                ASSERT_EQ("2.0", *member.getAttribute("doubleAttr"));

                ASSERT_TRUE(member.lookupAttribute("floatAttr"));
                ASSERT_EQ("1.2", *member.getAttribute("floatAttr"));

                ASSERT_TRUE(member.lookupAttribute("shortAttr"));
                ASSERT_EQ("3", *member.getAttribute("shortAttr"));

                ASSERT_TRUE(member.lookupAttribute("strAttr"));
                ASSERT_EQ(std::string("strAttr"), *member.getAttribute("strAttr"));

                instance.shutdown();
            }
Exemplo n.º 6
0
            TEST_F(ClusterTest, testClusterListeners) {
                HazelcastServer instance(*g_srvFactory);
                std::auto_ptr<HazelcastClient> hazelcastClient(getNewClient());
                Cluster cluster = hazelcastClient->getCluster();
                util::CountDownLatch memberAdded(1);
                util::CountDownLatch memberAddedInit(2);
                util::CountDownLatch memberRemoved(1);
                util::CountDownLatch memberRemovedInit(1);
                util::CountDownLatch attributeLatch(7);
                util::CountDownLatch attributeLatchInit(7);

                SampleInitialListener sampleInitialListener(memberAddedInit, attributeLatchInit, memberRemovedInit);
                SampleListenerInClusterTest sampleListener(memberAdded, attributeLatch, memberRemoved);

                cluster.addMembershipListener(&sampleInitialListener);
                cluster.addMembershipListener(&sampleListener);

                HazelcastServer instance2(*g_srvFactory);

                ASSERT_TRUE(attributeLatchInit.await(30));
                ASSERT_TRUE(attributeLatch.await(30));
                ASSERT_TRUE(memberAdded.await(30));
                ASSERT_TRUE(memberAddedInit.await(30));

                instance2.shutdown();

                ASSERT_TRUE(memberRemoved.await(30));
                ASSERT_TRUE(memberRemovedInit.await(30));

                instance.shutdown();

                cluster.removeMembershipListener(&sampleInitialListener);
                cluster.removeMembershipListener(&sampleListener);
            }
Exemplo n.º 7
0
// Friends: Arithmetic (Cluster and Point)
    const Cluster operator+(const Cluster &c, const Point &p)
    {
        Cluster added;
        added.__cpy(c.__points);
        added.add(p);
        return added;
    }
Exemplo n.º 8
0
void Clusters::removeTrackFromClustersWithoutTrack(Track *track) {
   // FIXME TClonesArray error
   
   Int_t    lastIndex = 0;
   Int_t    layer;
   Float_t  x, y;

   for (Int_t i = 0; i < track->GetEntriesFast(); i++) {
      if (!track->At(i)) continue;
      layer = track->getLayer(i);
      x = track->getX(i);
      y = track->getY(i);

      for (Int_t j=lastIndex; j<GetEntriesFastCWT(); j++) {
         Cluster *cluster = (Cluster *) clustersWithoutTrack_.At(j);

         if (!cluster)
            continue;
         
         if (cluster->getLayer() < layer)
            continue;

         if (cluster->getX() == x) {
            if (cluster->getY() == y && cluster->getLayer() == layer) {
               removeClusterWithoutTrackAt(j);
               lastIndex = j+1;
               break;
            }
         }
      }
   }
}
void AgglomerativeClustering::removeRepetitions() {

  
  for(int i = 0; i < this->clusters.size(); i++) {
   
    Cluster* cluster = this->clusters[i];
    vector<int> toRemove (0);
    
    for(int j = 0; j < this->clusters.size(); j++) {
      
      if(j != i && (cluster->getPoint()->x == this->clusters[j]->getPoint()->x) && 
        (cluster->getPoint()->y == this->clusters[j]->getPoint()->y)) {
        
        toRemove.push_back(j);
        
      }
      
    }
    
    for(int i = toRemove.size() - 1; i > -1; i--) {
      
      this->clusters.erase((this->clusters.begin() + toRemove[i]));
      
    }
    
  }
  
}
Exemplo n.º 10
0
C_NNFW_API NnfwCluster* NnfwIteratorGetCluster( NnfwIterator* itera, int i ) {
	Cluster* cl;
	switch( itera->type ) {
	case 0:
		cl = itera->clvec->at(i);
		break;
	case 1:
		return 0;
		break;
	case 2:
		if ( dynamic_cast<Linker*>(itera->upvec->at(i)) ) {
			return 0;
		}
		cl = (Cluster*)(itera->upvec->at(i));
		break;
	default:
		return 0;
	}
	if ( clmap.count( cl ) == 0 ) {
		NnfwCluster* ncl = new NnfwCluster();
		ncl->cluster = cl;
		ncl->myup = ncl->cluster;
		ncl->func = new NnfwOutputFunction();
		ncl->func->func = cl->getFunction();
		clmap[cl] = ncl;
	}
	return clmap[cl];
}
Exemplo n.º 11
0
void
find_associated_nodes(const Cluster & center,
                      const Uid2UinvTree & uid2uinv,
                      const PatentTree & patent_tree,
                      set < const Record * > & associated_delegates) {

    associated_delegates.clear();

    for (RecordPList::const_iterator p = center.get_fellows().begin(); p != center.get_fellows().end(); ++p ) {

        PatentTree::const_iterator ipat = patent_tree.find(*p);
        if (ipat == patent_tree.end()) {
            (*p)->print();
            throw cException_Attribute_Not_In_Tree("Cannot find the patent.");
        }

        for (RecordPList::const_iterator cgi = ipat->second.begin(); cgi != ipat->second.end(); ++cgi) {

            if ( *cgi == *p ) continue;

            Uid2UinvTree::const_iterator q = uid2uinv.find(*cgi);
            if (q == uid2uinv.end()) {
                throw cException_Attribute_Not_In_Tree("Cannot find the unique record pointer.");
            }
            associated_delegates.insert(q->second);
        }

    }

    for (RecordPList::const_iterator p = center.get_fellows().begin(); p != center.get_fellows().end(); ++p) {
        associated_delegates.erase(*p);
    }
}
Exemplo n.º 12
0
void cluster_builder::merge_clusters(std::vector<cluster_builder::Cluster> &clusters)
{
	if (clusters.size() <= 1) {
		return;
	}

	std::vector<ClusterPair> cluster_pairs;
	build_each_clusters(clusters, cluster_pairs);

	for (std::vector<ClusterPair>::iterator it = cluster_pairs.begin(); it != cluster_pairs.end(); ++it) {
		if (it->dis < threshold_) {
			std::vector<Cluster>::iterator it0 = find_cluster(clusters, it->c0.id);
			std::vector<Cluster>::iterator it1 = find_cluster(clusters, it->c1.id);

			if (it0 != clusters.end() && it1 != clusters.end()) {
				Cluster c;
				c.id = next_cid_++;
				c.pts = it0->pts;
				c.pts.insert(c.pts.begin(), it1->pts.begin(), it1->pts.end());
				c.calc_mean();

				clusters.push_back(c);
				remove_cluster(clusters, it0->id);
				remove_cluster(clusters, it1->id);
			}
		}
		else {
			break;
		}
	}
}
Exemplo n.º 13
0
            void ClusterTest::testClusterListeners() {
                HazelcastServer instance(hazelcastInstanceFactory);
                std::auto_ptr<HazelcastClient> hazelcastClient(getNewClient());
                Cluster cluster = hazelcastClient->getCluster();
                util::CountDownLatch memberAdded(1);
                util::CountDownLatch memberAddedInit(2);
                util::CountDownLatch memberRemoved(1);
                util::CountDownLatch memberRemovedInit(1);
                util::CountDownLatch attributeLatch(7);
                util::CountDownLatch attributeLatchInit(7);

                SampleInitialListener sampleInitialListener(memberAddedInit, attributeLatchInit, memberRemovedInit);
                SampleListenerInClusterTest sampleListener(memberAdded, attributeLatch, memberRemoved);

                cluster.addMembershipListener(&sampleInitialListener);
                cluster.addMembershipListener(&sampleListener);

                HazelcastServer instance2(hazelcastInstanceFactory);

                assertTrue(attributeLatchInit.await(30), "attributeLatchInit");
                assertTrue(attributeLatch.await(30), "attributeLatch");
                assertTrue(memberAdded.await(30), "memberAdded");
                assertTrue(memberAddedInit.await(30), "memberAddedInit");

                instance2.shutdown();

                assertTrue(memberRemoved.await(30), "memberRemoved");
                assertTrue(memberRemovedInit.await(30), "memberRemovedInit");

                instance.shutdown();

                cluster.removeMembershipListener(&sampleInitialListener);
                cluster.removeMembershipListener(&sampleListener);
            }
Exemplo n.º 14
0
Arquivo: Plain.cpp Projeto: kynad/AI
/**
 * Constructs a new cluster that contains all points from the given clusters.
 * Removes the given clusters from list of clusters, adds this cluster instead.
 * Updates the distance table.
 * @returns a pointer to the new cluster.
 */
Cluster* Plain::mergeClusters(int firstId, int secondId)
{
  if (firstId == secondId)
  {
    cout << "Error: trying to merge " << firstId << "th cluster with itself." << endl;
    throw "";
  }

  /*cout << "Debug: merging cluster " << firstId << " with cluster " << secondId << endl;*/

  // 0. get clusters by id from the vector
  Cluster* one = clusters[firstId];
  Cluster* two = clusters[secondId];
  // 1. merge the two clusters using the "copy ctor"
  Cluster* cluster = new Cluster(one, two);
  // 2. update the distances table
  int id = cluster->getId();
  int maxId = (firstId > secondId) ? firstId : secondId;
  for (vector<Cluster*>::iterator it = clusters.begin(); it != clusters.end(); it++)
  {
    int otherId = (*it)->getId();
    double distance = clusterDistance(one, two, (*it));
    this->distances[id][otherId] = distance;
    this->distances[otherId][id] = distance;
  }
  // 3. Replace the argmin(id) cluster in the vector and remove the argmax(id)
  clusters[id] = cluster;
  clusters.erase(clusters.begin() + maxId); // Note that erase is O(vector.size()).
  for (vector<Cluster*>::iterator it = clusters.begin() + maxId; it != clusters.end(); it++)
    (*it)->decreaseId();
  // 4. remove a row and a column in the distance 
  int size = clusters.size();
  double** distances = new double*[size*sizeof(double)];
  // copy until maxId
  for (int i=0; i < maxId; i++)
  {
    distances[i] = new double[size*sizeof(double)];
    for (int j=0; j < maxId; j++)
      distances[i][j] = this->distances[i][j];
    for (int j = maxId; j < size; j++)
      distances[i][j] = this->distances[i][j+1];
    delete this->distances[i];
  }
  // copy from maxId+1
  for (int i=maxId; i < size; i++)
  {
    distances[i] = new double[size*sizeof(double)];
    for (int j=0; j < maxId; j++)
      distances[i][j] = this->distances[i+1][j];
    for (int j=maxId; j < size; j++)
      distances[i][j] = this->distances[i+1][j+1];
    delete this->distances[i];
  }
  delete [] this->distances;
  this->distances = distances;
  // 5. delete the old clusters
  delete one;
  delete two;
  return cluster;
}
Exemplo n.º 15
0
int main_run(char * args[]){
	vector<vector<T>> ufile = read(args[1]);
		vector<vector<T>> tfile = read(args[2]);
		vector<vector<T>> logs = read(args[3]);
		HMM<T> hmm;
		/*for (auto i = transformed.begin(); i != transformed.end(); ++i) {
		  for (auto j = i->begin(); j != i->end(); ++j) {
		  cout<<j->first<<"\t"<<j->second<<"\n";
		  }
		  }*/
		hmm.Train(ufile, tfile);
		map<int, string> tagcodemap;
		vector<vector<T>> taglist = hmm.TagLogs(logs, tagcodemap);
		vector<vector<T>> transformed = transform2(taglist);
		//FP GROWTH PART FOR CLUSTERING after classification
		int s = atoi(args[4]);
		FPTree<T> tree(s);
		//consider the position of token in the line
		tree.build(transformed);
		std::vector<std::vector<T>> r;
		clock_t t = clock();
		tree.mine(r);
		std::cout<<"Initial pattern no: "<<r.size()<<"\n";
		Cluster<T> data;
		data.AssociatePatterns(transformed, r);
		cout << "Time: " << double(clock() - t) / CLOCKS_PER_SEC << "\n";
		data.DisplayCluster(logs, transformed, r, tagcodemap);
		Analyze<T> analyze;
		vector<vector<T>> manual = read("manual");
		cout<<"\n"<<analyze.Efficiency(taglist, manual);
}
Exemplo n.º 16
0
int main() {

    Cluster clusterInit;
    clusterInit.setRPFlag(true);

    std::string filename = "points.txt";
    KMeans algo(5);
    algo.initialize(clusterInit,filename);



    for(int i = 0; i< algo.getK();i++){
        std::cout<< "INITIAL" << std::endl;
        std::cout << algo.getClusters()[i] << std::endl;
        //std::cout << algo.getClusters()[i].getCentroid() << std::endl;
    }


    algo.letsCluster();

    for(int i = 0; i< algo.getK();i++){
        std::cout<< "FINAL" << std::endl;
        std::cout << algo.getClusters()[i] << std::endl;
        //std::cout << algo.getClusters()[i].getCentroid() << std::endl;
    }


}
Exemplo n.º 17
0
ClusterManager::ClusterManager(GMemorySystem *ms, GProcessor *gproc)
{
  bzero(res, sizeof(Resource *) * MaxInstType);

  const char *coreSection = SescConf->getCharPtr("","cpucore",gproc->getId());
  if(coreSection == 0) 
    return;  // No core section, bad conf

  int nClusters = SescConf->getRecordSize(coreSection,"cluster");
  
  for(int i=0;i<nClusters;i++) {
    const char *clusterName = SescConf->getCharPtr(coreSection,"cluster",i);
    SescConf->isCharPtr(coreSection,"cluster",i);
    
    Cluster *cluster = Cluster::create(clusterName, ms, gproc);

    for(int t = 0; t < MaxInstType; t++) {
      Resource *r = cluster->getResource(static_cast<InstType>(t));

      if (r) {
	if (res[t]) {
	  MSG("Multiple cluster have same FUs. Implement replicated clustering");
	  exit(0);
	}
	
	res[t] = r;
      }
    }
  }

  // 0 is an invalid opcde. All the other should be defined
  IN(forall((size_t i=1;i<static_cast<size_t>(MaxInstType);i++),res[i]!=0));
}
Exemplo n.º 18
0
Mapa::Mapa(list<Individual> objetos, int nLinhas, int nColunas, int cardinalidade) {
	list<Cluster> clusters = new list<Cluster>();
	int c = nLinhas * nColunas;
	int i,j;

	srand((unsigned)time(0));
	int random_int;
	int lowest=0, highest=this->objetos.size();
	int range=(highest-lowest);

	for (i = 0; i < c; i++){
		Cluster cluster = new Cluster(i);
		for (j = 0; j < cardinalidade; j++){
			random_int = lowest+int(range*rand()/(RAND_MAX + 1.0));
			Individual prot = this->objetos[random_int];
			Individual novo_prototipo = new Individual(prot.indice, prot.id2, prot.nome);

			//TODO: Verificar se já existe o protótipo na lista
			cluster.prototipos.push_back(novo_prototipo);
		}
		clusters.push_back(cluster);
	}

	this->mapa = new list<list<Cluster>>(nLinhas, nColunas);
	this->objetos = objetos;

	for(i=0; i<nLinhas; i++){
		for(j=0; j<nColunas; j++){
			Cluster cl = this->mapa[i][j];
			cl.definirPonto(i,j);
		}
	}
}
Exemplo n.º 19
0
Cluster * Track::getExtrapolatedClusterAt(Float_t mmBeforeDetector) {
   Int_t    firstLayer = getFirstLayer();
   Int_t    firstIdx = getClusterFromLayer(firstLayer);
   Int_t    nextIdx = 0;
   Float_t  diffx, diffy, diffz;
   Float_t  extra_mm = getLayermm(firstLayer);

   for (Int_t i=firstIdx+1; i<GetEntriesFast(); i++) {
      if (!At(i)) continue;

      nextIdx = i;
      break;
   }
   
   Cluster *first = At(firstIdx);
   Cluster *next = At(nextIdx);

   diffz = (next->getLayermm() - first->getLayermm());
   diffx = (first->getX() - next->getX()) / diffz;
   diffy = (first->getY() - next->getY()) / diffz;

   Float_t new_x = first->getX() + diffx * (mmBeforeDetector + extra_mm);
   Float_t new_y = first->getY() + diffy * (mmBeforeDetector + extra_mm);

   Cluster *extrapolated = new Cluster(new_x, new_y); 
   
   return extrapolated;
}
Exemplo n.º 20
0
MatrixPtr GenerateClusteredData::operator()() {
  auto matrix = std::make_shared<Matrix>();
  matrix->reserve(nbrInds);
  Variables variables;
  
  for (size_t var = 0; var < nbrClusters * clustSize; ++var) {
    variables ^= Variable( boost::lexical_cast<std::string>(var),
                           plIntegerType(0, cardinality-1) );
  }

  Clustering clustering; clustering.reserve(nbrClusters);
  for ( size_t clust = 0; clust < nbrClusters; ++clust ) {
    Cluster cluster;
    for ( size_t item = 0; item < clustSize; ++item ) {
      cluster.push_back( clust*clustSize + item ); 
    }
    clustering.push_back( cluster );
  }
  
  plJointDistribution jointDist = createClusteringJointDist( variables, clustering);
  plValues values( variables );
  // std::cout << jointDist << std::endl << jointDist.get_computable_object_list() << std::endl;
  for (size_t ind = 0; ind < nbrInds; ++ind) {
    jointDist.draw(values);   
    std::vector<int> row(variables.size()); 
    for (size_t var = 0; var < variables.size(); ++var) {
      row[var] = values[variables[var]];  
    }
    matrix->push_back(row);
  }

  //std::cout << jointDist << std::endl;
  return Transpose(*matrix);
}
Exemplo n.º 21
0
        Cluster split (int split_axis, const VertexElement *poselem,
                       uint8 *vdata, size_t vsz)
        {
            Real r = (mMin [split_axis] + mMax [split_axis]) * 0.5f;
            Cluster newbox;

            // Separate all points that are inside the new bbox
            for (set<uint32>::type::iterator i = mIndices.begin ();
                 i != mIndices.end (); )
            {
                float *v;
                poselem->baseVertexPointerToElement (vdata + *i * vsz, &v);
                if (v [split_axis] > r)
                {
                    newbox.mIndices.insert (*i);
                    set<uint32>::type::iterator x = i++;
                    mIndices.erase(x);
                }
                else
                    ++i;
            }

            computeBBox (poselem, vdata, vsz);
            newbox.computeBBox (poselem, vdata, vsz);

            return newbox;
        }
Exemplo n.º 22
0
plComputableObjectList createClusterJointDist( const Variables& variables, const Cluster& cluster ) {
  plComputableObjectList cndProbTab;
  const Variable& var =  variables[*cluster.begin()];
  const DistValues probs = createNBUniVarProbTab( var.cardinality() ) ;
  const plProbTable probTab( var, probs, true );
  cndProbTab *= probTab;

  DistValueMat clusterProbTables = createClusterProbTables( variables, cluster );
  //./bVariables clustVars;
  // clustVars ^= var;
  
  Cluster::const_iterator curr, next;
  curr = cluster.begin(); next = curr + 1;

  DistValueMat::const_iterator ptIt = clusterProbTables.begin();
  while ( next != cluster.end() ) {
    plDistributionTable distTab_Xi_Z( variables[*next], variables[*curr] ); 
    for (size_t h = 0; h < variables[*curr].cardinality(); ++h) {
      distTab_Xi_Z.push( plProbTable( variables[*next], ptIt->at(h)), (int)h );
    }
    cndProbTab *= distTab_Xi_Z; 
    ++curr; ++next; ++ptIt;
  }

  return cndProbTab; //plJointDistribution( clustVars, cndProbTab );
}
Exemplo n.º 23
0
bool CMSHCAL::acceptance(const Cluster& cluster) const {
  double energy = cluster.energy();
  double eta = fabs(cluster.eta());
  bool accept = false;
  auto& pars = m_acceptanceParameters;

  if (eta < m_etaCrack) {
    if (energy > pars[0])
      accept = rootrandom::Random::uniform(0, 1) < (pars[1] / (1 + exp((energy + pars[2]) / (pars[3]))));
  } else if (eta < pars[4]) {
    if (energy > pars[5]) {
      if (energy < pars[6])
        accept = rootrandom::Random::uniform(0, 1) < (pars[7] + pars[8] * energy + pars[9] * (pow(energy, 2)));
      else
        accept = rootrandom::Random::uniform(0, 1) < (pars[10] / (1 + exp((energy + pars[11]) / pars[12])));
    }
  } else if (eta < pars[13] && energy > pars[14])
    accept = true;

  /*if (eta < m_etaCrack) {
    if (energy > 1.) accept = rootrandom::Random::uniform(0, 1) < (1 / (1 + exp((energy - 1.93816) / (-1.75330))));
  } else if (eta < 3.) {
    if (energy > 1.1) {
      if (energy < 10.)
        accept = rootrandom::Random::uniform(0, 1) < (1.05634 - 1.66943e-01 * energy + 1.05997e-02 * (pow(energy, 2)));
      else
        accept = rootrandom::Random::uniform(0, 1) < (8.09522e-01 / (1 + exp((energy - 9.90855) / -5.30366)));
    }
  } else if (eta < 5. && energy > 7)
    accept = true;*/

  return accept;
}
Exemplo n.º 24
0
void Balancer::perfBalanceGPU(Cluster &cluster, Decomposition& decomp,
        const double kTimeEstimate) {
  const int kGPUOnly = 2;
  WorkQueue work_queue;
  WorkRequest work_request;
  const int kNumTotalGPUs = cluster.getNumTotalGPUs();
  if (decomp.getNumSubDomains() == 0 || kNumTotalGPUs == 0)
    return;
  for (int gpu_index = 0; gpu_index < kNumTotalGPUs; ++gpu_index) {
    Node& gpu = cluster.getGlobalGPU(gpu_index);
    // fastest gpu will have largest weight, and thus move to front of queue
    work_request.setTimeDiff(kTimeEstimate - gpu.getBalTimeEst(1, kGPUOnly));
    work_request.setIndex(gpu_index);
    work_queue.push(work_request);
  }

  const int kNumBlocks = decomp.getNumSubDomains();
  // place data blocks on gpu's one-at-a-time
  for (int block_id = 0; block_id < kNumBlocks; ++block_id) {
    work_request = work_queue.top();
    work_queue.pop();

    Node& gpu = cluster.getGlobalGPU(work_request.getIndex());
    gpu.incrementBalCount();

    double time_diff = gpu.getBalTimeEst(1, kGPUOnly);

    work_request.setTimeDiff(time_diff);
    work_queue.push(work_request);
    //printWorkQueue(work_queue);
  }

  cluster.distributeBlocks(&decomp);
}
Exemplo n.º 25
0
bool GenContext::intersects_with(const Cluster* clu2) const {
	for(int iclu = 0; iclu < m; iclu++) {
		Cluster *clu = clusters[iclu];
		if(clu && clu != clu2 && clu->intersects_with(*clu2))
			return true;
	}
	return false;
}  // intersects_with
Exemplo n.º 26
0
void Clusters::appendCluster(Cluster *cluster) {
   Int_t i = GetEntriesFast();
   Cluster *c = (Cluster*) clusters_.ConstructedAt(i);
   c->set(cluster->getX(), cluster->getY(), cluster->getLayer(), cluster->getSize());

   if (cluster->isUsed()) { c->markUsed(); }
   c->setEventID(cluster->getEventID());
}
Exemplo n.º 27
0
// Friends: Arithmetic (two Clusters)
    const Cluster operator+(const Cluster &one, const Cluster &two) // union
    {
        Cluster allTogether;
        allTogether.__cpy(one.__points);
        int size = two.getSize();
        // This isn't going to work, it will pass the first point and nothing more.
        allTogether.add(two.__points->point);

    }
Exemplo n.º 28
0
void DimArray::erase_cluster(const Cluster& c) {
    const set<Word>& c_dims = c.get_words();
    
    for (set<Word>::const_iterator p_dim = c_dims.begin();
         p_dim != c_dims.end();
         ++p_dim) {
        // remove c from p_dim linked nodes
        m_dims[p_dim->id].erase(c.id());
    }
}
Exemplo n.º 29
0
void Clusters::appendClusterEdep(Float_t x, Float_t y, Int_t layer, Float_t edep, Int_t eventID) {
   Int_t i = GetEntriesFast();
   Cluster *c = (Cluster*) clusters_.ConstructedAt(i);
   
   // calculate size from edep
   
   Int_t size = getCSFromEdep(edep);

   c->set(x,y,layer,size, eventID);
}
Exemplo n.º 30
0
bool ClicECAL::acceptance(const Cluster& cluster) const {
  double energy = cluster.energy();
  double eta = fabs(cluster.eta());
  if (eta < volumeCylinder().inner().etaJunction())
    return (energy > m_emin[0]);  // barrel
  else if (eta < m_etaAcceptance)
    return energy > m_emin[1];  // endcap
  else
    return false;
}