Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AtomTreeMinimizer.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 core/optimization/AtomTreeMinimizer.cc
11 /// @brief High-level atom tree minimizer class
12 /// @author Phil Bradley
13 
14 
15 // Unit headers
17 
18 // Package headers
25 
26 // Project headers
28 // AUTO-REMOVED #include <core/id/AtomID_Mask.hh>
29 // AUTO-REMOVED #include <core/id/AtomID_Map.Pose.hh>
30 #include <core/scoring/Energies.hh>
33 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
34 
35 
36 #include <basic/Tracer.hh>
37 
38 #include <ObjexxFCL/format.hh>
39 
40 #include <core/kinematics/Jump.hh>
41 #include <core/pose/Pose.hh>
42 #include <utility/vector1.hh>
43 
44 
45 using namespace ObjexxFCL::fmt;
46 
47 namespace core {
48 namespace optimization {
49 
50 AtomTreeMinimizer::AtomTreeMinimizer()
51 {}
52 
53 AtomTreeMinimizer::~AtomTreeMinimizer() {}
54 
55 ///////////////////////////////////////////////////////////////////////////////
56 Real
58  pose::Pose & pose,
59  kinematics::MoveMap const & move_map,
60  scoring::ScoreFunction const & scorefxn,
61  MinimizerOptions const & options
62 ) /*const*/
63 {
64  if ( options.deriv_check() ) {
65  deriv_check_result_ = new NumericalDerivCheckResult;
66  deriv_check_result_->send_to_stdout( options.deriv_check_to_stdout() );
67  }
68 
69  bool const use_nblist( options.use_nblist() );
70 
71  //fpd fail if this is called on a symmetric pose
72  runtime_assert( !core::pose::symmetry::is_symmetric( pose ) );
73 
74  // it's important that the structure be scored prior to nblist setup
75  Real const start_score( scorefxn( pose ) );
76 
77  //std::cout << "start_score:" << start_score << std::endl;
78  //pose.energies().show( std::cout );
79 
80  // setup the map of the degrees of freedom
81  MinimizerMap min_map;
82  min_map.setup( pose, move_map );
83 
84  // if we are using the nblist, set it up
85  if ( use_nblist ) {
86  // setup a mask of the moving dofs
87  pose.energies().set_use_nblist( pose, min_map.domain_map(), options.nblist_auto_update() );
88  }
89 
90  scorefxn.setup_for_minimizing( pose, min_map );
91 
92  // setup the function that we will pass to the low-level minimizer
93  AtomTreeMultifunc f( pose, min_map, scorefxn,
94  options.deriv_check(), options.deriv_check_verbose() );
95 
96  if ( deriv_check_result_ ) f.set_deriv_check_result( deriv_check_result_ );
97 
98  // starting position -- "dofs" = Degrees Of Freedom
99  Multivec dofs( min_map.nangles() );
100  min_map.copy_dofs_from_pose( pose, dofs );
101 
102  Real const start_func( f( dofs ) );
103 
104  //std::cout << "start_func: " << start_func << std::endl;
105  //pose.energies().show( std::cout );
106 
107  // now do the optimization with the low-level minimizer function
108  Minimizer minimizer( f, options );
109  minimizer.run( dofs );
110 
111  Real const end_func( f( dofs ) );
112 
113  //std::cout << "end_func: " << end_func << std::endl;
114  //pose.energies().show( std::cout );
115 
116  // turn off nblist
117  if ( use_nblist ) pose.energies().reset_nblist();
118 
119  // if we were doing rigid-body minimization, fold the rotation and
120  // translation offsets into the jump transforms
121  //
122  // also sets rb dofs to 0.0, so in principle func value should be the same
123  //
124  min_map.reset_jump_rb_deltas( pose, dofs );
125 
126  // rescore
127  Real const end_score( scorefxn( pose ) );
128 
129  //std::cout << "end_score:" << std::endl;
130  //pose.energies().show( std::cout );
131 
132  // we may not really need all these extra function evaluations
133  // good for diagnostics though
134 
135  static basic::Tracer core_optimize( "core.optimize", basic::t_debug);
136  core_optimize << "AtomTreeMinimizer::run: nangles= " << min_map.nangles() <<
137  " start_score: " << F(12,3,start_score) <<
138  " start_func: " << F(12,3,start_func ) <<
139  " end_score: " << F(12,3,end_score ) <<
140  " end_func: " << F(12,3,end_func ) << std::endl;
141 
142 
143  return end_score;
144 }
145 
147 AtomTreeMinimizer::deriv_check_result() const
148 {
149  return deriv_check_result_;
150 }
151 
152 } // namespace optimization
153 } // namespace core