IMP logo
IMP Reference Guide  2.7.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-2017 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_;
34 
35  public:
36  Sampler(Model *m, std::string name = "Sampler %1%");
37  ConfigurationSet *create_sample() const;
38 
39  //! Return the scoring function that is being used
40  /** \throws ValueException if no scoring function was set
41  */
43  if (sf_) {
44  return sf_;
45  } else {
46  IMP_THROW("No scoring function was set. "
47  "Use Sampler::set_scoring_function() to set one.",
49  }
50  }
51 
52  void set_scoring_function(ScoringFunctionAdaptor sf);
53 
54  Model *get_model() const { return model_; }
55 
56  protected:
57  virtual ConfigurationSet *do_sample() const = 0;
58 
59  // for the vtable
61  //! Subclasses should override this method
62 };
63 
65 
66 IMPKERNEL_END_NAMESPACE
67 
68 #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 more IMP-like version of the std::vector.
Definition: Vector.h:39
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 lists of object pointers.
Definition: object_macros.h:44
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Definition: check_macros.h:50
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)
Store a set of configurations of the model.
An exception for an invalid value being passed to IMP.
Definition: exception.h:137
ScoringFunction * get_scoring_function() const
Return the scoring function that is being used.
Definition: Sampler.h:42