IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
RigidBodyTunneler.h
Go to the documentation of this file.
1/**
2 * \file IMP/core/RigidBodyTunneler.h
3 * \brief A mover that transform a rigid body
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPCORE_RIGID_BODY_TUNNELER_H
10#define IMPCORE_RIGID_BODY_TUNNELER_H
11
12#include <IMP/core/core_config.h>
13#include "MonteCarlo.h"
14#include "MonteCarloMover.h"
16#include <IMP/core/XYZ.h>
17#include <IMP/core/internal/tunneler_helpers.h>
18#include <Eigen/Dense>
19#include <Eigen/Geometry>
20#include <iostream>
21#include <boost/ptr_container/ptr_vector.hpp>
22
23IMPCORE_BEGIN_NAMESPACE
24
25//! Modify the transformation of a rigid body
26/** Provided a number of entry points, this mover will propose random
27 * translations of the rigid body from the closest entry point to a randomly
28 * chosen other one. Moves that do not end up in the target exit area will be
29 * dropped. This way of moving thus satisfies detailed balance. Entry points are
30 * relative to the center of the provided reference rigid body.
31 *
32 * The procedure is as follows. Suppose we are at x.
33 * pick closest entry point to x: k
34 * do
35 * pick random other entry point if one is still available: l
36 * compute new position y by applying to x the transform that maps k to l
37 * while (closest entry point to y is not l)
38 * if (closest entry point to y is l)
39 * propose y as move
40 * else
41 * do nothing
42 *
43 * \see RigidBodyMover
44 * \see MonteCarlo
45 */
46class IMPCOREEXPORT RigidBodyTunneler : public MonteCarloMover {
47
48 public:
49 /** Constructor
50 * \param m the model
51 * \param pis the rigid bodies to move, in order
52 * \param ref the RigidBody reference
53 * \param k the weight when calculating distances
54 * The squared distance between two coordinates is
55 * \f$d^2_\text{eucl}(COM1,COM2) + k*d^2_\text{quat}(Q1,Q2)\f$
56 * If you want to weight rotation differences at the same level as
57 * translational ones, pick \f$k \simeq d_\text{max}/\pi\f$ where
58 * \f$d_\text{max}\f$ is the largest translational difference to be expected.
59 * \param move_probability the prior probability to actually
60 * move somewhere else
61 */
63 ParticleIndex ref, double k,
64 double move_probability = 1.);
65
66 //! add entry point
67 /** each entry point is a list of coordinates that matches the number of rigid
68 * bodies in pis (see constructor)
69 * If there are N rigid bodies in pis, then an entry point is
70 * - 3N floats, representing the x,y,z coordinates of the
71 * centroid of each of the N rigid bodies
72 * - 4N floats, corresponding to the N rotational quaternions of the rbs
73 * Coordinates are all relative to the reference, i.e. for which the centroid
74 * is at the origin and the rotation is identity.
75 * TODO: If an entry point should be indifferent of one rigid body, one
76 * centroid or one quaternion, the corresponding floats should be set to zero.
77 */
79
80 /// Statistics
82 unsigned get_number_of_rejected_moves() const { return num_rejected_; }
83 unsigned get_number_of_proposed_moves() const { return num_proposed_; }
84 unsigned get_number_of_impossible_moves() const { return num_impossible_; }
85 unsigned get_number_of_calls() const { return num_calls_; }
86
87 //! returns center of mass and quaternion of rotation wrt ref
89 ParticleIndex target,
90 ParticleIndex ref);
91
92 //! returns center of mass and quaternion of rotation of pi
94 ParticleIndex pi);
95
96 /// sets rigid body coordinates in the reference frame of ref
97 static void set_reduced_coordinates(Model* m,
98 ParticleIndex target,
99 ParticleIndex ref,
100 Floats coords);
101
102 protected:
103 virtual ModelObjectsTemp do_get_inputs() const override;
105 virtual void do_reject() override;
107
108 private:
109 unsigned get_closest_entry_point(const internal::Coord& x) const;
110
111 private:
112 ParticleIndexes pis_;
113 ParticleIndex ref_;
114 double k_, move_probability_;
115 unsigned num_calls_, num_proposed_, num_rejected_, num_impossible_;
116 boost::ptr_vector<internal::Transformer> last_transformations_;
117 std::vector<internal::Coord> entries_;
118};
119
120IMPCORE_END_NAMESPACE
121
122#endif /* IMPCORE_RIGID_BODY_TUNNELER_H */
The base class for movers for Monte Carlo optimization.
Simple Monte Carlo optimizer.
Simple XYZ decorator.
static Floats get_reduced_coordinates(Model *m, ParticleIndex target, ParticleIndex ref)
returns center of mass and quaternion of rotation wrt ref
virtual void do_reject() override
Implement reset_proposed_move().
static void set_reduced_coordinates(Model *m, ParticleIndex target, ParticleIndex ref, Floats coords)
sets rigid body coordinates in the reference frame of ref
RigidBodyTunneler(Model *m, ParticleIndexes pis, ParticleIndex ref, double k, double move_probability=1.)
virtual MonteCarloMoverResult do_propose() override
Implement propose_move().
void reset_stats()
Statistics.
virtual ModelObjectsTemp do_get_inputs() const override
void add_entry_point(Floats fl)
add entry point
static Floats get_reduced_coordinates(Model *m, ParticleIndex pi)
returns center of mass and quaternion of rotation of pi
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
Definition types.h:46
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
functionality for defining rigid bodies
Return value of the MonteCarloMover::propose() function.