IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
NormalMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/NormalMover.h
3  * \brief A modifier which perturbs a point with a normal distribution.
4  *
5  * Copyright 2007-2023 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_NORMAL_MOVER_H
10 #define IMPCORE_NORMAL_MOVER_H
11 
12 #include <IMP/core/core_config.h>
13 #include "MonteCarloMover.h"
14 #include <cereal/access.hpp>
15 #include <cereal/types/base_class.hpp>
16 #include <cereal/types/vector.hpp>
17 
18 IMPCORE_BEGIN_NAMESPACE
19 
20 //! Modify a set of continuous variables using a normal distribution.
21 /** \see MonteCarlo
22  */
23 class IMPCOREEXPORT NormalMover : public MonteCarloMover {
24  ParticleIndexes pis_;
25  FloatKeys keys_;
26  Float stddev_;
27  algebra::VectorKDs originals_;
28 
29  friend class cereal::access;
30  template<class Archive> void serialize(Archive &ar) {
31  ar(cereal::base_class<MonteCarloMover>(this), pis_, keys_, stddev_);
32  if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
33  // clear originals
34  initialize(pis_, keys_, stddev_);
35  }
36  }
38 
39  void initialize(ParticleIndexes pis, FloatKeys keys, double radius);
40 
41  public:
42  NormalMover(Model *m, ParticleIndex pi, const FloatKeys &vars,
43  double stddev);
44  //! Move the x,y,z coordinates
45  NormalMover(Model *m, ParticleIndex pi, double stddev);
46 #ifndef IMP_DOXYGEN
47  /** \param[in] sc The set of particles to perturb.
48  \param[in] vars The variables to use (normally the keys for x,y,z)
49  \param[in] sigma The standard deviation to use.
50  */
51  NormalMover(const ParticlesTemp &sc, const FloatKeys &vars,
52  Float sigma);
53 
54  NormalMover(const ParticlesTemp &sc, Float radius);
55 #endif
56  NormalMover() {}
57 
58  void set_sigma(Float sigma) {
59  IMP_USAGE_CHECK(sigma > 0, "Sigma must be positive");
60  stddev_ = sigma;
61  }
62 
63  Float get_sigma() const { return stddev_; }
64 
65  protected:
66  virtual ModelObjectsTemp do_get_inputs() const override;
67  virtual MonteCarloMoverResult do_propose() override;
68  virtual void do_reject() override;
70 };
71 
72 IMPCORE_END_NAMESPACE
73 
74 #endif /* IMPCORE_NORMAL_MOVER_H */
#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.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A base class for classes which perturb particles.
The base class for movers for Monte Carlo optimization.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
virtual MonteCarloMoverResult do_propose()=0
Implement propose_move()
Modify a set of continuous variables using a normal distribution.
Definition: NormalMover.h:23
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
virtual ModelObjectsTemp do_get_inputs() const =0