IMP  2.0.0
The Integrative Modeling Platform
PeriodicOptimizerState.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/PeriodicOptimizerState.h
3  * \brief Angle restraint between three particles.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_PERIODIC_OPTIMIZER_STATE_H
10 #define IMPCORE_PERIODIC_OPTIMIZER_STATE_H
11 
12 #include <IMP/core/core_config.h>
13 #include <IMP/OptimizerState.h>
15 IMPCORE_BEGIN_NAMESPACE
16 
17 /** This optimizer state calls its do_update() method with a given
18  period.*/
19 class IMPCOREEXPORT PeriodicOptimizerState : public OptimizerState
20 {
21  unsigned int period_, call_number_, update_number_;
22  public:
23  PeriodicOptimizerState(std::string name);
24  /** Called when an optimization begins. It resets the current call number
25  as well as making sure that the last frame is written.*/
26  IMP_IMPLEMENT(void set_is_optimizing(bool tf));
27  void set_period(unsigned int p);
28  unsigned int get_period() const;
29  /** Reset everything to look like the first call.*/
30  virtual void reset();
31  IMP_IMPLEMENT(virtual void update());
32  /** Force the optimizer state to perform its action now.
33  */
34  void update_always();
35  //! Return the number of times update has been called
36  unsigned int get_number_of_updates() const {
37  return update_number_;
38  }
39  //! Set the counter
40  void set_number_of_updates(unsigned int n) {
41  update_number_=n;
42  }
43 protected:
44  /** This method is called every get_period() update calls.*/
45  virtual void do_update(unsigned int call_number)=0;
46 };
47 
49 
50 IMPCORE_END_NAMESPACE
51 
52 #endif /* IMPCORE_PERIODIC_OPTIMIZER_STATE_H */