IMP logo
IMP Reference Guide  2.20.2
The Integrative Modeling Platform
LogNormalMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/LogNormalMover.h
3  * \brief A modifier that perturbs a point with a log-normal distribution.
4  *
5  * Copyright 2007-2023 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_LOGNORMAL_MOVER_H
10 #define IMPCORE_LOGNORMAL_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 log-normal distribution.
21 /** \see MonteCarlo
22  \see NormalMover
23  \note While technically a log-normal distribution only applies to
24  positively bounded variables, a log-normal perturbation has a
25  multiplicative effect that can be applied to negative variables
26  as well.
27  */
28 class IMPCOREEXPORT LogNormalMover : public MonteCarloMover {
29  ParticleIndexes pis_;
30  FloatKeys keys_;
31  Float stddev_;
32  algebra::VectorKDs originals_;
33 
34  friend class cereal::access;
35  template<class Archive> void serialize(Archive &ar) {
36  ar(cereal::base_class<MonteCarloMover>(this), pis_, keys_, stddev_);
37  if (std::is_base_of<cereal::detail::InputArchiveBase, Archive>::value) {
38  // clear originals
39  initialize(pis_, keys_, stddev_);
40  }
41  }
43 
44  void initialize(ParticleIndexes pis, FloatKeys keys, double radius);
45 
46  public:
47  LogNormalMover(Model *m, ParticleIndex pi, const FloatKeys &vars,
48  double stddev);
49  //! Move the x,y,z coordinates
50  LogNormalMover(Model *m, ParticleIndex pi, double stddev);
51 #ifndef IMP_DOXYGEN
52  /** \param[in] sc The set of particles to perturb.
53  \param[in] vars The variables to use (normally the keys for x,y,z)
54  \param[in] sigma The standard deviation to use.
55  */
56  LogNormalMover(const ParticlesTemp &sc, const FloatKeys &vars,
57  Float sigma);
58 
59  LogNormalMover(const ParticlesTemp &sc, Float radius);
60 #endif
61  LogNormalMover() {}
62 
63  void set_sigma(Float sigma) {
64  IMP_USAGE_CHECK(sigma > 0, "Sigma must be positive");
65  stddev_ = sigma;
66  }
67 
68  Float get_sigma() const { return stddev_; }
69 
70  protected:
71  virtual ModelObjectsTemp do_get_inputs() const override;
72  virtual MonteCarloMoverResult do_propose() override;
73  virtual void do_reject() override;
75 };
76 
77 IMPCORE_END_NAMESPACE
78 
79 #endif /* IMPCORE_LOGNORMAL_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 log-normal distribution.
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