Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IteratedConvergenceMover.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 src/protocols/moves/IteratedConvergenceMover.cc
11 /// @brief Implementation of IteratedConvergenceMover, class to repeatedly apply a submover until filter convergence is reached
12 /// @author Rocco Moretti (rmoretti@u.washington.edu)
13 
14 // Unit headers
17 
18 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
19 // AUTO-REMOVED #include <protocols/rosetta_scripts/util.hh>
21 
22 // AUTO-REMOVED #include <core/pose/Pose.hh>
23 // AUTO-REMOVED #include <basic/options/option.hh>
24 #include <basic/Tracer.hh>
25 
26 // Utility Headers
27 #include <utility/exit.hh>
28 #include <utility/tag/Tag.hh>
29 // AUTO-REMOVED #include <utility/string_util.hh>
30 
31 // option key includes
32 // AUTO-REMOVED #include <basic/options/keys/packing.OptionKeys.gen.hh>
33 
34 #include <utility/vector0.hh>
35 #include <utility/vector1.hh>
36 
37 
38 namespace protocols {
39 namespace moves {
40 
41 static basic::Tracer TR("protocols.moves.IteratedConvergenceMover");
42 
45 {
47 }
48 
51  return new IteratedConvergenceMover;
52 }
53 
56 {
57  return "IteratedConvergence";
58 }
59 
61  Mover("IteratedConvergenceMover"),
62  delta_(0.1),
63  cycles_(1),
64  maxcycles_(1000)
65 {}
66 
68  Mover("IteratedConvergenceMover"),
69  submover_(submover),
70  filter_(filter),
71  cycles_(cycles),
72  maxcycles_(maxcycles)
73 {
74  this->delta(delta);
75 }
76 
78 
80  //utility::pointer::ReferenceCount(),
81  Mover(other),
82  submover_(other.submover_),
83  filter_(other.filter_),
84  delta_(other.delta_),
85  cycles_(other.cycles_),
86  maxcycles_(other.maxcycles_)
87 {}
88 
89 void
91 {
92  runtime_assert(submover_);
93  runtime_assert(filter_);
94 
95  core::Real refval(filter_->report_sm(pose));
96  core::Size ncyc(0);
97  for( core::Size ii(1); ii <= maxcycles_; ++ii) {
98  submover_->apply(pose);
99  core::Real trialval(filter_->report_sm(pose));
100  if ( (trialval < refval - delta_) || ( trialval > refval + delta_ ) ) {
101  //Outside window, reset and continue
102  TR << "After "<<ii<<" applications, reseting reference to "<<trialval<<" which is "<<(trialval-refval)<<" away from previous reference."<<std::endl;
103  refval=trialval;
104  ncyc=0;
105  continue;
106  }
107  //within tolerance
108  ++ncyc;
109  if( ncyc >= cycles_) {
110  TR << "Exiting IteratedConvergence with convergence after "<<ii<<" applications of mover."<<std::endl;
111  return;
112  }
113  TR<<"After "<<ii<<" applications, at cycle "<<ncyc<<" of "<<cycles_<<", filter delta in range at "<<(trialval-refval)<<std::endl;
114  }
115  TR << "Exiting IteratedConvergence WITHOUT convergence after "<<maxcycles_<<" applications of mover."<<std::endl;
116 }
117 
121 }
122 
123 ///@brief parse XML (specifically in the context of the parser/scripting scheme)
124 void
126  TagPtr const tag,
127  DataMap &,
128  Filters_map const & filters,
129  Movers_map const & movers,
130  Pose const &
131 )
132 {
133  delta( tag->getOption< core::Real >( "delta", 0.1 ) );
134  cycles( tag->getOption< core::Size >( "cycles", 1 ) );
135  maxcycles( tag->getOption< core::Size >( "maxcycles", 1000 ) );
136 
137  std::string mover_name("");
138  std::string filter_name("");
139  if ( tag->hasOption("mover") ) mover_name = tag->getOption< std::string >( "mover" );
140  if ( tag->hasOption("mover_name") ) mover_name = tag->getOption< std::string >( "mover_name" );
141  if ( tag->hasOption("filter") ) filter_name = tag->getOption< std::string >( "filter" );
142  if ( tag->hasOption("filter_name") ) filter_name = tag->getOption< std::string >( "filter_name" );
143 
144  Movers_map::const_iterator find_mover ( movers.find( mover_name ));
145  Filters_map::const_iterator find_filter( filters.find( filter_name ));
146 
147  if( find_mover == movers.end() ) {
148  TR.Error << "ERROR !! mover not found in map: \n" << tag << std::endl;
149  runtime_assert( find_mover != movers.end() );
150  }
151  if( find_filter == filters.end() ) {
152  TR.Error << "ERROR !! filter not found in map: \n" << tag << std::endl;
153  runtime_assert( find_filter != filters.end() );
154  }
155  submover(find_mover->second);
156  filter(find_filter->second);
157 
158  TR << "Setting IteratedConvergence for "<<cycles()<<" cycles (max "<<maxcycles()<<") with mover '"<<mover_name<<"' and filter '"<<filter_name<<"' and delta tolerance "<<delta()<<std::endl;
159 }
160 
161 ///@brief required in the context of the parser/scripting scheme
162 MoverOP
164 {
165  return new IteratedConvergenceMover;
166 }
167 
168 ///@brief required in the context of the parser/scripting scheme
169 MoverOP
171 {
172  return new IteratedConvergenceMover( *this );
173 }
174 
175 // setters
177 {
178  runtime_assert( mover );
179  submover_ = mover;
180 }
181 
183 {
184  runtime_assert( filter );
185  filter_ = filter;
186 }
187 
189  if( delta < 0 ) {
190  utility_exit_with_message("Delta value given to IteratedConvergenceMover must be non-negative");
191  }
192  delta_ = delta;
193 }
194 
197 
198 // accessors
204 
205 } // moves
206 } // protocols
207