Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
GSLMinimizer1D.h
Go to the documentation of this file.
1// @(#)root/mathmore:$Id$
2// Author: L. Moneta, A. Zsenei 08/2005
3 /**********************************************************************
4 * *
5 * Copyright (c) 2004 moneta, CERN/PH-SFT *
6 * *
7 * This library is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU General Public License *
9 * as published by the Free Software Foundation; either version 2 *
10 * of the License, or (at your option) any later version. *
11 * *
12 * This library is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 * General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this library (see file COPYING); if not, write *
19 * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
20 * 330, Boston, MA 02111-1307 USA, or contact the author. *
21 * *
22 **********************************************************************/
23
24// Header file for class GSLMinimizer1D
25//
26// Created by: moneta at Wed Dec 1 15:04:51 2004
27//
28// Last update: Wed Dec 1 15:04:51 2004
29//
30
31#ifndef ROOT_Math_GSLMinimizer1D
32#define ROOT_Math_GSLMinimizer1D
33
34#include "Math/IMinimizer1D.h"
36
37
38namespace ROOT {
39namespace Math {
40
41 namespace Minim1D {
42
43 /**
44 Enumeration with One Dimensional Minimizer Algorithms.
45 The algorithms are implemented using GSL, see the
46 <A HREF="http://www.gnu.org/software/gsl/manual/gsl-ref_33.html#SEC447">GSL manual</A>.
47
48 The algorithms available are:
49 <ul>
50 <li><em>Golden Section Algorithm</em>, simplest method of bracketing the minimum of a function
51 <li><em>Brent Algorithm</em>, which combines a parabolic interpolation with the golden section algorithm
52 </ul>
53 @ingroup Min1D
54 */
55
57 kBRENT
58 };
59 }
60
61 class GSL1DMinimizerWrapper;
62 class GSLFunctionWrapper;
63
64//______________________________________________________________________________________
65/**
66
67Minimizer for arbitrary one dimensional functions.
68
69Implemented using GSL, for detailed description see:
70<A HREF="http://www.gnu.org/software/gsl/manual/html_node/One-dimensional-Minimization.html">GSL online doc</A>
71
72The algorithms uspported are only bracketing algorithm which do not use derivatives information.
73The algorithms which can be chosen at construction time are GOLDENSECTION, whic is the simplest method
74but the slowest and BRENT (the default one) which combines the golden section with a parabolic interpolation.
75
76
77This class does not support copying
78@ingroup Min1D
79*/
80
82
83 public:
84
85 /**
86 Construct the minimizer passing the minimizer type using the Minim1D::Algorithm enumeration
87 */
88
90
91 /**
92 Destructor: free allocated resources
93 */
94 virtual ~GSLMinimizer1D();
95
96 private:
97 // usually copying is non trivial, so we make this unaccessible
100
101 public:
102
103
104 /**
105 Set, or reset, minimizer to use the function f and the initial search interval [xlow, xup], with a guess for the location of the minimum xmin.
106 The condition : \f$ f(xlow) > f(xmin) < f(xup)\f$ must be satisfied
107 */
108 template <class UserFunc>
109 void SetFunction( const UserFunc & f, double xmin, double xlow, double xup) {
110 const void * p = &f;
111 SetFunction( &GSLFunctionAdapter<UserFunc>::F, const_cast<void *>(p), xmin, xlow, xup );
112 }
113
114 /**
115 Set, or reset, minimizer to use the function f and the initial search interval [xlow, xup], with a guess for the location of the minimum xmin.
116 The condition : \f$ f(xlow) > f(xmin) < f(xup) \f$ must be satisfied
117
118 Method specialized on the GSL function type
119 */
120 void SetFunction( GSLFuncPointer f, void * params, double xmin, double xlow, double xup);
121
122 /**
123 Perform a minimizer iteration and
124 if an unexepcted problem occurr then an error code will be returned
125 */
126 int Iterate();
127
128
129 /**
130 Return current estimate of the position of the minimum
131 */
132 double XMinimum() const;
133
134 /**
135 Return current lower bound of the minimization interval
136 */
137 double XLower() const;
138
139 /**
140 Return current upper bound of the minimization interval
141 */
142 double XUpper() const;
143
144 /**
145 Return function value at current estimate of the minimum
146 */
147 double FValMinimum() const;
148
149 /**
150 Return function value at current lower bound of the minimization interval
151 */
152 double FValLower() const;
153
154 /**
155 Return function value at current upper bound of the minimization interval
156 */
157 double FValUpper() const;
158
159
160 /**
161 Find minimum position iterating until convergence specified by the absolute and relative tolerance or
162 the maximum number of iteration is reached
163 Return true is result is successfull
164 \@param maxIter maximum number of iteration
165 \@param absTol desired absolute error in the minimum position
166 \@param absTol desired relative error in the minimum position
167 */
168 bool Minimize( int maxIter, double absTol, double relTol);
169
170
171 /**
172 Return number of iteration used to find minimum
173 */
174 int Iterations() const {
175 return fIter;
176 }
177
178 /**
179 Return status of last minimization
180 */
181 int Status() const { return fStatus; }
182
183 /**
184 Return name of minimization algorithm
185 */
186 const char * Name() const;
187
188 /**
189 Test convergence of the interval.
190 The test returns success if
191 \f[
192 |x_{min}-x_{truemin}| < epsAbs + epsRel *x_{truemin}
193 \f]
194 */
195 static int TestInterval( double xlow, double xup, double epsAbs, double epsRel);
196
197
198 protected:
199
200
201 private:
202
203 double fXmin;
204 double fXlow;
205 double fXup;
206 double fMin;
207 double fLow;
208 double fUp;
209 int fIter;
210 int fStatus; // status of last minimization (==0 ok =1 failed)
211 bool fIsSet;
212
213
216
217 };
218
219} // end namespace Math
220
221} // end namespace ROOT
222
223
224#endif /* ROOT_Math_GSLMinimizer1D */
#define f(i)
Definition RSha256.hxx:104
int type
Definition TGX11.cxx:121
float xmin
wrapper class for gsl_min_fminimizer structure
Class for adapting any C++ functor class to C function pointers used by GSL.
Wrapper class to the gsl_function C structure.
Minimizer for arbitrary one dimensional functions.
double XLower() const
Return current lower bound of the minimization interval.
double XUpper() const
Return current upper bound of the minimization interval.
GSLMinimizer1D & operator=(const GSLMinimizer1D &)
const char * Name() const
Return name of minimization algorithm.
double XMinimum() const
Return current estimate of the position of the minimum.
bool Minimize(int maxIter, double absTol, double relTol)
Find minimum position iterating until convergence specified by the absolute and relative tolerance or...
int Iterate()
Perform a minimizer iteration and if an unexepcted problem occurr then an error code will be returned...
GSL1DMinimizerWrapper * fMinimizer
static int TestInterval(double xlow, double xup, double epsAbs, double epsRel)
Test convergence of the interval.
int Status() const
Return status of last minimization.
void SetFunction(const UserFunc &f, double xmin, double xlow, double xup)
Set, or reset, minimizer to use the function f and the initial search interval [xlow,...
double FValMinimum() const
Return function value at current estimate of the minimum.
virtual ~GSLMinimizer1D()
Destructor: free allocated resources.
int Iterations() const
Return number of iteration used to find minimum.
double FValLower() const
Return function value at current lower bound of the minimization interval.
GSLFunctionWrapper * fFunction
double FValUpper() const
Return function value at current upper bound of the minimization interval.
Interface class for numerical methods for one-dimensional minimization.
Type
Enumeration with One Dimensional Minimizer Algorithms.
Namespace for new Math classes and functions.
double(* GSLFuncPointer)(double, void *)
Function pointer corresponding to gsl_function signature.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...