Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParallelTempering.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_ParallelTempering_hh
15 #define INCLUDED_protocols_canonical_sampling_ParallelTempering_hh
16 
17 #ifdef USEMPI
18 #include <mpi.h> //keep first
19 #endif
20 
21 // Unit Headers
24 #include <protocols/moves/Mover.hh>
25 
26 // Project Headers
29 #include <core/pose/Pose.fwd.hh>
30 #include <numeric/random/WeightedSampler.hh>
31 #include <protocols/jd2/Job.fwd.hh>
32 
33 // Utility Headers
34 #include <core/types.hh>
35 #include <utility/vector1.hh>
36 #include <utility/vector0.hh>
37 
38 // C Headers
39 #include <time.h>
40 
41 namespace protocols {
42 namespace canonical_sampling {
43 
44 ///@details
47 public:
48 
50 
51  //important d'tor to delete some C-style arrays
53 
55 
57 
58  virtual
59  void apply( core::pose::Pose& ) {};
60 
61  virtual
63  get_name() const;
64 
66  clone() const;
67 
68  virtual
70  fresh_instance() const;
71 
72  virtual
73  void
75  utility::tag::TagPtr const tag,
77  protocols::filters::Filters_map const & filters,
78  protocols::moves::Movers_map const & movers,
79  core::pose::Pose const & pose
80  );
81 
82  /// @brief execute the temperatur move ( called by observer_after_metropolis )
83  /// returns the current temperatur in kT.
86 
87  /// @brief callback executed before any Monte Carlo trials
88  virtual void
90  core::pose::Pose & pose,
91  protocols::canonical_sampling::MetropolisHastingsMover const & metropolis_hastings_mover,
92  core::Size cycle //non-zero if trajectory is restarted
93  );
94 
95  /// @brief callback executed after all Monte Carlo trials
96  virtual
97  void
99  core::pose::Pose & pose,
100  protocols::canonical_sampling::MetropolisHastingsMover const & metropolis_hastings_mover
101  );
102 
103 protected:
104  void set_defaults();
105  /// @brief Assigns user specified values to primitive members using command line options
106  void init_from_options();
107 
108 #ifdef USEMPI
109  MPI_Comm const& mpi_comm() const {
110  return mpi_comm_;
111  }
112 
113  void set_mpi_comm( MPI_Comm const& );
114 
115 #endif
116 
117  int rank() {
118  return rank_;
119  }
120 
121 private:
122  void deallocate_buffers();
124  void setup_exchange_schedule( Size nlevels );
125  void shuffle_temperatures( double *energies );
126 /// ------------------ register cmdline options ---------------------------
127 
128 private:
129  static bool options_registered_;
130 
131 public:
132  static void register_options();
133 
134 /// ---------------- member variables --------------------------
135 
136 private:
137 #ifdef USEMPI
138  MPI_Comm mpi_comm_;
139 #endif
140 // rank within mpi_comm_
141  int rank_;
145  // C-style arrays for communication in MPI
146  double *last_energies_;
149  std::map<std::pair<int, int>, core::Size> exchange_attempts_;
150  std::map<std::pair<int, int>, core::Size> exchange_accepts_;
151  clock_t start_time_;
153 
154 }; //end ParallelTempering
155 
156 } //namespace canonical_sampling
157 } //namespace protocols
158 
159 #endif //INCLUDED_protocols_canonical_sampling_ParallelTempering_HH