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>
27#include <boost/property_map/property_map.hpp>
29#include <boost/pending/disjoint_sets.hpp>
31IMPDOMINO_BEGIN_NAMESPACE
46 SubsetFilter(std::string name =
"SubsetFilter%1%");
59 return state[pos] + 1;
80 SubsetFilterTable(std::string name =
"SubsetFilterTable%1%") :
Object(name) {}
93 const Subsets &prior_subsets)
const = 0;
95 virtual ~SubsetFilterTable();
104class IMPDOMINOEXPORT RestraintScoreSubsetFilterTable
105 :
public SubsetFilterTable {
129class IMPDOMINOEXPORT MinimumRestraintScoreSubsetFilterTable
130 :
public SubsetFilterTable {
135 const Subsets &excluded)
const;
140 int max_number_allowed_violations);
141 int get_maximum_number_of_violated_restraints()
const {
142 return max_violated_;
164class IMPDOMINOEXPORT DisjointSetsSubsetFilterTable :
public SubsetFilterTable {
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_;
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]; }
185 DisjointSetsSubsetFilterTable(std::string name);
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;
199 void add_set(
const ParticlesTemp &ps);
203#if !defined(SWIG) && !defined(IMP_DOXYGEN)
204inline DisjointSetsSubsetFilterTable::DisjointSetsSubsetFilterTable(
207inline DisjointSetsSubsetFilterTable::DisjointSetsSubsetFilterTable(
209 : SubsetFilterTable(name), disjoint_sets_(rank_, parent_) {}
253class IMPDOMINOEXPORT ListSubsetFilterTable :
public SubsetFilterTable {
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);
298class IMPDOMINOEXPORT PairListSubsetFilterTable :
public SubsetFilterTable {
299 boost::unordered_map<ParticlePair, IntPairs> allowed_;
304 PairListSubsetFilterTable();
322 :
public SubsetFilterTable {
343IMPDOMINO_END_NAMESPACE
A Bayesian inference-based sampler.
Store a single configuration of the model.
Storage of a model, its restraints, constraints and particles.
A shared base class to help in debugging and things.
A nullptr-initialized pointer to an IMP Object.
A Bayesian inference-based sampler.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Common base class for heavy weight IMP objects.
Object(std::string name)
Construct an object with the given name.
Class to handle individual particles of a Model object.
Provide a consistent interface for things that take Restraints as arguments.
A more IMP-like version of the std::vector.
Store a configuration of a subset.
Maintain an explicit list of what states each particle is allowed to have.
virtual IMP::domino::SubsetFilter * get_subset_filter(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
virtual double get_strength(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
The strength is a rough metric of how this filter restricts the subset.
Filter a configuration of the subset using the Model thresholds.
virtual double get_strength(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
The strength is a rough metric of how this filter restricts the subset.
virtual IMP::domino::SubsetFilter * get_subset_filter(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
virtual IMP::domino::SubsetFilter * get_subset_filter(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
virtual double get_strength(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
The strength is a rough metric of how this filter restricts the subset.
virtual IMP::domino::SubsetFilter * get_subset_filter(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
ProbabilisticSubsetFilterTable(double p, bool leaves_only=false)
virtual double get_strength(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
The strength is a rough metric of how this filter restricts the subset.
Filter a configuration of the subset using the Model thresholds.
RestraintScoreSubsetFilterTable(RestraintsAdaptor rs, ParticleStatesTable *pst)
virtual double get_strength(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
The strength is a rough metric of how this filter restricts the subset.
virtual IMP::domino::SubsetFilter * get_subset_filter(const IMP::domino::Subset &s, const IMP::domino::Subsets &excluded) const override
virtual SubsetFilter * get_subset_filter(const Subset &s, const Subsets &prior_subsets) const =0
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.
virtual int get_next_state(int pos, const Assignment &state) const
Return a next possible acceptable state for the particle in pos.
virtual bool get_is_ok(const Assignment &state) const =0
Represent a subset of the particles being optimized.
Various important macros for implementing decorators.
#define IMP_DISJOINT_SUBSET_FILTER_TABLE_DECL(Name)
Various general useful macros for IMP.
IMP::Vector< IMP::Pointer< RestraintScoreSubsetFilterTable > > RestraintScoreSubsetFilterTables
IMP::Vector< IMP::Pointer< PairListSubsetFilterTable > > PairListSubsetFilterTables
IMP::Vector< IMP::Pointer< MinimumRestraintScoreSubsetFilterTable > > MinimumRestraintScoreSubsetFilterTables
IMP::Vector< IMP::Pointer< SubsetFilterTable > > SubsetFilterTables
IMP::Vector< IMP::Pointer< ListSubsetFilterTable > > ListSubsetFilterTables
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
IMP::Vector< IMP::Pointer< SubsetFilter > > SubsetFilters
IMP::Vector< Subset > Subsets
IMP::Vector< IMP::Pointer< Restraint > > Restraints
IMP::Vector< IntPair > IntPairs
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
IMP::Vector< IMP::WeakPointer< Restraint > > RestraintsTemp
Array< 2, WeakPointer< Particle >, Particle * > ParticlePair
ParticleIndexes get_indexes(const ParticlesTemp &ps)
Get the indexes from a list of particles.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A Bayesian inference-based sampler.
A smart pointer to a ref-counted Object that is a class member.
A smart pointer to a reference counted object.
A Bayesian inference-based sampler.
Various general useful macros for IMP.