IMP  2.2.1
The Integrative Modeling Platform
kernel/Constraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/Constraint.h \brief A base class for constraints.
3  *
4  * Copyright 2007-2014 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPKERNEL_CONSTRAINT_H
9 #define IMPKERNEL_CONSTRAINT_H
10 
11 #include "ScoreState.h"
12 
13 IMPKERNEL_BEGIN_NAMESPACE
14 
15 //! Implement a constraint on the Model.
16 /** The solution model can be restricted two ways, either by
17  penalizing "bad" conformations (a restraint) or by forcing some
18  set of attributes to a function of other attributes (a
19  constraint). For example, rigid bodies consisting of a number of
20  particles could be implemented either way.
21 
22  - As a restraint: the particles in the rigid body are each moved
23  independently by the optimizer. The scoring function has a term
24  for how far each particle diverges from its rigid position.
25 
26  - As a constraint: the optimizer only changes the position of the
27  rigid body itself and the position of the particles in the body
28  are computed from the position of the rigid body.
29 
30  In IMP, constraints are implemented as a type of
31  ScoreState. Before evaluation, the constraint updates the
32  attributes of some of the particles to ensure that the constraint
33  is satisfied. Since this update creates implicit relationships
34  between the particles, after the derivatives are computed, the
35  constraint can move them around to make sure the derivatives of
36  the optimizer parameters are correct.
37 
38  In general, constraints are associated with Decorator objects
39  and created invisibly when needed.
40 
41  \note Constraint invariants will not necessarily hold if
42  involved particles have been modified directly (not through e.g., an
43  Optimizer), until Model::update() or Model::evaluate()
44  have been called. For example, if you change a
45  particle's coordinates, a IMP::core::Centroid of a set of particles that
46  contains the particle, will not be the correct centroid until the
47  Model is updated.
48  */
49 class IMPKERNELEXPORT Constraint : public ScoreState {
50  public:
51  Constraint(kernel::Model *m, std::string name = "Constraint %1%");
52  virtual void do_update_attributes() = 0;
53  virtual void do_update_derivatives(DerivativeAccumulator *da) = 0;
54 
55  virtual void do_before_evaluate() IMP_OVERRIDE { do_update_attributes(); }
56  virtual void do_after_evaluate(DerivativeAccumulator *da) IMP_OVERRIDE {
57  if (da) do_update_derivatives(da);
58  }
60 };
61 
63 
64 IMPKERNEL_END_NAMESPACE
65 
66 #endif /* IMPKERNEL_CONSTRAINT_H */
Class for adding derivatives from restraints to the model.
IMP::kernel::Constraint Constraint
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
Ref counted objects should have private destructors.
ScoreStates maintian invariants in the Model.
Shared score state.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Implement a constraint on the Model.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72