IMP  2.3.0
The Integrative Modeling Platform
DiscreteSampler.h
Go to the documentation of this file.
1 /**
2  * \file IMP/domino/DiscreteSampler.h
3  * \brief A base class for discrete samplers.
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPDOMINO_DISCRETE_SAMPLER_H
10 #define IMPDOMINO_DISCRETE_SAMPLER_H
11 
12 #include <IMP/domino/domino_config.h>
13 #include "assignment_tables.h"
14 #include "particle_states.h"
15 #include "subset_filters.h"
17 #include <IMP/Sampler.h>
18 #include <IMP/macros.h>
19 #include <IMP/base/Pointer.h>
20 #include <IMP/base_types.h>
21 IMPDOMINO_BEGIN_NAMESPACE
22 
23 //! A base class for discrete samplers in Domino2
24 /** All the samplers derived from it share some common properties:
25  - each particle is allowed to have one of a discrete set of
26  conformations, as stored in a ParticleStatesTable
27  - there is, optionally, one scoring function, accessed through
28  the SubsetEvaluatorTable
29  - there can be many SubsetFilterTable objects which are
30  used to prune the discrete space.
31 
32  Defaults are provided for all the parameters:
33  - if no SubsetFilterTables are provided, then the
34  ExclusionSubsetFilterTable and the
35  kernel::RestraintScoreSubsetFilterTable are used.
36 
37  \note the restraint scores must be non-negative in general.
38  If you are using restraints which can produce negative values,
39  we can provide a restraint which wraps another and makes
40  it non-negative. Ping us.
41 
42  \note The discrete samplers enumerate all acceptable
43  conformations. As a result, users should take care to
44  remove uninteresting degrees of freedom (for example,
45  remove rigid transformations of a complex). Techniques
46  to do this can involve pinning one or more particles (by
47  locking them to a single conformation or to a few
48  degrees of freedom).
49  */
50 class IMPDOMINOEXPORT DiscreteSampler : public Sampler {
53  unsigned int max_;
54 
55  protected:
56  SubsetFilterTables get_subset_filter_tables_to_use(
57  const kernel::RestraintsTemp &rs, ParticleStatesTable *pst) const;
58  AssignmentsTable *get_assignments_table_to_use(
59  const SubsetFilterTables &sfts,
60  unsigned int max = std::numeric_limits<int>::max()) const;
61  virtual ConfigurationSet *do_sample() const IMP_OVERRIDE;
62  virtual Assignments do_get_sample_assignments(const Subset &all) const = 0;
63 
64  public:
65  DiscreteSampler(kernel::Model *m, ParticleStatesTable *pst, std::string name);
66 
67  ~DiscreteSampler();
68 
69  /** kernel::Particle states can be set either using this method,
70  or equivalently, by accessing the table itself
71  using get_particle_states_table(). This method
72  is provided for users who want to use the default values
73  and want a simple interface.*/
75  pst_->set_particle_states(p, se);
76  }
77 
78  /** Return the Assignment objects describing the subsets fitting
79  the description.
80 
81  \note At the moment, Subset must be equal to
82  Subset(ParticleStatesTable::get_particles()).
83  */
84  Assignments get_sample_assignments(const Subset &s) const;
85 
86  /** \name Advanced
87  Default values are provided, you only need to replace these
88  if you want to do something special. See the overview of
89  the module for a general description.
90  @{
91  */
92  void set_particle_states_table(ParticleStatesTable *cse) { pst_ = cse; }
93  void set_assignments_table(AssignmentsTable *sst) { sst_ = sst; }
94  ParticleStatesTable *get_particle_states_table() const { return pst_; }
95  IMP_LIST_ACTION(public, SubsetFilterTable, SubsetFilterTables,
96  subset_filter_table, subset_filter_tables,
97  SubsetFilterTable *, SubsetFilterTables,
98  obj->set_was_used(true), , );
99  /** @} */
100 
101  /** Limit the number of states that is ever produced for any
102  set of particles.
103 
104  Doing this can be useful to get some feedback when too
105  many states would otherwise be produced. A warning
106  will be emitted whenever the limit eliminates states.
107  */
108  void set_maximum_number_of_assignments(unsigned int mx) { max_ = mx; }
109  unsigned int get_maximum_number_of_assignments() const { return max_; }
110 };
111 
113 
114 IMPDOMINO_END_NAMESPACE
115 
116 #endif /* IMPDOMINO_DISCRETE_SAMPLER_H */
A class to store a set of configurations of a model.
Import IMP/kernel/base_types.h in the namespace.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:147
void set_particle_states(kernel::Particle *p, ParticleStates *se)
A base class for discrete samplers in Domino2.
A Bayesian inference-based sampler.
Represent a subset of the particles being optimized.
Definition: Subset.h:33
Import IMP/kernel/macros.h in the namespace.
A Bayesian inference-based sampler.
void set_maximum_number_of_assignments(unsigned int mx)
Import IMP/kernel/Sampler.h in the namespace.
Various general useful macros for IMP.
Class to handle individual model particles.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Definition: object_macros.h:52
A nullptr-initialized pointer to an IMP Object.
IMP::base::Vector< IMP::base::Pointer< SubsetFilterTable > > SubsetFilterTables
Base class for all samplers.
A Bayesian inference-based sampler.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73