Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RationalMonteCarlo.cc
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/simple_moves/rational_mc/RationalMonteCarlo.cc
11 /// @author Christopher Miles (cmiles@uw.edu)
12 
13 // Unit header
15 
16 // C/C++ headers
17 #include <iostream>
18 #include <string>
19 
20 // External headers
21 #include <boost/bind.hpp>
22 #include <boost/function.hpp>
23 #include <boost/unordered/unordered_map.hpp>
24 
25 // Utility headers
26 #include <basic/Tracer.hh>
27 
28 // Project headers
30 #include <core/pose/Pose.hh>
32 
33 // Package headers
35 #include <protocols/moves/Mover.hh>
36 
37 namespace protocols {
38 namespace simple_moves {
39 namespace rational_mc {
40 
41 using core::Real;
42 using core::Size;
43 using core::pose::Pose;
48 
49 static basic::Tracer TR("protocols.simple_moves.RationalMonteCarlo");
50 
51 RationalMonteCarlo::RationalMonteCarlo(MoverOP mover, ScoreFunctionOP score, Size num_trials, Real temperature, bool recover_low)
52  : Mover("RationalMonteCarlo"), mover_(mover), num_trials_(num_trials), recover_low_(recover_low), next_trigger_id_(0) {
53  mc_ = new protocols::moves::MonteCarlo(*score, temperature);
54  protocols::viewer::add_monte_carlo_viewer(*mc_, "RationalMonteCarlo");
55 }
56 
58  mc_->reset(pose);
59  mc_->reset_counters();
60 
61  for (Size i = 1; i <= num_trials(); ++i) {
62  Pose copy(pose);
63  mover_->apply(pose);
64 
65  if (mc_->boltzmann(pose)) { // accept
66  fire_all_triggers(pose);
67  } else { // reject
68  pose = copy;
69  }
70  }
71 
72  if (recover_low())
73  mc_->recover_low(pose);
74 
75  // Show simulation statistics
76  mc_->show_counters();
77  mc_->score_function().show(TR, pose);
78  TR.flush();
79 }
80 
82  return "RationalMonteCarlo";
83 }
84 
86  Size tid = ++next_trigger_id_;
87  triggers_[tid] = trigger;
88  return tid;
89 }
90 
92  Triggers::const_iterator i = triggers_.find(trigger_id);
93  if (i == triggers_.end()) {
94  TR.Warning << "Attempt to remove invalid trigger_id => " << trigger_id << std::endl;
95  return;
96  }
97  triggers_.erase(i);
98 }
99 
101  for (Triggers::iterator i = triggers_.begin(); i != triggers_.end(); ++i) {
102  RationalMonteCarloTrigger& t = i->second;
103  t(pose);
104  }
105 }
106 
107 // -- Accessors -- //
109  return num_trials_;
110 }
111 
113  return recover_low_;
114 }
115 
117  return mover_;
118 }
119 
121  return mc_->temperature();
122 }
123 
125  return mc_->score_function();
126 }
127 
129  return mc_->lowest_score_pose();
130 }
131 
133  return mc_->last_accepted_pose();
134 }
135 
136 // -- Mutators -- //
139 }
140 
141 void RationalMonteCarlo::set_recover_low(bool recover_low) {
143 }
144 
146  mover_ = mover;
147 }
148 
150  mc_->set_temperature(temperature);
151 }
152 
154  mc_->score_function(*score);
155 }
156 
157 void RationalMonteCarlo::reset(const Pose& pose) {
158  mc_->reset(pose);
159 }
160 
162  mc_->set_autotemp(true, quench);
163 }
164 
166  mc_->set_autotemp(false, 0);
167 }
168 
169 } // namespace rational_mc
170 } // namespace simple_moves
171 } // namespace protocols