14 #define TRDEBUG TR.Debug
37 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
42 #include <basic/options/keys/in.OptionKeys.gen.hh>
45 #include <basic/options/keys/lh.OptionKeys.gen.hh>
46 #include <basic/options/option.hh>
50 #include <basic/Tracer.hh>
51 #include <ObjexxFCL/format.hh>
54 #include <ObjexxFCL/string.functions.hh>
57 #include <numeric/random/random.hh>
60 #ifndef _WIN32 // REQUIRED FOR WINDOWS
66 #include <utility/vector1.hh>
68 using namespace ObjexxFCL;
69 using namespace ObjexxFCL::fmt;
74 using namespace protocols::wum;
76 static basic::Tracer
TR(
"MPI.LHR");
78 static numeric::random::RandomGenerator
RG(9788321);
80 MPI_LoopHashRefine::MPI_LoopHashRefine(
char machine_letter ):
83 save_state_interval_(300),
85 totaltime_loophash_(0),
87 totaltime_batchrelax_(0),
90 total_structures_relax_(0),
92 total_metropolis_accepts_(0),
93 ident_string_(
"ident")
100 using namespace basic::options;
101 using namespace basic::options::OptionKeys;
107 rms_limit_ = option[ OptionKeys::lh::rms_limit ]();
110 if( option[ OptionKeys::lh::mpi_resume ].user() ){
111 mpi_resume_ = option[ OptionKeys::lh::mpi_resume ]();
113 jobname_ = option[ OptionKeys::lh::jobname ]();
128 using namespace basic::options;
129 using namespace basic::options::OptionKeys;
132 TR <<
"Reading in structures..." << std::endl;
149 while( input.has_another_pose() ) {
151 input.fill_pose( pose, *rsd_set );
153 if ( option[ OptionKeys::constraints::cst_fa_file ].user() ) {
155 TR <<
"Read constraints: " << ( cstset->has_constraints() ?
"YES" :
"NONE" ) << std::endl;
165 ss->fill_struct( pose,
"empty_tag" );
166 ss->add_energy(
"censcore", 0 );
167 ss->add_energy(
"extra_score", 0 );
168 ss->add_energy(
"combined_score", 0 );
169 ss->add_energy(
"parent_score", 0 );
170 ss->add_energy(
"lhcount", 0 );
171 ss->add_energy(
"round", 0 );
172 ss->add_energy(
"expire", 0 );
173 if( ss->get_string_value(
"usid") ==
"" ){
174 ss->add_string_value(
"usid",
"_" + string_of(count));
176 ss->add_string_value(
"husid", ss->get_string_value(
"usid") );
177 ss->add_energy(
"state", 0 );
178 ss->add_energy(
"ltime", time(NULL) );
179 ss->add_energy(
"master",
mpi_rank() );
180 ss->add_energy(
"emperor_count", 0 );
185 if ( temp_lib.size() == 0 ){
186 TR.Error <<
"Error reading starting structures: 0 valid structures read. Check your input files and parameters" << std::endl;
187 utility_exit_with_message(
"Error reading starting structures: 0 valid structures read. Check your input files and parameters" );
190 TR <<
"Loaded " << temp_lib.size() <<
" starting structures" << std::endl;
192 core::Size position = structure_read_offset % temp_lib.size();
196 ss = temp_lib.get_struct( position )->clone();
197 ss->add_energy(
"ssid", count );
200 if(position>=temp_lib.size()) position = 0;
213 long starttime = time(NULL);
216 long endtime = time(NULL);
224 TR <<
"Saving state.. " << std::endl;
243 static int lasttime = 0;
244 if( (time(NULL) - lasttime) < 300 )
return;
245 lasttime = time(NULL);
269 if( add_algorithm ==
"no" ) result =
false;
274 utility_exit_with_message(
"FATAL ERROR: Unknown adding algorithm: '" + add_algorithm +
"'" );
289 using namespace basic::options;
290 using namespace basic::options::OptionKeys;
295 TRDEBUG <<
"Checking for zero size .. " << std::endl;
318 if ( option[ OptionKeys::lh::bss]() ) {
320 core::io::silent::BinaryProteinSilentStruct *ss = dynamic_cast < core::io::silent::BinaryProteinSilentStruct * > ( &(pss) );
321 if ( jt_pss == NULL || ss == NULL ) utility_exit_with_message(
"FATAL ERROR: This code only runs with Binary Protein SilentStructs " );
322 the_rms = ss->
CA_rmsd( *jt_pss );
325 core::io::silent::ProteinSilentStruct *ss = dynamic_cast < core::io::silent::ProteinSilentStruct * > ( &(pss) );
326 if ( jt_pss == NULL || ss == NULL ) utility_exit_with_message(
"FATAL ERROR: This code only runs with Protein SilentStructs " );
327 the_rms = ss->
CA_rmsd( *jt_pss );
329 TRDEBUG <<
"The rms: " << the_rms << std::endl;
330 if ( the_rms < closest_rms ){
332 closest_rms = the_rms;
338 TR <<
"RMS_Time: " << rms_time << std::endl;
343 TR <<
"Enew vd Eold " << new_struct_score <<
" " << energy_old << std::endl;
344 if( new_struct_score < energy_old ){
346 *(*closest_struct) = pss;
356 TR <<
"No structure added" << std::endl;
370 TR <<
"ssid expired: " + ObjexxFCL::string_of( ssid ) +
" - rejected structure" << std::endl;
376 bool replace_it =
false;
378 if( pss.
get_energy(
"round") > (*ssid_match)->get_energy(
"round") ) replace_it =
true;
387 bool metropolis_replace =
false;
392 if( ( energy_diff_T >= 0.0 ) ) metropolis_replace =
true;
393 else if ( energy_diff_T > (-10.0) ){
398 if ( metropolis_replace ) {
414 TR <<
"N:" <<
library_central_.
store().size() <<
" <ssid> <score> <censc> <rms> <round> <time> <master> <lhcount> ----" << std::endl;
427 it != new_structs.
end(); ++it )
429 runtime_assert( *it );
432 result = result || local_result;
456 it != new_structs.
end(); ++it )
460 if( (*it)->get_energy(
"round") > 0 ){
463 TR <<
"Trying to dump structure of round == 0. Refusing plainly. " << std::endl;
467 TR <<
"Write time: " << write_time << std::endl;
473 TR.Error <<
"ERROR: Havce no structure to send" << std::endl;
479 resultpack->set_wu_type(
"resultpack" );
481 new_struct->add_energy(
"ssid", newssid);
482 resultpack->decoys().add( new_struct );
500 std::stringstream sstream;
508 <<
" |" << I(5, time(NULL) - ss.
get_energy(
"ltime") )
510 <<
" |" << I(1, ss.
get_energy(
"lhcount")) <<
"]";
511 return sstream.str();