IMP  2.1.0
The Integrative Modeling Platform
kernel/declare_RestraintSet.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/declare_RestraintSet.h
3  * \brief Used to hold a set of related restraints.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_DECLARE_RESTRAINT_SET_H
10 #define IMPKERNEL_DECLARE_RESTRAINT_SET_H
11 
12 #include <IMP/kernel/kernel_config.h>
13 #include "declare_Restraint.h"
14 #include "container_macros.h"
15 #include <IMP/base/map.h>
16 #include <string>
17 
18 IMPKERNEL_BEGIN_NAMESPACE
19 //! Object used to hold a set of restraints
20 /** RestraintSets allow one to define a tree of restraints
21  and to weight various restraints. Upon evaluation,
22  all of the restraints in RestraintSets that have been
23  added to the model are evaluated
24  using the provided weight (weights are multiplicative
25  when RestraintSets are nested).
26 
27  If the weight is 0, the restraints are not evaluated.
28 
29  \note Restraints can belong to multiple RestraintSets.
30  The total effect is simply one of adding up the weights.
31 
32  \headerfile RestraintSet.h "IMP/RestraintSet.h"
33  \advanceddoc
34 
35  Talk to Daniel if you want to inherit from RestraintSet.
36 */
37 class IMPKERNELEXPORT RestraintSet : public Restraint {
38  void on_add(Restraint *r);
39  void on_change();
40  static void on_remove(RestraintSet *container, Restraint *r);
41  void show_it(std::ostream &out) const;
42 
43  public:
44  //! Create an empty set that is registered with the model
45  RestraintSet(kernel::Model *m, double weight,
46  const std::string &name = "RestraintSet %1%");
47  //! Create an empty set that is registered with the model
48  RestraintSet(kernel::Model *m, const std::string &name = "RestraintSet %1%");
49  //! Create a set that is registered with the model
50  RestraintSet(const RestraintsTemp &rs, double weight,
51  const std::string &name = "RestraintSet %1%");
52  /** \deprecated_at{2.1} Use the constructor that takes a Model. */
53  IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
54  RestraintSet(double weight, const std::string &name = "RestraintSet %1%");
55  /** \deprecated_at{2.1} Use the constructor that takes a Model. */
56  IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
57  RestraintSet(const std::string &name = "RestraintSet %1%");
58 
59  double unprotected_evaluate(DerivativeAccumulator *da) const;
61  /** @name Methods to control the nested Restraint objects
62 
63  This container manages a set of Restraint objects. To
64  manipulate the stored set use the methods below.
65  */
66  /**@{*/
67  IMP_LIST_ACTION(public, Restraint, Restraints, restraint, restraints,
68  Restraint *, Restraints, on_add(obj), on_change(),
69  if (container) on_remove(container, obj));
70  /**@}*/
71 
72  /** Divide the list of contained restraints into sets and non-sets.*/
73  std::pair<RestraintsTemp, RestraintSetsTemp> get_non_sets_and_sets() const;
74 
75  public:
76 #ifndef IMP_DOXYGEN
79  double weight = 1.0,
80  double max = std::numeric_limits<double>::max()) const;
81 #endif
82  double get_last_score() const;
83 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
84 
85  protected:
86  virtual void do_set_model(kernel::Model *m) IMP_OVERRIDE;
87 
91 #endif
92 };
93 
94 /** \name Gathering restraints
95  It is sometimes useful to extract all the non-RestraintSet restraints
96  from a hierarchy involving RestraintSets mixed with Restraints.
97 */
98 
99 IMPKERNELEXPORT RestraintsTemp get_restraints(const RestraintsTemp &rs);
100 
101 IMPKERNEL_END_NAMESPACE
102 
103 #endif /* IMPKERNEL_DECLARE_RESTRAINT_SET_H */
Abstract base class for all restraints.
Class for adding derivatives from restraints to the model.
Object used to hold a set of restraints.
virtual void do_add_score_and_derivatives(ScoreAccumulator sa) const
kernel::RestraintsTemp get_restraints(const Subset &s, const ParticleStatesTable *pst, const DependencyGraph &dg, kernel::RestraintSet *rs)
virtual double get_last_score() const
Class for adding up scores during ScoringFunction evaluation.
A restraint is a term in an IMP ScoringFunction.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
virtual Restraints do_create_current_decomposition() const
virtual ScoringFunction * create_scoring_function(double weight=1.0, double max=NO_MAX) const
virtual void do_set_model(kernel::Model *)
virtual ModelObjectsTemp do_get_inputs() const =0
virtual Restraints do_create_decomposition() const
Macros to define containers of objects.
IMP::kernel::RestraintSet RestraintSet
Declare an efficient stl-compatible map.
Class for storing model, its restraints, constraints, and particles.