IMP logo
IMP Reference Guide  2.22.0
The Integrative Modeling Platform
DirectionMover.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/DirectionMover.h
3  * \brief A mover that transforms a Direction.
4  *
5  * Copyright 2007-2023 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_DIRECTION_MOVER_H
10 #define IMPCORE_DIRECTION_MOVER_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/core/direction.h>
14 #include <IMP/core/MonteCarlo.h>
16 #include <IMP/Particle.h>
17 #include <IMP/Object.h>
18 #include <IMP/Model.h>
19 #include <cereal/access.hpp>
20 #include <cereal/types/base_class.hpp>
21 #include <cereal/types/polymorphic.hpp>
22 
23 
24 IMPCORE_BEGIN_NAMESPACE
25 
26 //! Modify a direction.
27 /** The Direction is transformed via rotation and/or reflection
28 
29  \see Direction
30  \see MonteCarlo
31 */
32 class IMPCOREEXPORT DirectionMover : public MonteCarloMover {
33  private:
34  algebra::Vector3D last_direction_;
35  Float max_angle_;
36  Float reflect_prob_;
37  ParticleIndex pi_;
38 
39  void initialize(ParticleIndex pi, double max_rotation,
40  double reflect_probability);
41 
42  friend class cereal::access;
43 
44  template<class Archive> void serialize(Archive &ar) {
45  ar(cereal::base_class<MonteCarloMover>(this), last_direction_,
46  max_angle_, reflect_prob_, pi_);
47  }
49 
50  public:
51  DirectionMover(Model *m, ParticleIndex pi, Float max_rotation,
52  Float reflect_probability);
53 
54  DirectionMover(Direction d, Float max_rotation,
55  Float reflect_probability);
56 
57  DirectionMover() {}
58 
59  //! Set the maximum rotation in radians.
60  void set_maximum_rotation(Float mr);
61 
62  //! Set the frequency of reflection moves.
63  void set_reflect_probability(Float rp);
64 
65  //! Get the maximum rotation.
66  Float get_maximum_rotation() const { return max_angle_; }
67 
68  //! Get the frequency of reflection moves.
69  Float get_reflect_probability() const { return reflect_prob_; }
70 
71  //! Get the surface being moved.
72  Direction get_direction() const { return Direction(get_model(), pi_); }
73 
74  protected:
75  virtual ModelObjectsTemp do_get_inputs() const override;
76  virtual MonteCarloMoverResult do_propose() override;
77  virtual void do_reject() override;
79 };
80 
81 IMPCORE_END_NAMESPACE
82 
83 #endif /* IMPCORE_DIRECTION_MOVER_H */
Direction get_direction() const
Get the surface being moved.
Simple Monte Carlo optimizer.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A decorator for a particle that represents a direction in 3D.
Definition: direction.h:23
Storage of a model, its restraints, constraints and particles.
virtual void do_reject()=0
Implement reset_proposed_move()
Return value of the MonteCarloMover::propose() function.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
Modify a direction.
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()
Decorators for directions and the angle between them.
Float get_maximum_rotation() const
Get the maximum rotation.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
A shared base class to help in debugging and things.
Float get_reflect_probability() const
Get the frequency of reflection moves.
VectorD< 3 > Vector3D
Definition: VectorD.h:408
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
virtual ModelObjectsTemp do_get_inputs() const =0