IMP  2.0.1
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 beyesian infererence-based sampler.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPDOMINO_ASSIGNMENT_TABLES_H
10 #define IMPDOMINO_ASSIGNMENT_TABLES_H
11 
12 
13 #include "particle_states.h"
14 #include "subset_filters.h"
15 #include "Assignment.h"
16 #include "Subset.h"
17 #include <IMP/domino/domino_config.h>
18 #include "assignment_containers.h"
19 #include "domino_macros.h"
20 #include <IMP/Sampler.h>
21 #include <IMP/macros.h>
22 #include <IMP/base/map.h>
23 #include <boost/pending/disjoint_sets.hpp>
24 #if BOOST_VERSION > 103900
25 #include <boost/property_map/property_map.hpp>
26 #else
27 #include <boost/property_map.hpp>
28 #endif
29 
30 IMPDOMINO_BEGIN_NAMESPACE
31 class DominoSampler;
32 
33 /** The base class for classes that create Assignments, one per
34  subset. The main method of interest is load_assignments()
35  which enumerates the assignments and loads them into an AssignmentContainer.
36 */
37 class IMPDOMINOEXPORT AssignmentsTable: public IMP::base::Object {
38  public:
39  AssignmentsTable(std::string name= "SubsetStatesTable %1%"): Object(name){}
40  virtual void load_assignments(const Subset &s,
41  AssignmentContainer *ac) const=0;
43 };
44 
46 
47 
48 /** The produced states are filtered using the provided
49  SubsetFilterTable objects. The assignments are enumerated
50  and filtered in a straight forward manner.
51 */
52 class IMPDOMINOEXPORT SimpleAssignmentsTable:
53  public AssignmentsTable {
54  Pointer<ParticleStatesTable> pst_;
55  SubsetFilterTables sft_;
56  unsigned int max_;
57  public:
59  const SubsetFilterTables &sft
61  unsigned int max
62  = std::numeric_limits<unsigned int>::max());
64 };
65 
66 
67 /** The produced states are filtered using the provided
68  SubsetFilterTable objects. The assignments are enumerated
69  and filtered by recursively dividing the subset in half.
70 */
71 class IMPDOMINOEXPORT RecursiveAssignmentsTable:
72  public AssignmentsTable {
73  Pointer<ParticleStatesTable> pst_;
74  SubsetFilterTables sft_;
75  unsigned int max_;
76  public:
78  const SubsetFilterTables &sft
80  unsigned int max
81  = std::numeric_limits<unsigned int>::max());
83 };
84 
85 
86 /** Enumerate states based on provided ParticleStates
87  objects.
88 
89  The produced states are filtered using the provided
90  SubsetFilterTable objects. Branch and bound is used
91  to try to make this process more efficient. To do that
92  the SubsetFilterTable::get_strength() method is used
93  to order the particles from most restricted to least
94  restricted.
95 */
96 class IMPDOMINOEXPORT BranchAndBoundAssignmentsTable:
97  public AssignmentsTable {
98 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
99 /* MSVC/Sun gcc appears confused by a friend class in the anonymous namespace */
100 public:
101  Pointer<ParticleStatesTable> pst_;
102  SubsetFilterTables sft_;
103  unsigned int max_;
104 #if IMP_HAS_CHECKS >= IMP_INTERNAL
106 #endif
107 #endif
108  public:
110  const SubsetFilterTables &sft
111  = SubsetFilterTables(),
112  unsigned int max
113  = std::numeric_limits<unsigned int>::max());
115 };
116 
117 
118 /** Store a map of Assignments objects and return them on demand. This table
119  should be used when each subset is sampled using some other protocol
120  (eg Monte Carlo or molecular dynamics) and those states are then fed
121  in to domino.
122 */
123 class IMPDOMINOEXPORT ListAssignmentsTable: public AssignmentsTable {
125  IMP::OwnerPointer<AssignmentContainer> >
126  states_;
127  public:
128  ListAssignmentsTable(std::string name="ListSubsetStatesTable %1%");
129  /** There must not be any duplicates in the list */
131  states_[s]=lsc;
132  }
134 };
135 
136 
137 /** Return the order computed for the particles in the subset to be used for
138  enumeration. This function is there in order to expose internal
139  functionality for easier testing and should not be depended upon.
140 */
141 IMPDOMINOEXPORT ParticlesTemp get_order(const Subset &s,
142  const SubsetFilterTables &sft);
143 
144 IMPDOMINO_END_NAMESPACE
145 
146 #endif /* IMPDOMINO_ASSIGNMENT_TABLES_H */