Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Minimizer.hh
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/Minimizer.hh
11 /// @brief Simple low-level minimizer class
12 /// @author Phil Bradley
13 
14 
15 #ifndef INCLUDED_core_optimization_Minimizer_hh
16 #define INCLUDED_core_optimization_Minimizer_hh
17 
18 // Package headers
21 // AUTO-REMOVED #include <core/optimization/Multifunc.hh>
22 // AUTO-REMOVED #include <core/optimization/LineMinimizer.hh>
23 
26 #include <utility/vector1.hh>
27 
28 
29 
30 namespace core {
31 namespace optimization {
32 
33 
34 /**************************************************
35  *
36  * Rough outline of how to structure this:
37  *
38  * Make a base 'minimizer' class
39  *
40  * Sub-class into univariate and multivariate minimizers
41  * -> actually, could we treat linmin as an instance of multivariate
42  * minimization, with a single pass of steepest descent
43  *
44  * The trick is how to mix and match convergence criteria, descent
45  * direction generation, and line minimization schemes
46  *
47  * convergence criteria could be a function or a functor. Descent
48  * direction algorithms probably need to be functors, since they
49  * have different storage needs.
50  *
51  *
52  *
53  **********************************************/
54 
55 //**************************************
56 //*** Begin convergence test section ***
57 //**************************************
58 
59 // base convergence test class
61 public:
62  virtual bool operator()( Real Fnew, Real Fold ) = 0;
63  virtual ~ConvergenceTest() {}
64 };
65 
66 // concrete convergence test class - classic dfpmin
68 public:
69  DFPMinConvergedFractional( Real _tol, Real _eps = 1.0e-10 ) : tolerance( _tol ), eps( _eps ) {};
71  virtual bool operator()( Real Fnew, Real Fold );
72 private:
75 };
76 
77 // concrete convergence test class - "atol" dfpmin
79 public:
80  DFPMinConvergedAbsolute( Real _tol ) : tolerance( _tol ) {}
82  virtual bool operator()( Real Fnew, Real Fold );
83 private:
85 };
86 
87 //**************************************
88 //*** End convergence test section ***
89 //**************************************
90 
91 //***************************************
92 //*** Begin descent direction section ***
93 //***************************************
94 
95 // base convergence test class
97 public:
98  DescentDirectionAlgorithm( Multifunc const & in_func_ ): func_( in_func_ ) {}
99 // Multivec operator()(){};
100  void initialize(){};
101 private:
102  Multifunc const & func_;
103 };
104 
105 //********************************************
106 //*** Begin multivariate minimizer section ***
107 //********************************************
108 
110 public:
112  Multifunc const & score_fxn,
113  LineMinimizationAlgorithm & line_min_alg,
114  ConvergenceTest & converge_test,
115  DescentDirectionAlgorithm & desc_dir ):
116  _func( score_fxn ), _line_min( line_min_alg ),
117  _converged( converge_test ), _get_direction( desc_dir ){}
118  Real run( Multivec & angles );
119 private:
120  Multifunc const & _func;
124 };
125 
126 //********************************************
127 //*** End multivariate minimizer section ***
128 //********************************************
129 
130 //
131 // Data stored at each LBFGS iteration
133 public:
137  core::Real ys; // = dot(y,s)
138 };
139 
140 
141 /// @brief Simple low-level minimizer class
142 class Minimizer {
143 
144 public:
145  Minimizer( Multifunc & func_in, MinimizerOptions const & options_in );
146 
147  Real
148  run( Multivec & phipsi_inout );
149 
150 private:
151  void
152  linmin(
153  Multivec & P,
154  Multivec & XI,
155  Real & FRET,
156  int const ITMAX
157  ) const;
158 
159  void
160  dfpmin(
161  Multivec & P,
162  Real & FRET,
163  ConvergenceTest & converge_test,
164  int const ITMAX
165  ) const;
166 
167  void
169  Multivec & P,
170  Real & FRET,
171  ConvergenceTest & converge_test,
173  int const ITMAX
174  ) const;
175 
176  void
177  lbfgs(
178  Multivec & P,
179  Real & FRET,
180  ConvergenceTest & converge_test,
182  int const ITMAX
183  ) const;
184 
187 }; // Minimizer
188 
189 } // namespace optimization
190 } // namespace core
191 
192 
193 #endif // INCLUDED_core_optimization_Minimizer_HH