IMP logo
IMP Reference Guide  develop.63b38c487d,2024/12/21
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 
21 IMPDOMINO_BEGIN_NAMESPACE
22 #ifdef SWIG
23 class 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  */
32 class 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%");
43  std::string name = "DominoSampler %1%");
44  Assignments do_get_sample_assignments(const IMP::domino::Subset &known) const
45  override;
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 
124 IMPDOMINO_END_NAMESPACE
125 
126 #endif /* IMPDOMINO_DOMINO_SAMPLER_H */
The base class for containers of assignments.
A Bayesian inference-based sampler.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A base class for discrete samplers in Domino2.
Sample best solutions using Domino.
Definition: DominoSampler.h:32
boost::graph SubsetGraph
Definition: subset_graphs.h:23
Represent a subset of the particles being optimized.
Definition: Subset.h:33
Various general useful macros for IMP.
A smart pointer to a reference counted object.
Definition: Pointer.h:87
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A base class for discrete samplers.
boost::graph MergeTree
Base class for all samplers.
void set_use_cross_subset_filtering(bool tf)
Definition: DominoSampler.h:62
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
A nullptr-initialized pointer to an IMP Object.