IMP logo
IMP Reference Guide  develop.27926d84dc,2024/04/19
The Integrative Modeling Platform
assignment_tables.h
Go to the documentation of this file.
1 /**
2  * \file IMP/domino/assignment_tables.h
3  * \brief A Bayesian inference-based sampler.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPDOMINO_ASSIGNMENT_TABLES_H
10 #define IMPDOMINO_ASSIGNMENT_TABLES_H
11 
12 #include "particle_states.h"
13 #include "subset_filters.h"
14 #include "Assignment.h"
15 #include "Subset.h"
16 #include <IMP/domino/domino_config.h>
17 #include "assignment_containers.h"
18 #include "domino_macros.h"
19 #include <IMP/Sampler.h>
20 #include <IMP/macros.h>
21 #include <boost/unordered_map.hpp>
22 #include <boost/pending/disjoint_sets.hpp>
23 #include <boost/property_map/property_map.hpp>
24 
25 IMPDOMINO_BEGIN_NAMESPACE
26 class DominoSampler;
27 
28 /** The base class for classes that create Assignments, one per
29  subset. The main method of interest is load_assignments()
30  which enumerates the assignments and loads them into an AssignmentContainer.
31 */
32 class IMPDOMINOEXPORT AssignmentsTable : public IMP::Object {
33  public:
34  AssignmentsTable(std::string name = "AssignmentsTable %1%") : Object(name) {}
35  virtual void load_assignments(const Subset &s,
36  AssignmentContainer *ac) const = 0;
38 };
39 
41 
42 /** The produced states are filtered using the provided
43  SubsetFilterTable objects. The assignments are enumerated
44  and filtered in a straight forward manner.
45 */
46 class IMPDOMINOEXPORT SimpleAssignmentsTable : public AssignmentsTable {
48  SubsetFilterTables sft_;
49  unsigned int max_;
50 
51  public:
54  unsigned int max =
55  std::numeric_limits<unsigned int>::max());
56  virtual void load_assignments(const IMP::domino::Subset &s,
57  AssignmentContainer *ac) const override;
59 };
60 
61 /** The produced states are filtered using the provided
62  SubsetFilterTable objects. The assignments are enumerated
63  and filtered by recursively dividing the subset in half.
64 */
65 class IMPDOMINOEXPORT RecursiveAssignmentsTable : public AssignmentsTable {
67  SubsetFilterTables sft_;
68  unsigned int max_;
69 
70  public:
72  const SubsetFilterTables &sft =
74  unsigned int max =
75  std::numeric_limits<unsigned int>::max());
76  virtual void load_assignments(const IMP::domino::Subset &s,
77  AssignmentContainer *ac) const override;
79 };
80 
81 /** Enumerate states based on provided ParticleStates
82  objects.
83 
84  The produced states are filtered using the provided
85  SubsetFilterTable objects. Branch and bound is used
86  to try to make this process more efficient. To do that
87  the SubsetFilterTable::get_strength() method is used
88  to order the particles from most restricted to least
89  restricted.
90 */
91 class IMPDOMINOEXPORT BranchAndBoundAssignmentsTable : public AssignmentsTable {
92 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
93  /* MSVC/Sun gcc appears confused by a friend class in the anonymous namespace
94  */
95  public:
97  SubsetFilterTables sft_;
98  unsigned int max_;
99 #if IMP_HAS_CHECKS >= IMP_INTERNAL
100  boost::unordered_map<Particle *, ParticlesTemp> rls_;
101 #endif
102 #endif
103  public:
105  const SubsetFilterTables &sft =
107  unsigned int max =
108  std::numeric_limits<unsigned int>::max());
109  virtual void load_assignments(const IMP::domino::Subset &s,
110  AssignmentContainer *ac) const override;
112 };
113 
114 /** Store a map of Assignments objects and return them on demand. This table
115  should be used when each subset is sampled using some other protocol
116  (eg Monte Carlo or molecular dynamics) and those states are then fed
117  in to domino.
118 */
119 class IMPDOMINOEXPORT ListAssignmentsTable : public AssignmentsTable {
120  boost::unordered_map<Subset, IMP::PointerMember<AssignmentContainer> >
121  states_;
122 
123  public:
124  ListAssignmentsTable(std::string name = "ListAssignmentsTable %1%");
125  /** There must not be any duplicates in the list */
127  states_[s] = lsc;
128  }
129  virtual void load_assignments(const IMP::domino::Subset &s,
130  AssignmentContainer *ac) const override;
132 };
133 
134 /** Return the order computed for the particles in the subset to be used for
135  enumeration. This function is there in order to expose internal
136  functionality for easier testing and should not be depended upon.
137 */
138 IMPDOMINOEXPORT ParticlesTemp get_order(const Subset &s,
139  const SubsetFilterTables &sft);
140 
141 IMPDOMINO_END_NAMESPACE
142 
143 #endif /* IMPDOMINO_ASSIGNMENT_TABLES_H */
The base class for containers of assignments.
A Bayesian inference-based sampler.
void set_assignments(const Subset &s, AssignmentContainer *lsc)
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A Bayesian inference-based sampler.
Represent a subset of the particles being optimized.
Definition: Subset.h:33
Various general useful macros for IMP.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
A smart pointer to a reference counted object.
Definition: Pointer.h:87
Common base class for heavy weight IMP objects.
Definition: Object.h:111
ParticlesTemp get_order(const Subset &s, const SubsetFilterTables &sft)
Base class for all samplers.
Various important macros for implementing decorators.
IMP::Vector< IMP::Pointer< SubsetFilterTable > > SubsetFilterTables
A Bayesian inference-based sampler.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
Object(std::string name)
Construct an object with the given name.
Container classes to store assignments.
A Bayesian inference-based sampler.