Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HamiltonianExchange.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file /protocols/canonical_sampling/MetropolisHastingsMover.hh
11 /// @brief Implement replica exchange in the MetropolisHastingsMover Framework.
12 /// @author Oliver Lange ( oliver.lange@tum.de )
13 
14 #ifndef INCLUDED_protocols_canonical_sampling_HamiltonianExchange_hh
15 #define INCLUDED_protocols_canonical_sampling_HamiltonianExchange_hh
16 
17 #ifdef USEMPI
18 #include <mpi.h> //keep first
19 #endif
20 
21 // Unit Headers
24 
25 // Project Headers
26 //#include <protocols/jd2/Job.fwd.hh>
27 
28 #include <core/pose/Pose.fwd.hh>
30 
31 // Utility Headers
32 #include <core/types.hh>
33 #include <utility/vector1.hh>
34 #include <utility/vector0.hh>
35 
36 namespace protocols {
37 namespace canonical_sampling {
38 
39 ///@details
44 
45 public:
46 
48 
49  //important d'tor to delete some C-style arrays
51 
53 
55 
56  virtual
57  void apply( core::pose::Pose& ) {};
58 
59  virtual
61  get_name() const;
62 
64  clone() const;
65 
66  virtual
68  fresh_instance() const;
69 
70  virtual
71  void
73  utility::tag::TagPtr const tag,
75  protocols::filters::Filters_map const & filters,
76  protocols::moves::Movers_map const & movers,
77  core::pose::Pose const & pose
78  );
79 
80  /// @brief not possible for HamExchange -- exit with ERROR if called
83 
84 
85  /// @brief execute the temperatur move ( called by observer_after_metropolis )
86  /// returns the current temperatur in kT.
89 
90  /// @brief callback executed before any Monte Carlo trials
91  virtual void
93  core::pose::Pose& pose,
94  MetropolisHastingsMover const& metropolis_hastings_mover,
95  core::Size cycle //non-zero if trajectory is restarted
96  );
97 
98  virtual
99  void
101  core::pose::Pose & pose,
102  protocols::canonical_sampling::MetropolisHastingsMover const & metropolis_hastings_mover,
103  core::Size level,
105  core::Size cycle
106  );
107 
108  /// @brief callback executed after all Monte Carlo trials
109  virtual
110  void
112  core::pose::Pose & pose,
113  protocols::canonical_sampling::MetropolisHastingsMover const & metropolis_hastings_mover
114  );
115 
116  void show( std::ostream& ) const;
117 
118  void next_exchange_schedule();
119 
120 protected:
121  void set_defaults();
122  /// @brief Assigns user specified values to primitive members using command line options
123  void init_from_options();
124 
125  /// @brief return to uninitialized status
126  void clear();
127 
128  /// @brief initialize temperatures and weights from file, return false if IO error occurrs
129  virtual bool initialize_from_file( std::string const& filename );
130 
131 
132 #ifdef USEMPI
133  MPI_Comm const& mpi_comm() const {
134  return mpi_comm_;
135  }
136 
137  void set_mpi_comm( MPI_Comm const& );
138 
139 #endif
140 
141  int rank() {
142  return rank_;
143  }
144 
145 private:
147  void find_exchange_partner( int& partner, bool& is_master );
148  ///@brief small helper function; compute unique key out of (z1, z2, ... , zN) excluding zD
150  GridCoord const& coord,
151  GridCoord const& max_coord,
152  Size exclude_dim = 0
153  );
154 /// ------------------ register cmdline options ---------------------------
155 
156 private:
157  static bool options_registered_;
158 
159 public:
160  static void register_options();
161 
162 /// ---------------- member variables --------------------------
163 
164 private:
165 #ifdef USEMPI
166  MPI_Comm mpi_comm_;
167 #endif
168  // rank within mpi_comm_
169  int rank_;
170 
171  /// the different score-funcitons
173 
174  // exchange schedule determines which nodes try to swap at a given trial phase
178 
179  // exchange happens between neighbouring cells in a D dimensional grid
180  // in temperature replica-exchange usually D=1.
184 }; //end HamiltonianExchange
185 
186 /// @brief Test IO operator for debug and Python bindings
187 std::ostream& operator << ( std::ostream & os, HamiltonianExchange const& );
188 
189 } //namespace canonical_sampling
190 } //namespace protocols
191 
192 #endif //INCLUDED_protocols_canonical_sampling_HamiltonianExchange_HH