IMP logo
IMP Reference Guide  2.5.0
The Integrative Modeling Platform
Sampler.h
Go to the documentation of this file.
1 /**
2  * \file IMP/Sampler.h \brief Base class for all samplers.
3  *
4  * Copyright 2007-2015 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPKERNEL_SAMPLER_H
9 #define IMPKERNEL_SAMPLER_H
10 
11 #include <IMP/kernel_config.h>
12 #include "Model.h"
13 #include <IMP/Pointer.h>
14 #include <IMP/Object.h>
15 #include "ConfigurationSet.h"
16 #include <IMP/deprecation_macros.h>
17 #include <IMP/ref_counted_macros.h>
18 
19 IMPKERNEL_BEGIN_NAMESPACE
20 
21 //! Base class for all samplers.
22 /** A sampler takes a Model and searches for good configurations,
23  given the optimizable parameters and the scoring function in
24  the Model and extra information that can be provided. Typically,
25  the current configuration of the model is ignored.
26 
27  Typically a sampler works by using one or more Optimizer
28  types to search for configurations which minimize the scoring
29  function.
30 */
31 class IMPKERNELEXPORT Sampler : public IMP::Object {
32  PointerMember<Model> model_;
33  mutable Pointer<ScoringFunction> cache_;
35 
36  public:
37  Sampler(Model *m, std::string name = "Sampler %1%");
38  ConfigurationSet *create_sample() const;
39 
40  ScoringFunction *get_scoring_function() const {
41  if (sf_) {
42  return sf_;
43  } else if (cache_) {
44  return cache_;
45  } else {
46 /* Don't warn about deprecated model scoring function every time someone
47  includes Sampler.h */
48 IMP_HELPER_MACRO_PUSH_WARNINGS
49 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
50 IMP_GCC_PRAGMA(diagnostic ignored "-Wdeprecated-declarations")
51 #endif
52  return cache_ = get_model()->create_model_scoring_function();
53 IMP_HELPER_MACRO_POP_WARNINGS
54  }
55  }
56 
57  void set_scoring_function(ScoringFunctionAdaptor sf);
58 
59  Model *get_model() const { return model_; }
60 
61  protected:
62  virtual ConfigurationSet *do_sample() const = 0;
63 
64  // for the vtable
66  //! Subclasses should override this method
67 };
68 
70 
71 IMPKERNEL_END_NAMESPACE
72 
73 #endif /* IMPKERNEL_SAMPLER_H */
Control display of deprecation information.
Various general useful macros for IMP.
Storage of a model, its restraints, constraints and particles.
Base class for all samplers.
Definition: Sampler.h:31
A smart pointer to a reference counted object.
Definition: Pointer.h:87
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Common base class for heavy weight IMP objects.
Definition: Object.h:106
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
A class to store a set of configurations of a model.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Definition: object_macros.h:42
A nullptr-initialized pointer to an IMP Object.
Represents a scoring function on the model.
A shared base class to help in debugging and things.
#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Name)