Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TrialCounter.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
11 /// @brief
12 /// @author Phil Bradley
13 
14 // Unit Headers
16 
17 // ObjexxFCL Headers
18 #include <ObjexxFCL/format.hh>
19 #include <ObjexxFCL/string.functions.hh> //Pretty output.
20 
21 // Utility Headers
22 #include <basic/Tracer.hh>
23 static basic::Tracer tr("protocols.moves.TrialCounter");
24 
25 namespace protocols {
26 namespace moves {
27 
28 using namespace core;
29 using namespace ObjexxFCL::fmt;
30 
31 /////////////////////////////////////////////////////////////////////////////
32 void
34 {
35  trial_counter_.clear();
36  accept_counter_.clear();
37  energy_drop_counter_.clear();
38 }
39 
40 ///@detail return number of trials since last reset
43  Size ntrials( 0 );
44  for ( std::map< std::string, int >::const_iterator
45  it=trial_counter_.begin(); it != trial_counter_.end(); ++it ) {
46  ntrials += it->second;
47  }
48  return ntrials;
49 }
50 
51 void TrialCounter::show() const {
52  show( tr.Info );
53 }
54 /////////////////////////////////////////////////////////////////////////////
55 void
56 TrialCounter::show( std::ostream& os, std::string line_header, bool endline ) const {
57  if ( line_header.size() ) {
58  line_header=line_header+" ";
59  }
60  for ( std::map< std::string, int >::const_iterator
61  it=trial_counter_.begin(); it != trial_counter_.end(); ++it ) {
62  std::string const & tag( it->first );
63  int const ntrials( it->second );
64  if ( accept_counter_.count( tag )) {
65  int const accepts( accept_counter_.find( tag )->second );
66  core::Real const energy_drop( energy_drop_counter_.find( tag )->second );
67  os << line_header << A( 16, tag ) <<
68  " trials= " << I( 6, ntrials ) << "; " <<
69  " accepts= " << F( 6, 4, core::Real( accepts )/ntrials ) << "; " <<
70  " energy_drop/trial= " << F( 9, 5, core::Real( energy_drop ) / ntrials );
71  if ( endline ) os << std::endl;
72  } else { //no accepts
73  os << A( 16, tag ) << " trials= " << I( 6, ntrials ) << " NO ACCEPTS.";
74  if ( endline ) os << std::endl;
75  } // else
76  } // for
77 }
78 
80  return trial_counter_[ tag ];
81 }
82 
84  return accept_counter_[ tag ];
85 }
86 
88  return energy_drop_counter_[ tag ];
89 }
90 
92  ++trial_counter_[ tag ];
93 }
94 
96  ++accept_counter_[ tag ];
97 }
98 
100  energy_drop_counter_[ tag ] += delta;
101 }
102 
103 
104 } // namespace moves
105 } // namespace core