IMP  2.0.1
The Integrative Modeling Platform
kernel/OptimizerState.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/OptimizerState.h \brief Shared optimizer state.
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPKERNEL_OPTIMIZER_STATE_H
9 #define IMPKERNEL_OPTIMIZER_STATE_H
10 
11 #include <IMP/kernel/kernel_config.h>
12 #include "VersionInfo.h"
13 #include "RefCounted.h"
14 #include "Pointer.h"
15 #include "WeakPointer.h"
16 #include "Object.h"
17 
18 #include <iostream>
19 
20 IMPKERNEL_BEGIN_NAMESPACE
21 
22 class Optimizer;
23 
24 //! Shared optimizer state.
25 /** The OptimizerState update method is called each time the Optimizer commits
26  to a new set of coordinates. Optimizer states may change the values of
27  particle attributes. However, changes to whether an attribute is optimized
28  or not may not be picked up by the Optimizer until the next call to
29  optimize.
30 
31  \note When logging is VERBOSE, state should print enough information
32  in evaluate to reproduce the the entire flow of data in update. When
33  logging is TERSE the restraint should print out only a constant number
34  of lines per update call.
35 
36  Implementors should see IMP_OPTIMIZER_STATE().
37  */
38 class IMPKERNELEXPORT OptimizerState : public IMP::base::Object
39 {
40  friend class Optimizer;
41  void set_optimizer(Optimizer* optimizer);
42 public:
43  OptimizerState(std::string name="OptimizerState %1%");
44 
45  //! Called when the Optimizer accepts a new conformation
46  virtual void update() = 0;
47 
48  /** Called with true at the beginning of an optimizing run and with
49  false at the end.*/
50  virtual void set_is_optimizing(bool) {}
51 
52  Optimizer *get_optimizer() const {
53  IMP_INTERNAL_CHECK(optimizer_,
54  "Must call set_optimizer before get_optimizer on state");
55  return optimizer_.get();
56  }
58 protected:
59  UncheckedWeakPointer<Optimizer> optimizer_;
60 };
61 
62 IMPKERNEL_END_NAMESPACE
63 
64 #endif /* IMPKERNEL_OPTIMIZER_STATE_H */