9 #ifndef IMPDOMINO_SUBSET_FILTERS_H
10 #define IMPDOMINO_SUBSET_FILTERS_H
12 #include <IMP/domino/domino_config.h>
21 #include <boost/unordered_map.hpp>
25 #include <boost/dynamic_bitset.hpp>
29 #include <boost/pending/disjoint_sets.hpp>
31 IMPDOMINO_BEGIN_NAMESPACE
49 virtual bool get_is_ok(
const Assignment &state)
const = 0;
59 return state[pos] + 1;
92 virtual double get_strength(
const Subset &s,
93 const Subsets &prior_subsets)
const = 0;
135 const Subsets &excluded)
const;
140 int max_number_allowed_violations);
141 int get_maximum_number_of_violated_restraints()
const {
142 return max_violated_;
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_;
170 boost::unordered_map<const Particle *, int> index_;
172 mutable boost::unordered_map<const Particle *, int> set_indexes_;
176 void build_sets()
const;
179 unsigned int get_number_of_sets()
const {
183 ParticlesTemp get_set(
unsigned int i)
const {
return sets_[i]; }
189 int get_index_in_set(
Particle *p)
const {
190 if (set_indexes_.find(p) == set_indexes_.end()) {
193 return set_indexes_.find(p)->second;
203 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
204 inline DisjointSetsSubsetFilterTable::DisjointSetsSubsetFilterTable(
207 inline DisjointSetsSubsetFilterTable::DisjointSetsSubsetFilterTable(
209 : SubsetFilterTable(name), disjoint_sets_(rank_, parent_) {}
255 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
256 boost::unordered_map<Particle *, int> map_;
259 mutable double num_ok_, num_test_;
261 void load_indexes(
const Subset &s,
Ints &indexes)
const;
262 void mask_allowed_states(
Particle *p,
263 const boost::dynamic_bitset<> &bs);
267 double get_ok_rate()
const {
return num_ok_ / num_test_; }
268 unsigned int get_number_of_particle_states(
Particle *p)
const {
271 return pst_->get_particle_states(p)->get_number_of_particle_states();
274 "Particle " << p->get_name()
275 <<
" is unknown. It probably is not in the "
276 <<
" ParticleStatesTable. Boom.");
277 return states_[i].size();
279 void set_allowed_states(
Particle *p,
const Ints &states);
299 boost::unordered_map<ParticlePair, IntPairs> allowed_;
343 IMPDOMINO_END_NAMESPACE
Include the correct headers to get the boost vector_property_map.
Maintain an explicit list of what states each particle is allowed to have.
virtual SubsetFilter * get_subset_filter(const Subset &s, const Subsets &prior_subsets) const =0
A Bayesian inference-based sampler.
RestraintsTemp get_restraints(const Subset &s, const ParticleStatesTable *pst, const DependencyGraph &dg, RestraintSet *rs)
A class to store an fixed array of same-typed values.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
Filter a configuration of the subset using the Model thresholds.
Represent a subset of the particles being optimized.
Various general useful macros for IMP.
A more IMP-like version of the std::vector.
A smart pointer to a reference counted object.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Common base class for heavy weight IMP objects.
Provide a consistent interface for things that take Restraints as arguments.
Various general useful macros for IMP.
Various important macros for implementing decorators.
A smart pointer to a ref-counted Object that is a class member.
virtual double get_strength(const Subset &s, const Subsets &prior_subsets) const =0
The strength is a rough metric of how this filter restricts the subset.
A Bayesian inference-based sampler.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
A nullptr-initialized pointer to an IMP Object.
A shared base class to help in debugging and things.
Store a configuration of a subset.
Object(std::string name)
Construct an object with the given name.
Class to handle individual particles of a Model object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A Bayesian inference-based sampler.
Store a set of configurations of the model.
Filter a configuration of the subset using the Model thresholds.
virtual int get_next_state(int pos, const Assignment &state) const
Return a next possible acceptable state for the particle in pos.
A Bayesian inference-based sampler.
ParticleIndexes get_indexes(const ParticlesTemp &ps)
Get the indexes from a list of particles.
#define IMP_DISJOINT_SUBSET_FILTER_TABLE_DECL(Name)