Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EvaluatedTrialMover.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 PoseEvaluator
11 /// @brief PoseEvaluator
12 /// @detailed
13 ///
14 ///
15 /// @author Oliver Lange
16 
17 
18 
19 // Unit Headers
21 
22 // Package Headers
26 
27 // Project Headers
30 #include <core/pose/Pose.hh>
31 #include <core/scoring/Energies.hh>
32 
33 // ObjexxFCL Headers
34 
35 // Utility headers
36 // AUTO-REMOVED #include <basic/Tracer.hh>
37 // AUTO-REMOVED #include <core/scoring/rms_util.hh>
38 #include <utility/io/ozstream.hh>
39 #include <utility/file/file_sys_util.hh>
40 #include <basic/prof.hh>
41 
45 #include <utility/vector1.hh>
46 
47 // C++ headers
48 
49 
50 namespace protocols {
51 namespace simple_filters {
52 
53 using namespace core;
54 using namespace core::io::silent;
55 
56 /// c'stor
58  moves::MoverOP mover_in,
59  moves::MonteCarloOP mc_in,
60  evaluation::PoseEvaluatorOP evaluator_in,
61  std::string tag
62 ) :
63  TrialMover( mover_in, mc_in),
64  tag_( tag )
65 {
67  evaluator_->add_evaluation( new simple_filters::ScoreEvaluator( "full",mc_in->score_function().clone() ) );
68  evaluator_->add_evaluation( evaluator_in );
69 }
70 
72 
73 void
75  /// OKAY this IS code duplication but it is just a HACK
76  /// it's true. code duplication is totally ok when it's just a hack. :P
77  using namespace protocols::moves;
78 
80  /// get the initial scores
81  if ( keep_stats_type() == all_stats ) {
82  stats_.add_score( mc_->last_accepted_score() ); ///< initial_last_accepted_score
83  stats_.add_score( pose.energies().total_energy() ); ///< initial_pose_score
84  }
85 
86  /// make the move
87  mover_->apply( pose );
88 
89  PROF_START( basic::TEST3 );
91  evaluator_->apply( pose, tag_, *pss );
92  PROF_STOP( basic::TEST3 );
93 
94  if ( keep_stats_type() == all_stats ) { //// score and get residue energies
95  //Real newscore =
96  mc_->score_function()( pose );
97  //std::cout << "newscore: " << newscore << std::endl;
98  /// Now handled automatically. mc_->score_function().accumulate_residue_total_energies( pose );
99  stats_.add_score( pose.energies().total_energy() ); ///< score_after_move
100  //if ( newscore != pose.energies().total_energy() ) {
101  // std::cout << " newscore != perceived newscore: " << newscore << " != " <<
102  // pose.energies().total_energy() << std::endl;
103  //}
104  }
105 
106  /// test if MC accepts or rejects it
107  bool accepted_move = mc_->boltzmann( pose, mover_->type() );
108 
109  PROF_START( basic::TEST3 );
110  pss->add_energy( "acceptance", accepted_move );
111  evals_.push_back( pss );
112  PROF_STOP( basic::TEST3 );
113 
114  if ( keep_stats_type() > no_stats ) {
115  stats_.accepted( accepted_move );
116  stats_.print( mc_, mover_->type() );
117  // std::cout << "Acceptance rate: " << stats_.acceptance_rate() << std::endl;
118  }
119 
120 
121 }
122 
125  return "EvaluatedTrialMover";
126 }
127 
128 void
130  //copy some of the functionality of SilentFileData::write_silent_struct
131  // want to avoid opening/closing of file for each line of data ... write as burst
132  // might add this to SilentFileData
133  if ( evals_.size() ) {
134  utility::io::ozstream output;
135  if ( !utility::file::file_exists( file ) ) {
136  output.open( file );
137  evals_[ 1 ]->print_header( output );
138  } else {
139  output.open_append( file );
140  }
141 
142  for ( SilentInfoList::const_iterator it=evals_.begin(), eit=evals_.end(); it!=eit; ++it ) {
143  (*it)->print_scores( output );
144  }
145  }
146 }
147 
148 
149 
150 }
151 }