Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CartesianMinimizer.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/CartesianMinimizer.cc
11 /// @brief High-level Cartesian minimizer class
12 /// @author Frank DiMaio
13 
14 
15 // Unit headers
17 
18 // Package headers
22 // AUTO-REMOVED #include <core/optimization/MinimizerMap.hh>
25 
26 // Project headers
28 #include <core/scoring/Energies.hh>
30 // AUTO-REMOVED #include <core/pose/symmetry/util.hh>
31 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
32 
33 
34 #include <basic/Tracer.hh>
35 
36 #include <ObjexxFCL/format.hh>
37 
38 #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 CartesianMinimizer::CartesianMinimizer()
51 {}
52 
53 CartesianMinimizer::~CartesianMinimizer() {}
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 this works with symm!
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  // setup the map of the degrees of freedom
78  CartesianMinimizerMap min_map;
79  min_map.setup( pose, move_map );
80 
81  // if we are using the nblist, set it up
82  if ( use_nblist ) {
83  // setup a mask of the moving dofs
84  pose.energies().set_use_nblist( pose, min_map.domain_map(), options.nblist_auto_update() );
85  }
86 
87  scorefxn.setup_for_minimizing( pose, min_map );
88 
89  // setup the function that we will pass to the low-level minimizer
90  CartesianMultifunc f( pose, min_map, scorefxn,
91  options.deriv_check(), options.deriv_check_verbose() );
92 
93  if ( deriv_check_result_ ) f.set_deriv_check_result( deriv_check_result_ );
94 
95  // starting position -- "dofs" = Degrees Of Freedom
96  Multivec dofs( min_map.ndofs() );
97  min_map.copy_dofs_from_pose( pose, dofs );
98 
99  Real const start_func( f( dofs ) );
100 
101  // now do the optimization with the low-level minimizer function
102  Minimizer minimizer( f, options );
103  minimizer.run( dofs );
104 
105  Real const end_func( f( dofs ) );
106 
107  // turn off nblist
108  if ( use_nblist ) pose.energies().reset_nblist();
109 
110  // rescore
111  Real const end_score( scorefxn( pose ) );
112 
113  // we may not really need all these extra function evaluations
114  // good for diagnostics though
115  static basic::Tracer core_optimize( "core.optimize", basic::t_debug);
116  core_optimize << "CartesianMinimizer::run: ndofs= " << min_map.ndofs() <<
117  " start_score: " << F(12,3,start_score) <<
118  " start_func: " << F(12,3,start_func ) <<
119  " end_score: " << F(12,3,end_score ) <<
120  " end_func: " << F(12,3,end_func ) << std::endl;
121 
122  return end_score;
123 }
124 
126 CartesianMinimizer::deriv_check_result() const
127 {
128  return deriv_check_result_;
129 }
130 
131 } // namespace optimization
132 } // namespace core