IMP  2.0.1
The Integrative Modeling Platform
MinimumRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/MinimumRestraint.h
3  * \brief Score based on the k minimum restraints.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_MINIMUM_RESTRAINT_H
10 #define IMPCORE_MINIMUM_RESTRAINT_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/Restraint.h>
14 #include <IMP/Model.h>
15 #include <IMP/macros.h>
16 #include <IMP/generic.h>
17 
18 IMPCORE_BEGIN_NAMESPACE
19 
20 //! Score based on the minimum scoring members of a set of restraints
21 /**
22  */
23 class IMPCOREEXPORT MinimumRestraint : public Restraint
24 {
25  unsigned int k_;
26 public:
27  /** Score based on the num minimum restraints from rs. The restraints
28  must already be registered with the model (either by being added
29  to the model scoring function, upon constructior or having
30  Restraint::set_model() called on them.
31  */
32  MinimumRestraint(unsigned int num,
33  const Restraints& rs=Restraints(),
34  std::string name="MinimumRestraint %1%");
35 
36  void clear_caches() {
37  if (get_is_part_of_model()) {
38  get_model()->clear_caches();
39  }
40  }
41 
42  public:
43  double unprotected_evaluate(IMP::DerivativeAccumulator *accum)
44  const IMP_OVERRIDE;
45  IMP::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
47 
48  IMP_LIST_ACTION(public, Restraint, Restraints,
49  restraint, restraints, Restraint*, Restraints,
50  {
51  if (get_is_part_of_model()) {
52  obj->set_model(get_model());
53  }
54  }
55  ,{
56 
57  }, {
58  obj->set_model(nullptr);
59  });
60  void set_model(Model *m);
61 };
62 
63 IMPCORE_END_NAMESPACE
64 
65 #endif /* IMPCORE_MINIMUM_RESTRAINT_H */