IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
DominoSampler.h
Go to the documentation of this file.
1/**
2 * \file IMP/domino/DominoSampler.h
3 * \brief Sample best solutions using Domino.
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPDOMINO_DOMINO_SAMPLER_H
10#define IMPDOMINO_DOMINO_SAMPLER_H
11
12#include <IMP/domino/domino_config.h>
13//#include "Evaluator.h"
14#include "DiscreteSampler.h"
15#include "subset_graphs.h"
16#include "internal/inference_utility.h"
17#include <IMP/Sampler.h>
18#include <IMP/macros.h>
19#include <IMP/Pointer.h>
20
21IMPDOMINO_BEGIN_NAMESPACE
22#ifdef SWIG
23class SubsetGraph;
24#endif
25
26//! Sample best solutions using Domino
27/** Note that if there are many solutions, the ConfigurationSet returned
28 by get_sample() might be huge (in terms of memory usage) and slow to
29 generate. The Assignments returned by get_sample_assignments() can be
30 a lot smaller and faster.
31 */
32class IMPDOMINOEXPORT DominoSampler : public DiscreteSampler {
34 SubsetGraph sg_;
35 MergeTree mt_;
36 bool has_mt_;
37 bool csf_;
38 mutable internal::InferenceStatistics stats_;
39
40 public:
41 DominoSampler(Model *m, std::string name = "DominoSampler %1%");
42 DominoSampler(Model *m, ParticleStatesTable *pst,
43 std::string name = "DominoSampler %1%");
44 Assignments do_get_sample_assignments(const IMP::domino::Subset &known) const
45 override;
46 IMP_OBJECT_METHODS(DominoSampler);
47
48 public:
49 /** \name Advanced
50 Default values are provided, you only need to replace these
51 if you want to do something special. See the overview of
52 the module for a general description.
53 @{
54 */
55 //! Specify the merge tree directly
56 void set_merge_tree(const MergeTree &mt);
57 /** @} */
58
59 /** perform filtering between subsets based by eliminating states
60 that cannot be realized in a subset.
61 */
62 void set_use_cross_subset_filtering(bool tf) { csf_ = tf; }
63
64 /** \name Statistics
65 If you specify the merge tree explicitly, you can query
66 for statistics about particular nodes in the merge tree.
67 @{
68 */
69 //! Get the number of states found for the merge at that vertex of the tree
70 unsigned int get_number_of_assignments_for_vertex(unsigned int tree_vertex)
71 const;
72 //! Return a few subset states from that merge
73 Assignments get_sample_assignments_for_vertex(unsigned int tree_vertex) const;
74 /** @} */
75
76 /** \name Interactive mode
77 Once a merge tree is specified, one can interactively perform the
78 sampling by requesting that domino fill in the Assignments for a
79 given node of the merge tree from the assignments for the children.
80 This can be useful for debugging Domino as well as for providing
81 a distributed implementation.
82
83 For each method, you can pass max_states to limit how many states are
84 generated.
85
86 You might want to just use load_leaf_assignments() and
87 load_merged_assignments() instead.
88 @{
89 */
90 //! Fill in assignments for a leaf
91 Assignments get_vertex_assignments(unsigned int node_index,
92 unsigned int max_states =
93 std::numeric_limits<int>::max()) const;
94 //! Fill in assignments for an internal node
95 /** The passed assignments, the ordering for the children is
96 the node index for the children.
97 */
98 Assignments get_vertex_assignments(unsigned int node_index,
99 const Assignments &first,
100 const Assignments &second,
101 unsigned int max_states =
102 std::numeric_limits<int>::max()) const;
103
104 //! Fill in assignments for a leaf
105 void load_vertex_assignments(unsigned int node_index, AssignmentContainer *ac,
106 unsigned int max_states =
107 std::numeric_limits<int>::max()) const;
108 //! Fill in assignments for an internal node
109 /** The passed assignments, the ordering for the children is that of
110 the node indexes for the children.
111 */
112 void load_vertex_assignments(unsigned int node_index,
113 AssignmentContainer *first,
114 AssignmentContainer *second,
116 unsigned int max_states =
117 std::numeric_limits<int>::max()) const;
118
119 /** @} */
120};
121
123
124IMPDOMINO_END_NAMESPACE
125
126#endif /* IMPDOMINO_DOMINO_SAMPLER_H */
A base class for discrete samplers.
A nullptr-initialized pointer to an IMP Object.
Base class for all samplers.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
The base class for containers of assignments.
Sample best solutions using Domino.
void load_vertex_assignments(unsigned int node_index, AssignmentContainer *ac, unsigned int max_states=std::numeric_limits< int >::max()) const
Fill in assignments for a leaf.
void set_use_cross_subset_filtering(bool tf)
void set_merge_tree(const MergeTree &mt)
Specify the merge tree directly.
Assignments get_sample_assignments_for_vertex(unsigned int tree_vertex) const
Return a few subset states from that merge.
unsigned int get_number_of_assignments_for_vertex(unsigned int tree_vertex) const
Get the number of states found for the merge at that vertex of the tree.
Assignments get_vertex_assignments(unsigned int node_index, unsigned int max_states=std::numeric_limits< int >::max()) const
Fill in assignments for a leaf.
void load_vertex_assignments(unsigned int node_index, AssignmentContainer *first, AssignmentContainer *second, AssignmentContainer *ac, unsigned int max_states=std::numeric_limits< int >::max()) const
Fill in assignments for an internal node.
Assignments get_vertex_assignments(unsigned int node_index, const Assignments &first, const Assignments &second, unsigned int max_states=std::numeric_limits< int >::max()) const
Fill in assignments for an internal node.
Represent a subset of the particles being optimized.
Definition Subset.h:34
Various general useful macros for IMP.
IMP::Vector< Assignment > Assignments
Definition Assignment.h:53
boost::graph MergeTree
boost::graph SubsetGraph
IMP::Vector< IMP::Pointer< DominoSampler > > DominoSamplers
#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 smart pointer to a reference counted object.
Definition Pointer.h:88
A Bayesian inference-based sampler.