Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MultiTemperatureTrialCounter.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
17 
18 
19 
20 // ObjexxFCL Headers
21 #include <ObjexxFCL/format.hh>
22 #include <ObjexxFCL/string.functions.hh> //Pretty output.
23 #include <utility/io/ozstream.hh>
24 
25 // Utility Headers
26 #include <basic/Tracer.hh>
27 static basic::Tracer tr("protocols.canonical_sampling.MultiTemperatureTrialCounter");
28 
29 namespace protocols {
30 namespace canonical_sampling {
31 
32 using namespace core;
33 using namespace ObjexxFCL;
34 
36  tempering_( temp_in )
37 {
38  reset();
39 }
40 
41 void
43  tempering_ = temp_in;
44  reset();
45 }
46 
47 
48 /////////////////////////////////////////////////////////////////////////////
49 void
51 {
52  runtime_assert( tempering_ );
53  counters_.clear();
54  counters_.resize( tempering_->n_temp_levels() );
55 }
56 
58  show( tr.Info );
59 }
60 /////////////////////////////////////////////////////////////////////////////
61 void
62 MultiTemperatureTrialCounter::show( std::ostream& os ) const {
63  assert( tempering_ );
64  _write_to_stream( os, "" );
65 }
66 
67 void
69  utility::io::ozstream out( file, std::ios::app );
70  _write_to_stream( out, tag );
71 }
72 
73 void
74 MultiTemperatureTrialCounter::_write_to_stream( std::ostream& os, std::string const& tag ) const {
75  assert( tempering_ );
76  for ( Size i=1; i<=counters_.size(); ++i ) {
77  std::ostringstream line_header;
78  line_header << "level " << fmt::I( 4, i) << " temperature " << fmt::F( 4, 2, tempering_->temperature( i ) );
79  counters_[ i ].show( os, line_header.str(), false );
80  os << " " << tag << std::endl;
81  }
82 }
83 
85  assert( tempering_ );
86  assert( tempering_->n_temp_levels() == counters_.size() );
87  counters_[ tempering_->temperature_level() ].count_trial( tag );
88 }
89 
91  assert( tempering_ );
92  counters_[ tempering_->temperature_level() ].count_accepted( tag );
93 }
94 
96  assert( tempering_ );
97  counters_[ tempering_->temperature_level() ].count_energy_drop( tag, delta );
98 }
99 
102  return counters_[ level ];
103 }
104 
107  return counters_[ level ];
108 }
109 
110 } // namespace canonical_sampling
111 } // namespace core