IMP  2.0.0
The Integrative Modeling Platform
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 "MonteCarloMover.h"
15 
16 IMPCORE_BEGIN_NAMESPACE
17 
18 //! Modify a set of continuous variables by perturbing them within a ball.
19 /** The variables are perturbed within a ball of the
20  given radius.
21  \see MonteCarlo
22  */
23 class IMPCOREEXPORT BallMover: public MonteCarloMover
24 {
25  ParticleIndexes pis_;
26  FloatKeys keys_;
27  double radius_;
28  algebra::VectorKDs originals_;
29 
30  void initialize(ParticleIndexes pis,
31  FloatKeys keys,
32  double radius);
33 public:
35  const FloatKeys &vars, double radius);
36  //! Move the x,y,z coordinates
37  BallMover(Model *m, ParticleIndex pi, double radius);
38 
39 #ifndef IMP_DOXYGEN
40  /** The attributes are perturbed within a ball whose dimensionality is
41  given by the number of attributes and radius by the given value.
42  \param[in] sc The set of particles to perturb.
43  \param[in] vars The variables to use (normally the keys for x,y,z)
44  \param[in] radius The radius deviation to use.
45  */
46  BallMover(const ParticlesTemp &sc, const FloatKeys &vars,
47  Float radius);
48 
49  /** The x,y,z coordinates are perturbed within a ball.
50  \param[in] sc The set of particles to perturb.
51  \param[in] radius The radius deviation to use.
52  */
53  BallMover(const ParticlesTemp &sc,
54  Float radius);
55 #endif
56 
57  void set_radius(Float radius) {
58  IMP_USAGE_CHECK(radius > 0, "The radius must be positive");
59  radius_=radius;
60  }
61 
62  Float get_radius() const {
63  return radius_;
64  }
65 
66  protected:
67  virtual kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
68  virtual MonteCarloMoverResult do_propose() IMP_OVERRIDE;
69  virtual void do_reject() IMP_OVERRIDE;
71 };
72 
73 IMPCORE_END_NAMESPACE
74 
75 #endif /* IMPCORE_BALL_MOVER_H */