IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2026 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>
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
25IMPDOMINO_BEGIN_NAMESPACE
26class 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*/
32class 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;
37 ~AssignmentsTable();
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*/
46class IMPDOMINOEXPORT SimpleAssignmentsTable : public AssignmentsTable {
49 unsigned int max_;
50
51 public:
52 SimpleAssignmentsTable(ParticleStatesTable *pst,
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;
58 IMP_OBJECT_METHODS(SimpleAssignmentsTable);
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*/
65class IMPDOMINOEXPORT RecursiveAssignmentsTable : public AssignmentsTable {
68 unsigned int max_;
69
70 public:
71 RecursiveAssignmentsTable(ParticleStatesTable *pst,
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;
78 IMP_OBJECT_METHODS(RecursiveAssignmentsTable);
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*/
91class 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:
98 unsigned int max_;
99#if IMP_HAS_CHECKS >= IMP_INTERNAL
100 boost::unordered_map<Particle *, ParticlesTemp> rls_;
101#endif
102#endif
103 public:
104 BranchAndBoundAssignmentsTable(ParticleStatesTable *pst,
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;
111 IMP_OBJECT_METHODS(BranchAndBoundAssignmentsTable);
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*/
119class 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;
131 IMP_OBJECT_METHODS(ListAssignmentsTable);
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*/
138IMPDOMINOEXPORT ParticlesTemp get_order(const Subset &s,
139 const SubsetFilterTables &sft);
140
141IMPDOMINO_END_NAMESPACE
142
143#endif /* IMPDOMINO_ASSIGNMENT_TABLES_H */
A Bayesian inference-based sampler.
Base class for all samplers.
A Bayesian inference-based sampler.
Container classes to store assignments.
Common base class for heavy weight IMP objects.
Definition Object.h:111
Object(std::string name)
Construct an object with the given name.
The base class for containers of assignments.
void set_assignments(const Subset &s, AssignmentContainer *lsc)
Represent a subset of the particles being optimized.
Definition Subset.h:34
Various important macros for implementing decorators.
Various general useful macros for IMP.
ParticlesTemp get_order(const Subset &s, const SubsetFilterTables &sft)
IMP::Vector< IMP::Pointer< AssignmentsTable > > AssignmentsTables
IMP::Vector< IMP::Pointer< SubsetFilterTable > > SubsetFilterTables
#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 reference counted object.
Definition Pointer.h:88
A Bayesian inference-based sampler.