9 #ifndef IMPDOMINO_SUBSET_FILTERS_H
10 #define IMPDOMINO_SUBSET_FILTERS_H
12 #include <IMP/domino/domino_config.h>
25 #include <boost/dynamic_bitset.hpp>
29 #include <boost/pending/disjoint_sets.hpp>
33 IMPDOMINO_BEGIN_NAMESPACE
51 virtual bool get_is_ok(
const Assignment& state)
const=0;
89 const Subsets &prior_subsets)
const=0;
95 virtual double get_strength(
const Subset &s,
96 const Subsets &prior_subsets)
const=0;
112 OwnerPointer<RestraintCache> cache_;
137 OwnerPointer<RestraintCache> rc_;
141 const Subsets &excluded)
const;
145 int max_number_allowed_violations);
146 int get_maximum_number_of_violated_restraints()
const {
147 return max_violated_;}
165 Pointer<ParticleStatesTable> pst_;
166 ParticlesTemp elements_;
167 boost::vector_property_map<int> parent_, rank_;
168 mutable boost::disjoint_sets<boost::vector_property_map<int>,
169 boost::vector_property_map<int> > disjoint_sets_;
176 void build_sets()
const;
178 unsigned int get_number_of_sets()
const {
182 ParticlesTemp get_set(
unsigned int i)
const {
193 Ints &used),
const, );
197 if (set_indexes_.find(p)== set_indexes_.end()) {
200 return set_indexes_.find(p)->second;
204 void add_set(
const ParticlesTemp &ps);
208 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
209 inline DisjointSetsSubsetFilterTable
214 disjoint_sets_(rank_, parent_){}
215 inline DisjointSetsSubsetFilterTable
216 ::DisjointSetsSubsetFilterTable(std::string name):
217 SubsetFilterTable(name),
218 disjoint_sets_(rank_, parent_){}
271 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
274 Pointer<ParticleStatesTable> pst_;
275 mutable double num_ok_, num_test_;
277 void load_indexes(
const Subset &s,
278 Ints &indexes)
const;
279 void mask_allowed_states(
Particle *p,
const boost::dynamic_bitset<> &bs);
283 double get_ok_rate()
const {
284 return num_ok_/num_test_;
286 unsigned int get_number_of_particle_states(
Particle *p)
const {
289 return pst_->get_particle_states(p)->get_number_of_particle_states();
292 <<
" is unknown. It probably is not in the "
293 <<
" ParticleStatesTable. Boom.");
294 return states_[i].size();
296 void set_allowed_states(
Particle *p,
const Ints &states);
315 void fill(
const Subset &s,
343 bool leaves_only=
false);
349 IMPDOMINO_END_NAMESPACE