IMP logo
IMP Reference Guide  2.9.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-2018 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/exception.h>
15 #include "MonteCarloMover.h"
16 
17 IMPCORE_BEGIN_NAMESPACE
18 
19 //! Move continuous particle variables by perturbing them within a ball.
20 /** The variables are perturbed within a ball of the given radius.
21  \see MonteCarlo
22  */
23 class IMPCOREEXPORT BallMover : public MonteCarloMover {
24  ParticleIndexes pis_;
25  FloatKeys keys_;
26  double radius_;
27  algebra::VectorKDs originals_;
28 
29  void initialize(ParticleIndexes pis, FloatKeys keys, double radius);
30 
31  public:
32  //! Move specified variables of particle pi within a ball of specified radius
33  /** Construct a mover that in each move, perturbs the specified
34  variables (attributes) of particle pi in model m, within a ball
35  of specified radius, whose dimensionality is the total number of
36  attributes.
37  */
38  BallMover(Model *m, ParticleIndex pi, const FloatKeys &vars,
39  double radius);
40 
41  //! Move the x,y,z coordinates of pi within a ball of specified radius
42  BallMover(Model *m, ParticleIndex pi, double radius);
43 
44  //! Move specified variables of particles within a ball of specified radius
45  /** \param[in] pis The set of particles to perturb.
46  \param[in] vars The variables to use (normally the keys for x,y,z)
47  \param[in] radius The radius deviation to use.
48  */
49  BallMover(Model *m, const ParticleIndexes &pis, const FloatKeys &vars,
50  Float radius);
51 
52  //! Move the x,y,z coordinates of pis within a ball of specified radius
53  /** The x,y,z coordinates of each particle are perturbed within a ball.
54  \param[in] pis The set of particles to perturb.
55  \param[in] radius The radius deviation to use.
56  */
57  BallMover(Model *m, const ParticleIndexes &pis, Float radius);
58 
59  void set_radius(Float radius) {
60  IMP_ALWAYS_CHECK(radius > 0, "The radius must be positive",
62  radius_ = radius;
63  }
64 
65  Float get_radius() const { return radius_; }
66 
67  protected:
69 
70  //! Move particle attributes within a ball, as specified in constructor
72 
73  //! Restore original attributes from before do_propose()
74  virtual void do_reject() IMP_OVERRIDE;
76 };
77 
78 IMPCORE_END_NAMESPACE
79 
80 #endif /* IMPCORE_BALL_MOVER_H */
Basic types used by IMP.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual void do_reject()=0
Implement reset_proposed_move()
Return value of the MonteCarloMover::propose() function.
Move continuous particle variables by perturbing them within a ball.
Exception definitions and assertions.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
A base class for classes which perturb particles.
The base class for movers for Monte Carlo optimization.
virtual MonteCarloMoverResult do_propose()=0
Implement propose_move()
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
#define IMP_ALWAYS_CHECK(condition, message, exception_name)
Throw an exception if a check fails.
Definition: check_macros.h:61
An exception for an invalid value being passed to IMP.
Definition: exception.h:137
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.