IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2026 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
18IMPCORE_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 */
28class 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 }
42 IMP_OBJECT_SERIALIZE_DECL(LogNormalMover);
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 ParticleIndexes get_indexes() const { return pis_; }
70 FloatKeys get_keys() const { return keys_; }
71
72 protected:
73 virtual ModelObjectsTemp do_get_inputs() const override;
75 virtual void do_reject() override;
76 IMP_OBJECT_METHODS(LogNormalMover);
77};
78
79IMPCORE_END_NAMESPACE
80
81#endif /* IMPCORE_LOGNORMAL_MOVER_H */
The base class for movers for Monte Carlo optimization.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
virtual MonteCarloMoverResult do_propose() override
Implement propose_move().
LogNormalMover(Model *m, ParticleIndex pi, double stddev)
Move the x,y,z coordinates.
virtual void do_reject() override
Implement reset_proposed_move().
virtual ModelObjectsTemp do_get_inputs() const override
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Vector< VectorD<-1 > > VectorKDs
Definition VectorD.h:425
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
IMP::Vector< FloatKey > FloatKeys
Definition base_types.h:33
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Return value of the MonteCarloMover::propose() function.