Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
GSLMinimizer.h
Go to the documentation of this file.
1 // @(#)root/mathmore:$Id$
2 // Author: L. Moneta Wed Oct 18 11:48:00 2006
3 
4  /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License *
10  * as published by the Free Software Foundation; either version 2 *
11  * of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this library (see file COPYING); if not, write *
20  * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21  * 330, Boston, MA 02111-1307 USA, or contact the author. *
22  * *
23  **********************************************************************/
24 
25 
26 // Header file for class GSLMinimizer
27 
28 #ifndef ROOT_Math_GSLMinimizer
29 #define ROOT_Math_GSLMinimizer
30 
31 #include "Math/Minimizer.h"
32 
33 
34 #include "Math/IFunctionfwd.h"
35 
36 #include "Math/IParamFunctionfwd.h"
37 
38 #include "Math/BasicMinimizer.h"
39 
40 
41 #include <vector>
42 #include <map>
43 #include <string>
44 
45 
46 
47 namespace ROOT {
48 
49 namespace Math {
50 
51 
52  /**
53  enumeration specifying the types of GSL minimizers
54  @ingroup MultiMin
55  */
56  enum EGSLMinimizerType {
57  kConjugateFR,
58  kConjugatePR,
59  kVectorBFGS,
60  kVectorBFGS2,
61  kSteepestDescent
62  };
63 
64 
65  class GSLMultiMinimizer;
66 
67  class MinimTransformFunction;
68 
69 
70 //_____________________________________________________________________________________
71 /**
72  GSLMinimizer class.
73  Implementation of the ROOT::Math::Minimizer interface using the GSL multi-dimensional
74  minimization algorithms.
75 
76  See <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Multidimensional-Minimization.html">GSL doc</A>
77  from more info on the GSL minimization algorithms.
78 
79  The class implements the ROOT::Math::Minimizer interface and can be instantiated using the
80  ROOT plugin manager (plugin name is "GSLMultiMin"). The varius minimization algorithms
81  (conjugatefr, conjugatepr, bfgs, etc..) can be passed as enumerations and also as a string.
82  The default algorithm is conjugatefr (Fletcher-Reeves conjugate gradient algorithm).
83 
84  @ingroup MultiMin
85 */
86 class GSLMinimizer : public ROOT::Math::BasicMinimizer {
87 
88 public:
89 
90  /**
91  Default constructor
92  */
93  GSLMinimizer (ROOT::Math::EGSLMinimizerType type = ROOT::Math::kConjugateFR );
94 
95  /**
96  Constructor with a string giving name of algorithm
97  */
98  GSLMinimizer (const char * type );
99 
100  /**
101  Destructor
102  */
103  virtual ~GSLMinimizer ();
104 
105 private:
106  // usually copying is non trivial, so we make this unaccessible
107 
108  /**
109  Copy constructor
110  */
111  GSLMinimizer(const GSLMinimizer &) : BasicMinimizer() {}
112 
113  /**
114  Assignment operator
115  */
116  GSLMinimizer & operator = (const GSLMinimizer & rhs) {
117  if (this == &rhs) return *this; // time saving self-test
118  return *this;
119  }
120 
121 public:
122 
123  /// set the function to minimize
124  virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func);
125 
126  /// set the function to minimize
127  virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func) { BasicMinimizer::SetFunction(func);}
128 
129  /// method to perform the minimization
130  virtual bool Minimize();
131 
132 
133  /// return expected distance reached from the minimum
134  virtual double Edm() const { return 0; } // not impl. }
135 
136 
137  /// return pointer to gradient values at the minimum
138  virtual const double * MinGradient() const;
139 
140  /// number of function calls to reach the minimum
141  virtual unsigned int NCalls() const;
142 
143 
144  /// minimizer provides error and error matrix
145  virtual bool ProvidesError() const { return false; }
146 
147  /// return errors at the minimum
148  virtual const double * Errors() const {
149  return 0;
150  }
151 
152  /** return covariance matrices elements
153  if the variable is fixed the matrix is zero
154  The ordering of the variables is the same as in errors
155  */
156  virtual double CovMatrix(unsigned int , unsigned int ) const { return 0; }
157 
158 
159 
160 
161 protected:
162 
163 private:
164 
165 
166  ROOT::Math::GSLMultiMinimizer * fGSLMultiMin;
167 
168  double fLSTolerance; // Line Search Tolerance
169 
170 };
171 
172  } // end namespace Fit
173 
174 } // end namespace ROOT
175 
176 
177 
178 #endif /* ROOT_Math_GSLMinimizer */