IMP logo
IMP Reference Guide  2.24.0
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-2026 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>
16 #include <boost/unordered_set.hpp>
17 #include <deque>
18 
19 IMPNPCTRANSPORT_BEGIN_NAMESPACE
20 
21 class Statistics;
22 
23 /** Track the interaction between pairs from one group of particles
24  with particles from another group, within some specified contact
25  range
26 */
27 class IMPNPCTRANSPORTEXPORT BipartitePairsStatisticsOptimizerState
28  : public OptimizerState {
29  private:
30  typedef OptimizerState P;
31  typedef IMP_KERNEL_LARGE_ORDERED_SET<ParticleIndex> t_particle_index_ordered_set; // got to be ordered
32  typedef IMP_KERNEL_LARGE_ORDERED_SET<ParticleIndexPair> t_particle_index_pair_ordered_set;
33  private:
35 
36  bool is_reset_;
37 
38  int n_updates_;
39  double time_ns_; // simulation time in ns
40  double stats_time_ns_; // time statistics were gathered for miscs
41  double off_stats_time_ns_; // time when off-rate calculations were gathered,
42  // requiring presence of bounds, weighted by #contacts
43  double off_I_stats_time_ns_; // weighted by number of bounds I
44  double off_II_stats_time_ns_; // weighted by number of bounds II
45  double on_stats_time_ns_; // time when on-rate calculations were gathered,
46  // requiring presence of unbounds
47  double on_I_stats_time_ns_; // time when on-rate calculations were gathered
48  // for particles I, weighted by their number
49  double on_II_stats_time_ns_; // time when on-rate calculations were gathered
50  // for particles II, weighted by their number
51 
52  // the types of particles involved in the interaction (type of group I and II)
53  // TODO: a bit ugly and ungeneral, we might have mixed types in principle
54  InteractionType interaction_type_;
55 
56  // maintains a list of nearby particle pairs in a bipartite graph
58  close_bipartite_pair_container_;
59 
60  // range considered as contact (without slack of CloseBipartitePairContainer)
61  double range_;
62 
63  // avergae number of times all pairs of particles contacted each other
64  // per update round
65  double avg_ncontacts_;
66 
67  // list of bound particles of each type + list of their contacts after
68  // last round of update
69  t_particle_index_ordered_set bounds_I_;
70  t_particle_index_ordered_set bounds_II_;
71  t_particle_index_pair_ordered_set contacts_;
72 
73  // Average since last reset:
74  double avg_pct_bound_particles_I_; // particles in group I (it is fraction, not pct)
75  double avg_pct_bound_particles_II_; // particles in group II (it is fraction, not pct)
76  double avg_fraction_bound_sites_I_; // sites in group I
77  double avg_fraction_bound_sites_II_; // sites in group I
78  double avg_fraction_nonspecific_I_; // fraction of non-specific interactions for particles of type I with particles of type II
79  double avg_fraction_nonspecific_II_; // fraction of non-specific interactions for particles of type II with particles of type I
80  double avg_off_per_contact_per_ns_;
81  double avg_off_per_bound_I_per_ns_;
82  double avg_off_per_bound_II_per_ns_;
83  double avg_on_per_unbound_I_per_ns_;
84  double avg_on_per_unbound_II_per_ns_;
85  double avg_on_per_missing_contact_per_ns_;
86 
87  // Total number of all (bound) particles in each group after last update():
88  unsigned int n_particles_I_;
89  unsigned int n_particles_II_;
90  unsigned int n_bounds_I_;
91  unsigned int n_bounds_II_;
92 
93  // Total number of sites on particles of type I and II:
94  unsigned int n_sites_I_;
95  unsigned int n_sites_II_;
96 
97  public:
98 
99  /**
100  Constructor
101 
102  @param[in] m the model associated with particlesI / II
103  @param[in] interaction_type the pair of interacting particle types, assumed to
104  be the types of all particles in particlesI and
105  particlesII, respectively.
106  @param[in] particlesI particles from one side of the interaction
107  @param[in] particlesII particles from other side of the interaction
108  @param[in] contact_range define a contact for particle pairs whose sphere distances
109  are within contact_range in [A]
110  @param[in] slack slack for updating close particles in appropriate
111  CloseBiparyiyrPairContainer, this affects only
112  performance - touch only if you know what you're
113  doing
114  */
116  ( IMP::npctransport::Statistics* statistics_manager,
117  InteractionType interaction_type, // TODO: remove this from class?
118  // a bit ugly and ungeneral
119  const ParticlesTemp& particlesI,
120  const ParticlesTemp& particlesII,
121  double contact_range = 1.0, double slack = 1.0);
122 
123  /**
124  returns the particle types of the first and second group of particles,
125  respectively. This might change in the future, since types can be mixed
126  */
127  InteractionType get_interaction_type() const { return interaction_type_; }
128 
129  /**
130  returns the average number of interacting pairs of particles
131  per update
132  */
133  double get_average_number_of_contacts() const { return avg_ncontacts_; }
134 
135  /** returns the average off rate per bound complex per nanosecond
136  since last reset()
137  */
139  { return avg_off_per_contact_per_ns_; }
140 
141  /** returns the average off rate per bound particles of type I
142  since last reset()
143  */
145  { return avg_off_per_bound_I_per_ns_; }
146 
147  /** returns the average off rate per bound particles of type II
148  since last reset()
149  */
151  { return avg_off_per_bound_II_per_ns_; }
152 
153  /** returns the average on rate per missing possible contact
154  (out of all theoretically possible contacts between particlesI
155  and particles II)
156  */
158  { return avg_on_per_missing_contact_per_ns_; }
159 
160  /** returns the average on rate per unbound particles of type I
161  since last resetI()
162  */
164  { return avg_on_per_unbound_I_per_ns_; }
165 
166  /** returns the average on rate per unbound particles of type II
167  since last resetII()
168  */
170  { return avg_on_per_unbound_II_per_ns_; }
171 
172  /**
173  returns the average fraction of particles from group I
174  that are bound in each update round
175  */
177  return avg_pct_bound_particles_I_;
178  }
179 
180  /**
181  returns the average fraction of particles from group II
182  that are bound in each update round
183  */
185  return avg_pct_bound_particles_II_;
186  }
187 
188  //! returns the average fraction of particle sites from group I
189  //! that are bound in each update round
191  return avg_fraction_bound_sites_I_;
192  }
193 
194  //! returns the average fraction of particle sites from group II
195  //! that are bound in each update round
197  return avg_fraction_bound_sites_II_;
198  }
199 
200  //! returns the average fraction of particles from type I
201  //! that are nonspecifically interaction with particles of type II
202  //! (= non-zero contribution)
204  return avg_fraction_nonspecific_I_;
205  }
206 
207  //! returns the average fraction of particles from type II
208  //! that are nonspecifically interaction with particles of type I
209  //! (= non-zero contribution)
211  return avg_fraction_nonspecific_II_;
212  }
213 
214  /**
215  return the total number of particles in the first group
216  */
217  Int get_number_of_particles_1() { return n_particles_I_; }
218 
219  /**
220  return the total number of particles in the second group
221  */
222  Int get_number_of_particles_2() { return n_particles_II_; }
223 
224 
225  /** restart accumulation of all averages in the next time
226  that update() is called
227  */
228  void reset() override;
229 
230  double get_misc_stats_period_ns() const
231  { return stats_time_ns_; };
232 
233  double get_off_stats_period_ns() const
234  { return off_stats_time_ns_; };
235 
236  double get_off_I_stats_period_ns() const
237  { return off_I_stats_time_ns_; };
238 
239  double get_off_II_stats_period_ns() const
240  { return off_II_stats_time_ns_; };
241 
242  double get_on_stats_period_ns() const
243  { return on_stats_time_ns_; };
244 
245  double get_on_I_stats_period_ns() const
246  { return on_I_stats_time_ns_; };
247 
248  double get_on_II_stats_period_ns() const
249  { return on_II_stats_time_ns_; };
250 
251 
252  protected:
253  virtual void do_update(unsigned int call_num) override;
254 
255 
256  private:
257 
258  /**
259  update fraction bound with n1 bound particles of type I;
260  and n2 bound particles of type II, assuming old_updates
261  for the old average
262  */
263  // void update_fraction_bound(unsigned int n1,
264  // unsigned int n2,
265  // unsigned int old_updates);
266 
267 
268  public:
270 };
273 
274 IMPNPCTRANSPORT_END_NAMESPACE
275 
276 #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
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.