Ejemplo n.º 1
0
int Empty(testLogger& log ) {
    Subsets sets = Subsets::Empty();
    log << "Expected count to be 0, got: " << sets.Count() << endl;;
    if ( sets.Count() != 0 ) { 
        return 1;
    }
    return 0;
}
Ejemplo n.º 2
0
IMPDOMINO_BEGIN_NAMESPACE

Subsets get_subsets(const SubsetGraph &g) {
  SubsetGraphConstVertexName subset_map = boost::get(boost::vertex_name, g);
  Subsets output;
  for (unsigned int vi = 0; vi < boost::num_vertices(g); vi++) {
    output.push_back(boost::get(subset_map, vi));
  }
  return output;
}
Ejemplo n.º 3
0
int Count(testLogger& log ) {
    Subsets sets = Subsets::Empty();
    for ( int i=0; i< 5; ++i) {
        sets.Add(Subset::Range(i));
    }

    log << "Expected count to be 5, got: " << sets.Count() << endl;;
    if ( sets.Count() != 5 ) { 
        return 1;
    }
    return 0;
}
Ejemplo n.º 4
0
int total(const Subsets &a) {
	int i, j, k, r;
	bool f;
	
	//Init
	r = 0;
	
	for(i = 0; i < a.size(); i++)
		for(j = i; j < a.size(); j++)
			if(uniek(a[i], a[j]))
				if(!validate1(a[i], a[j])) {
					r++;
					
					//Debug
					//draw(a[i]);
					//draw(a[j]);
					//cout << endl;
				}
	
	return r;
}
Ejemplo n.º 5
0
int total(const Subsets &a, const Subsets &b) {
	int i, j, k, r;
	bool f;
	
	//Init
	r = 0;
	f = (a[0].size() == b[0].size());
	
	for(i = 0; i < a.size(); i++)
		for(j = (f ? i : 0); j < b.size(); j++)
			if(uniek(a[i], b[j])) {
				r++;
				
				//Debug
				//draw(a[i]);
				//draw(a[j]);
				//cout << endl;
			}
	
	return r;
}
Ejemplo n.º 6
0
RestraintsTemp RestraintCache::get_restraints(const Subset &s,
                                              const Subsets &exclusions) const {
  IMP_OBJECT_LOG;
  kernel::RestraintsTemp ret;
  for (KnownRestraints::const_iterator it = known_restraints_.begin();
       it != known_restraints_.end(); ++it) {
    if (s.get_contains(it->second)) {
      bool excluded = false;
      for (unsigned int i = 0; i < exclusions.size(); ++i) {
        if (exclusions[i].get_contains(it->second)) {
          excluded = true;
          break;
        }
      }
      if (!excluded) {
        ret.push_back(it->first);
      }
    }
  }
  return ret;
}
Ejemplo n.º 7
0
void gen_subsets(Subsets &s, const Subset &x, int n, int p, int m) {
	int i;
	Subset x2;
	
	if(x.size() == m) {
		s.push_back(x);
		
		//Debug
		//draw(x);
		//cout << endl;
		
		return;
	}
	
	for(i = p; i <= n; i++) {
		x2 = x;

		x2.push_back(i);
		
		gen_subsets(s, x2, n, i + 1, m);
	}
}
Ejemplo n.º 8
0
Ints get_partial_index(const ParticlesTemp &particles,
               const Subset &subset, const Subsets &excluded) {
  for (unsigned int i=0; i< excluded.size(); ++i) {
    bool all=true;
    for (unsigned int j=0; j< particles.size(); ++j) {
      if (!std::binary_search(excluded[i].begin(), excluded[i].end(),
                              particles[j])) {
        all=false;
        break;
      }
    }
    if (all) {
      return Ints();
    }
  }
  Ints ret(particles.size(), -1);
  for (unsigned int i=0; i< particles.size(); ++i) {
    Subset::const_iterator it= std::lower_bound(subset.begin(),
                                                subset.end(), particles[i]);
    if (it!= subset.end() && *it == particles[i]) {
      ret[i]= it-subset.begin();
    }
  }
  IMP_IF_LOG(VERBOSE) {
    IMP_LOG(VERBOSE, "Returning ");
    for (unsigned int i=0; i< ret.size(); ++i) {
      IMP_LOG(VERBOSE, ret[i] << " ");
    }
    IMP_LOG(VERBOSE, "for ");
     for (unsigned int i=0; i< particles.size(); ++i) {
       IMP_LOG(VERBOSE, particles[i]->get_name() << " ");
     }
     IMP_LOG(VERBOSE, " subset " << subset << std::endl);
  }
  return ret;
}