24 #include <ObjexxFCL/format.hh>
25 #include <ObjexxFCL/string.functions.hh>
28 #include <numeric/numeric.functions.hh>
29 #include <numeric/random/random.hh>
32 #include <basic/Tracer.hh>
33 #include <basic/prof.hh>
35 #include <basic/options/option.hh>
36 #include <basic/options/keys/mc.OptionKeys.gen.hh>
39 #include <utility/vector1.hh>
51 static basic::Tracer
TR(
"protocols.moves.MonteCarlo");
52 static numeric::random::RandomGenerator
mc_RG(62452);
58 using namespace ObjexxFCL::fmt;
64 utility::pointer::ReferenceCount(),
65 last_accepted_pose_( src.last_accepted_pose_ ? new core::pose::
Pose( * src.last_accepted_pose_ ) : 0 ),
66 lowest_score_pose_( src.lowest_score_pose_ ? new core::pose::
Pose( * src.lowest_score_pose_ ) : 0 ),
67 temperature_( src.temperature_ ),
68 score_function_( src.score_function_ ? src.score_function_->
clone() : static_cast< core::scoring::
ScoreFunction * > (0) ),
69 autotemp_( src.autotemp_ ),
70 quench_temp_( src.quench_temp_ ),
71 last_accept_( src.last_accept_ ),
72 mc_accepted_( src.mc_accepted_ ),
73 counter_( src.counter_ ),
74 update_boinc_( src.update_boinc_ ),
75 total_score_of_last_considered_pose_( src.total_score_of_last_considered_pose_ ),
76 last_accepted_score_( src.last_accepted_score_ ),
77 lowest_score_( src.lowest_score_ ),
78 heat_after_cycles_( src.heat_after_cycles_ ),
79 convergence_checks_( src.convergence_checks_ ),
80 last_check_( src.last_check_ ),
81 check_frequency_( src.check_frequency_ )
88 Pose const & init_pose,
90 Real const temperature
92 temperature_( temperature ),
97 update_boinc_( true ),
98 total_score_of_last_considered_pose_( 0.0 ),
99 last_accepted_score_( 0.0 ),
100 lowest_score_( 0.0 ),
101 heat_after_cycles_( 150 )
110 check_frequency_ = basic::options::option[ basic::options::OptionKeys::mc::convergence_check_frequency ]();
115 Real const temperature
117 temperature_( temperature ),
122 update_boinc_( true ),
123 total_score_of_last_considered_pose_( 0.0 ),
124 last_accepted_score_( 0.0 ),
125 lowest_score_( 0.0 ),
126 heat_after_cycles_( 150 )
133 check_frequency_ = basic::options::option[ basic::options::OptionKeys::mc::convergence_check_frequency ]();
149 Pose const & init_pose,
178 <<
" " << (*score_function_)(*last_accepted_pose_)
179 <<
" " << (*score_function_)(*lowest_score_pose_)
195 TR <<
"MonteCarlo:: last_accepted_score,lowest_score: " <<
221 using namespace scoring;
236 TR <<
"score copy" << std::endl;
237 Real const copy_score = (*score_function_)( copy_pose );
239 TR <<
"Score discrepancy. lowest_score: " <<
lowest_score_ <<
" vs copy score: " << copy_score << std::endl;
240 TR <<
"pose score: ";
244 TR <<
"copy score: ";
248 TR <<
"Difference: ";
269 TR <<
"score copy" << std::endl;
270 Real const copy_score = (*score_function_)( copy_pose );
272 TR <<
"Score discrepancy. last_accepted_score: " <<
last_accepted_score_ <<
" vs copy score: " << copy_score << std::endl;
273 TR <<
"pose score: ";
277 TR <<
"copy score: ";
281 TR <<
"Difference: ";
297 PROF_START( basic::MC_ACCEPT );
300 PROF_STOP( basic::MC_ACCEPT );
324 core::Real const inner_score_temperature_delta
329 #ifdef BOINC_GRAPHICS
331 boinc::Boinc::update_graphics_current( pose );
343 TR <<
"score copy" << std::endl;
344 Real const copy_score = (*score_function_)( copy_pose );
345 if ( std::abs( copy_score - score ) > 1
E-6) {
346 TR <<
"Score discrepancy. score: " << score <<
" vs copy score: " << copy_score << std::endl;
347 TR <<
"pose score: ";
351 TR <<
"copy score: ";
355 TR <<
"Difference: ";
366 #ifdef BOINC_GRAPHICS
368 boinc::Boinc::update_mc_trial_info(
counter_.
trial( move_type ), move_type );
372 Real const probability = std::exp( std::min (40.0, std::max(-40.0,boltz_factor)) ) * proposal_density_ratio;
373 if ( probability < 1 ) {
374 if (
mc_RG.uniform() >= probability ) {
378 pose = ( *last_accepted_pose_ );
403 PROF_START( basic::MC_ACCEPT );
407 #ifdef BOINC_GRAPHICS
421 #ifdef BOINC_GRAPHICS
423 boinc::Boinc::update_graphics_low_energy( pose,
lowest_score() );
429 PROF_STOP( basic::MC_ACCEPT );
448 Real const probability = std::exp( std::min (40.0, std::max(-40.0,boltz_factor)) ) * proposal_density_ratio;
449 if ( probability < 1 ) {
450 if (
mc_RG.uniform() >= probability ) {
472 PROF_START( basic::MC_ACCEPT );
481 PROF_STOP( basic::MC_ACCEPT );
489 PROF_START( basic::MC_ACCEPT );
491 PROF_STOP( basic::MC_ACCEPT );
496 PROF_START( basic::MC_ACCEPT );
498 PROF_STOP( basic::MC_ACCEPT );
508 PROF_START( basic::MC_ACCEPT );
510 PROF_STOP( basic::MC_ACCEPT );
518 PROF_START( basic::MC_ACCEPT );
520 PROF_STOP( basic::MC_ACCEPT );
530 Real const quench_temp
619 TR <<
"autotemp_accept: reset temperature_ = " <<
temperature_ << std::endl;
629 (**it)( pose, *
this,
reject );
642 os <<
"protocols.moves.MonteCarlo:\n";
643 os <<
"\"Temperature\" (kT): " << mc.
temperature() <<
"\n";
647 os <<
"last_accept = " << mc.
lowest_score() << std::endl;