IMP  2.2.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-2014 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 #if BOOST_VERSION > 103900
24 #include <boost/property_map/property_map.hpp>
25 #else
26 #include <boost/property_map.hpp>
27 #endif
28 
29 IMPDOMINO_BEGIN_NAMESPACE
30 class DominoSampler;
31 
32 /** The base class for classes that create Assignments, one per
33  subset. The main method of interest is load_assignments()
34  which enumerates the assignments and loads them into an AssignmentContainer.
35 */
36 class IMPDOMINOEXPORT AssignmentsTable : public IMP::base::Object {
37  public:
38  AssignmentsTable(std::string name = "SubsetStatesTable %1%") : Object(name) {}
39  virtual void load_assignments(const Subset &s,
40  AssignmentContainer *ac) const = 0;
42 };
43 
45 
46 /** The produced states are filtered using the provided
47  SubsetFilterTable objects. The assignments are enumerated
48  and filtered in a straight forward manner.
49 */
50 class IMPDOMINOEXPORT SimpleAssignmentsTable : public AssignmentsTable {
52  SubsetFilterTables sft_;
53  unsigned int max_;
54 
55  public:
58  unsigned int max =
59  std::numeric_limits<unsigned int>::max());
60  virtual void load_assignments(const IMP::domino::Subset &s,
61  AssignmentContainer *ac) const IMP_OVERRIDE;
63 };
64 
65 /** The produced states are filtered using the provided
66  SubsetFilterTable objects. The assignments are enumerated
67  and filtered by recursively dividing the subset in half.
68 */
69 class IMPDOMINOEXPORT RecursiveAssignmentsTable : public AssignmentsTable {
71  SubsetFilterTables sft_;
72  unsigned int max_;
73 
74  public:
76  const SubsetFilterTables &sft =
78  unsigned int max =
79  std::numeric_limits<unsigned int>::max());
80  virtual void load_assignments(const IMP::domino::Subset &s,
81  AssignmentContainer *ac) const IMP_OVERRIDE;
83 };
84 
85 /** Enumerate states based on provided ParticleStates
86  objects.
87 
88  The produced states are filtered using the provided
89  SubsetFilterTable objects. Branch and bound is used
90  to try to make this process more efficient. To do that
91  the SubsetFilterTable::get_strength() method is used
92  to order the particles from most restricted to least
93  restricted.
94 */
95 class IMPDOMINOEXPORT BranchAndBoundAssignmentsTable : public AssignmentsTable {
96 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
97  /* MSVC/Sun gcc appears confused by a friend class in the anonymous namespace
98  */
99  public:
101  SubsetFilterTables sft_;
102  unsigned int max_;
103 #if IMP_HAS_CHECKS >= IMP_INTERNAL
104  boost::unordered_map<kernel::Particle *, kernel::ParticlesTemp> rls_;
105 #endif
106 #endif
107  public:
109  const SubsetFilterTables &sft =
111  unsigned int max =
112  std::numeric_limits<unsigned int>::max());
113  virtual void load_assignments(const IMP::domino::Subset &s,
114  AssignmentContainer *ac) const IMP_OVERRIDE;
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 {
124  boost::unordered_map<Subset, IMP::base::PointerMember<AssignmentContainer> >
125  states_;
126 
127  public:
128  ListAssignmentsTable(std::string name = "ListSubsetStatesTable %1%");
129  /** There must not be any duplicates in the list */
131  states_[s] = lsc;
132  }
133  virtual void load_assignments(const IMP::domino::Subset &s,
134  AssignmentContainer *ac) const IMP_OVERRIDE;
136 };
137 
138 /** Return the order computed for the particles in the subset to be used for
139  enumeration. This function is there in order to expose internal
140  functionality for easier testing and should not be depended upon.
141 */
142 IMPDOMINOEXPORT kernel::ParticlesTemp get_order(const Subset &s,
143  const SubsetFilterTables &sft);
144 
145 IMPDOMINO_END_NAMESPACE
146 
147 #endif /* IMPDOMINO_ASSIGNMENT_TABLES_H */
kernel::ParticlesTemp get_order(const Subset &s, const SubsetFilterTables &sft)
A beyesian infererence-based sampler.
void set_assignments(const Subset &s, AssignmentContainer *lsc)
A smart pointer to a reference counted object.
Definition: base/Pointer.h:87
A beyesian infererence-based sampler.
Represent a subset of the particles being optimized.
Definition: Subset.h:33
Import IMP/kernel/macros.h in the namespace.
Object(std::string name)
Construct an object with the given name.
Import IMP/kernel/Sampler.h in the namespace.
Various important macros for implementing decorators.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Common base class for heavy weight IMP objects.
Definition: base/Object.h:106
A beyesian infererence-based sampler.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
IMP::base::Vector< IMP::base::Pointer< SubsetFilterTable > > SubsetFilterTables
A beyesian infererence-based sampler.
A beyesian infererence-based sampler.