IMP  2.1.0
The Integrative Modeling Platform
core/BallMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/BallMover.h
3  * \brief A modifier which variables within a ball.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_BALL_MOVER_H
10 #define IMPCORE_BALL_MOVER_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/base_types.h>
14 #include <IMP/base/exception.h>
15 #include "MonteCarloMover.h"
16 
17 IMPCORE_BEGIN_NAMESPACE
18 
19 //! Modify a set of continuous variables by perturbing them within a ball.
20 /** The variables are perturbed within a ball of the
21  given radius.
22  \see MonteCarlo
23  */
24 class IMPCOREEXPORT BallMover : public MonteCarloMover {
26  FloatKeys keys_;
27  double radius_;
28  algebra::VectorKDs originals_;
29 
30  void initialize(kernel::ParticleIndexes pis, FloatKeys keys, double radius);
31 
32  public:
34  double radius);
35  //! Move the x,y,z coordinates
36  BallMover(kernel::Model *m, kernel::ParticleIndex pi, double radius);
37 
38 #ifndef IMP_DOXYGEN
39  /** The attributes are perturbed within a ball whose dimensionality is
40  given by the number of attributes and radius by the given value.
41  \param[in] sc The set of particles to perturb.
42  \param[in] vars The variables to use (normally the keys for x,y,z)
43  \param[in] radius The radius deviation to use.
44  */
45  BallMover(const kernel::ParticlesTemp &sc, const FloatKeys &vars,
46  Float radius);
47 
48  /** The x,y,z coordinates are perturbed within a ball.
49  \param[in] sc The set of particles to perturb.
50  \param[in] radius The radius deviation to use.
51  */
52  BallMover(const kernel::ParticlesTemp &sc, Float radius);
53 #endif
54 
55  void set_radius(Float radius) {
56  IMP_ALWAYS_CHECK(radius > 0, "The radius must be positive",
58  radius_ = radius;
59  }
60 
61  Float get_radius() const { return radius_; }
62 
63  protected:
64  virtual kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
65  virtual MonteCarloMoverResult do_propose() IMP_OVERRIDE;
66  virtual void do_reject() IMP_OVERRIDE;
68 };
69 
70 IMPCORE_END_NAMESPACE
71 
72 #endif /* IMPCORE_BALL_MOVER_H */
Import IMP/kernel/base_types.h in the namespace.
virtual void do_reject()=0
Implement reset_proposed_move()
Modify a set of continuous variables by perturbing them within a ball.
A base class for classes which perturb particles.
The base class for movers for MC optimization.
virtual MonteCarloMoverResult do_propose()=0
Implement propose_move()
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Exception definitions and assertions.
virtual ModelObjectsTemp do_get_inputs() const =0
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
#define IMP_ALWAYS_CHECK(condition, message, exception_name)
Throw an exception if a check fails.
An exception for an invalid value being passed to IMP.
Class for storing model, its restraints, constraints, and particles.