42 #include <basic/options/keys/in.OptionKeys.gen.hh>
43 #include <basic/options/keys/packing.OptionKeys.gen.hh>
48 #include <basic/Tracer.hh>
52 #include <numeric/random/random.hh>
55 #include <utility/file/file_sys_util.hh>
56 #include <utility/io/ozstream.hh>
57 #include <utility/pointer/owning_ptr.hh>
58 #include <utility/tag/Tag.hh>
61 #include <utility/vector0.hh>
62 #include <utility/vector1.hh>
65 #include <utility/excn/Exceptions.hh>
66 #include <basic/options/option.hh>
74 static basic::Tracer
TR(
"protocols.canonical_sampling.MetropolisHastingsMover" );
75 static numeric::random::RandomGenerator
RG(638767547);
78 namespace canonical_sampling {
93 return "MetropolisHastings";
106 Mover(metropolis_hastings_mover),
107 monte_carlo_( new protocols::moves::MonteCarlo(*metropolis_hastings_mover.monte_carlo_) ),
108 ntrials_(metropolis_hastings_mover.ntrials_),
109 output_name_(metropolis_hastings_mover.output_name_),
110 weighted_sampler_(metropolis_hastings_mover.weighted_sampler_),
111 trial_(metropolis_hastings_mover.trial_)
114 movers_.push_back(reinterpret_cast<ThermodynamicMover *>(metropolis_hastings_mover.
movers_[i]()));
118 observers_.push_back(reinterpret_cast<ThermodynamicObserver *>(metropolis_hastings_mover.
observers_[i]()));
133 TR.Info <<
" obtained output name from JobDistributor " << std::endl;
136 TR.Info <<
" running with preset output name: " <<
output_name() << std::endl;
141 TR.Info <<
"no temperature controller in MetropolisHastings defined... generating FixedTemperatureController" << std::endl;
144 using namespace core;
145 bool restart =
false;
148 Real temperature = -1.0;
157 tempering_->initialize_simulation(pose, *
this, cycle_number );
159 tempering_->initialize_simulation(pose, *
this, temp_level, temperature, cycle_number );
163 TR <<
"Initializing " <<
movers_[i]->get_name() << std::endl;
164 movers_[i]->set_metropolis_hastings_mover(
this);
165 movers_[i]->initialize_simulation(pose, *
this, cycle_number);
173 TR <<
"Initializing " <<
observers_[i]->get_name() << std::endl;
174 observers_[i]->initialize_simulation(pose, *
this, cycle_number);
177 TR <<
"Initial Score:\n";
180 TR <<
"Running " <<
ntrials_-cycle_number <<
" trials..." << std::endl;
197 mover->last_proposal_density_ratio(),
198 mover->last_inner_score_temperature_delta()
203 mover->observe_after_metropolis(*
this);
204 TR.Debug <<
"current move accepted " << accepted <<std::endl;
206 observers_[i]->observe_after_metropolis(*
this);
222 TR <<
"Finalizing " <<
movers_[i]->get_name() << std::endl;
223 movers_[i]->finalize_simulation(pose, *
this);
227 TR <<
"Finalizing " <<
observers_[i]->get_name() << std::endl;
228 observers_[i]->finalize_simulation(pose, *
this);
233 TR <<
"Final Score:" << std::endl;
245 return "MetropolisHastingsMover";
286 TagPtr const subtag = *subtag_it;
288 if (subtag->getName() ==
"Add") {
290 protocols::moves::Movers_map::const_iterator mover_iter( movers.find( mover_name ) );
291 if ( mover_iter == movers.end() ) {
292 TR <<
"Mover not found for XML tag:\n" << subtag << std::endl;
293 throw utility::excn::EXCN_RosettaScriptsOption(
"");
295 mover = mover_iter->second;
298 mover = mover_factory->
newMover(subtag, data, filters, movers, pose);
309 }
else if ( th_observer ) {
311 if ( temp_controller ) {
313 throw utility::excn::EXCN_RosettaScriptsOption(
"cannot define two TemperatureControllers" );
320 TR <<
"Mover is not a ThermodynamicMover or ThermodynamicObserver for XML tag:\n" << subtag << std::endl;
321 throw utility::excn::EXCN_RosettaScriptsOption(
"");
385 bool cumulate_replicas
388 if (cumulate_jobs || cumulate_replicas) runtime_assert(utility::io::ozstream::MPI_reroute_rank() >= 0);
390 std::ostringstream file_name_stream;
392 if (!cumulate_jobs) {
397 if (!cumulate_replicas && replica) {
398 if ( file_name_stream.str().length() ) file_name_stream <<
"_";
399 file_name_stream << std::setfill(
'0') << std::setw(3) << replica;
402 if ( suffix.length() ) {
403 if ( file_name_stream.str().length() ) file_name_stream <<
"_";
404 file_name_stream << suffix;
407 return file_name_stream.str();
435 mover->set_preserve_detailed_balance(
true);
458 backrub_mover->branchopt().read_database();
470 using namespace basic::options;
471 using namespace basic::options::OptionKeys;
474 small_mover->nmoves(1);
479 movemap->set_bb(
true);
481 small_mover->movemap(movemap);
493 using namespace basic::options;
494 using namespace basic::options::OptionKeys;
497 shear_mover->nmoves(1);
502 movemap->set_bb(
true);
504 shear_mover->movemap(movemap);
519 using namespace basic::options;
520 using namespace basic::options::OptionKeys;
524 if ( option[ packing::resfile ].user() ) {
532 sidechain_mover->set_task_factory(main_task_factory);
533 sidechain_mover->set_prob_uniform(prob_uniform);
534 sidechain_mover->set_prob_withinrot(prob_withinrot);
550 using namespace basic::options;
551 using namespace basic::options::OptionKeys;
555 if ( option[ packing::resfile ].user() ) {
563 sidechain_mc_mover->set_task_factory(main_task_factory);
564 sidechain_mc_mover->set_prob_uniform(prob_uniform);
565 sidechain_mc_mover->set_prob_withinrot(prob_withinrot);
566 sidechain_mc_mover->setup(
monte_carlo_->score_function().clone());
567 sidechain_mc_mover->set_ntrials(ntrials);