IMP logo
IMP Reference Guide  develop.27926d84dc,2024/04/19
The Integrative Modeling Platform
BipartitePairsStatisticsOptimizerState.h
Go to the documentation of this file.
1 /**
2  * \file npctransport/BipartitePairsStatisticsOptimizerState.h
3  * \brief description
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPNPCTRANSPORT_BIPARTITE_PAIRS_STATISTICS_OPTIMIZER_STATE_H
9 #define IMPNPCTRANSPORT_BIPARTITE_PAIRS_STATISTICS_OPTIMIZER_STATE_H
10 
11 #include "npctransport_config.h"
12 #include <IMP/Particle.h>
13 #include <IMP/OptimizerState.h>
14 //#include <IMP/optimizer_state_macros.h>
18 #include <boost/unordered_set.hpp>
19 #include <deque>
20 
21 IMPNPCTRANSPORT_BEGIN_NAMESPACE
22 
23 class Statistics;
24 
25 /** Track the interaction between pairs from one group of particles
26  with particles from another group, within some specified contact
27  range
28 */
29 class IMPNPCTRANSPORTEXPORT BipartitePairsStatisticsOptimizerState
31  private:
33  typedef IMP_KERNEL_LARGE_ORDERED_SET<ParticleIndex> t_particle_index_ordered_set; // got to be ordered
34  typedef IMP_KERNEL_LARGE_ORDERED_SET<ParticleIndexPair> t_particle_index_pair_ordered_set;
35  private:
37 
38  bool is_reset_;
39 
40  int n_updates_;
41  double time_ns_; // simulation time in ns
42  double stats_time_ns_; // time statistics were gathered for miscs
43  double off_stats_time_ns_; // time when off-rate calculations were gathered,
44  // requiring presence of bounds, weighted by #contacts
45  double off_I_stats_time_ns_; // weighted by number of bounds I
46  double off_II_stats_time_ns_; // weighted by number of bounds II
47  double on_stats_time_ns_; // time when on-rate calculations were gathered,
48  // requiring presence of unbounds
49  double on_I_stats_time_ns_; // time when on-rate calculations were gathered
50  // for particles I, weighted by their number
51  double on_II_stats_time_ns_; // time when on-rate calculations were gathered
52  // for particles II, weighted by their number
53 
54  // the types of particles involved in the interaction (type of group I and II)
55  // TODO: a bit ugly and ungeneral, we might have mixed types in principle
56  InteractionType interaction_type_;
57 
58  // maintains a list of nearby particle pairs in a bipartite graph
60  close_bipartite_pair_container_;
61 
62  // range considered as contact (without slack of CloseBipartitePairContainer)
63  double range_;
64 
65  // avergae number of times all pairs of particles contacted each other
66  // per update round
67  double avg_ncontacts_;
68 
69  // list of bound particles of each type + list of their contacts after
70  // last round of update
71  t_particle_index_ordered_set bounds_I_;
72  t_particle_index_ordered_set bounds_II_;
73  t_particle_index_pair_ordered_set contacts_;
74 
75  // Average since last reset:
76  double avg_pct_bound_particles_I_; // particles in group I (it is fraction, not pct)
77  double avg_pct_bound_particles_II_; // particles in group II (it is fraction, not pct)
78  double avg_fraction_bound_sites_I_; // sites in group I
79  double avg_fraction_bound_sites_II_; // sites in group I
80  double avg_fraction_nonspecific_I_; // fraction of non-specific interactions for particles of type I with particles of type II
81  double avg_fraction_nonspecific_II_; // fraction of non-specific interactions for particles of type II with particles of type I
82  double avg_off_per_contact_per_ns_;
83  double avg_off_per_bound_I_per_ns_;
84  double avg_off_per_bound_II_per_ns_;
85  double avg_on_per_unbound_I_per_ns_;
86  double avg_on_per_unbound_II_per_ns_;
87  double avg_on_per_missing_contact_per_ns_;
88 
89  // Total number of all (bound) particles in each group after last update():
90  unsigned int n_particles_I_;
91  unsigned int n_particles_II_;
92  unsigned int n_bounds_I_;
93  unsigned int n_bounds_II_;
94 
95  // Total number of sites on particles of type I and II:
96  unsigned int n_sites_I_;
97  unsigned int n_sites_II_;
98 
99  public:
100 
101  /**
102  Constructor
103 
104  @param[in] m the model associated with particlesI / II
105  @param[in] interaction_type the pair of interacting particle types, assumed to
106  be the types of all particles in particlesI and
107  particlesII, respectively.
108  @param[in] particlesI particles from one side of the interaction
109  @param[in] particlesII particles from other side of the interaction
110  @param[in] contact_range define a contact for particle pairs whose sphere distances
111  are within contact_range in [A]
112  @param[in] slack slack for updating close particles in appropriate
113  CloseBiparyiyrPairContainer, this affects only
114  performance - touch only if you know what you're
115  doing
116  */
118  ( IMP::npctransport::Statistics* statistics_manager,
119  InteractionType interaction_type, // TODO: remove this from class?
120  // a bit ugly and ungeneral
121  const ParticlesTemp& particlesI,
122  const ParticlesTemp& particlesII,
123  double contact_range = 1.0, double slack = 1.0);
124 
125  /**
126  returns the particle types of the first and second group of particles,
127  respectively. This might change in the future, since types can be mixed
128  */
129  InteractionType get_interaction_type() const { return interaction_type_; }
130 
131  /**
132  returns the average number of interacting pairs of particles
133  per update
134  */
135  double get_average_number_of_contacts() const { return avg_ncontacts_; }
136 
137  /** returns the average off rate per bound complex per nanosecond
138  since last reset()
139  */
141  { return avg_off_per_contact_per_ns_; }
142 
143  /** returns the average off rate per bound particles of type I
144  since last reset()
145  */
147  { return avg_off_per_bound_I_per_ns_; }
148 
149  /** returns the average off rate per bound particles of type II
150  since last reset()
151  */
153  { return avg_off_per_bound_II_per_ns_; }
154 
155  /** returns the average on rate per missing possible contact
156  (out of all theoretically possible contacts between particlesI
157  and particles II)
158  */
160  { return avg_on_per_missing_contact_per_ns_; }
161 
162  /** returns the average on rate per unbound particles of type I
163  since last resetI()
164  */
166  { return avg_on_per_unbound_I_per_ns_; }
167 
168  /** returns the average on rate per unbound particles of type II
169  since last resetII()
170  */
172  { return avg_on_per_unbound_II_per_ns_; }
173 
174  /**
175  returns the average fraction of particles from group I
176  that are bound in each update round
177  */
179  return avg_pct_bound_particles_I_;
180  }
181 
182  /**
183  returns the average fraction of particles from group II
184  that are bound in each update round
185  */
187  return avg_pct_bound_particles_II_;
188  }
189 
190  //! returns the average fraction of particle sites from group I
191  //! that are bound in each update round
193  return avg_fraction_bound_sites_I_;
194  }
195 
196  //! returns the average fraction of particle sites from group II
197  //! that are bound in each update round
199  return avg_fraction_bound_sites_II_;
200  }
201 
202  //! returns the average fraction of particles from type I
203  //! that are nonspecifically interaction with particles of type II
204  //! (= non-zero contribution)
206  return avg_fraction_nonspecific_I_;
207  }
208 
209  //! returns the average fraction of particles from type II
210  //! that are nonspecifically interaction with particles of type I
211  //! (= non-zero contribution)
213  return avg_fraction_nonspecific_II_;
214  }
215 
216  /**
217  return the total number of particles in the first group
218  */
219  Int get_number_of_particles_1() { return n_particles_I_; }
220 
221  /**
222  return the total number of particles in the second group
223  */
224  Int get_number_of_particles_2() { return n_particles_II_; }
225 
226 
227  /** restart accumulation of all averages in the next time
228  that update() is called
229  */
230  void reset() override;
231 
232  double get_misc_stats_period_ns() const
233  { return stats_time_ns_; };
234 
235  double get_off_stats_period_ns() const
236  { return off_stats_time_ns_; };
237 
238  double get_off_I_stats_period_ns() const
239  { return off_I_stats_time_ns_; };
240 
241  double get_off_II_stats_period_ns() const
242  { return off_II_stats_time_ns_; };
243 
244  double get_on_stats_period_ns() const
245  { return on_stats_time_ns_; };
246 
247  double get_on_I_stats_period_ns() const
248  { return on_I_stats_time_ns_; };
249 
250  double get_on_II_stats_period_ns() const
251  { return on_II_stats_time_ns_; };
252 
253 
254  protected:
255  virtual void do_update(unsigned int call_num) override;
256 
257 
258  private:
259 
260  /**
261  update fraction bound with n1 bound particles of type I;
262  and n2 bound particles of type II, assuming old_updates
263  for the old average
264  */
265  // void update_fraction_bound(unsigned int n1,
266  // unsigned int n2,
267  // unsigned int old_updates);
268 
269 
270  public:
272 };
275 
276 IMPNPCTRANSPORT_END_NAMESPACE
277 
278 #endif /* IMPNPCTRANSPORT_BIPARTITE_PAIRS_STATISTICS_OPTIMIZER_STATE_H */
std::pair< IMP::core::ParticleType, IMP::core::ParticleType > InteractionType
an interaction that involves particles of two types
Definition: typedefs.h:21
Smart pointer to Object-derived classes that does not refcount.
Definition: WeakPointer.h:77
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Angle restraint between three particles.
virtual void do_update(unsigned int)
Statistics and order parameters about the simulations.
Return all pairs from a SingletonContainer.
virtual void reset()
Reset counters, as if at the start of an optimize run.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
Shared optimizer state that is invoked upon commitment of new coordinates.
description
int Int
Basic integer value.
Definition: types.h:34
Shared optimizer state.