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, which 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 ~GSLMinimizer1D() override;
95
96 // usually copying is non trivial, so we delete this
97 GSLMinimizer1D(const GSLMinimizer1D &) = delete;
101
102
103 /**
104 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.
105 The condition : \f$ f(xlow) > f(xmin) < f(xup)\f$ must be satisfied
106 */
107 template <class UserFunc>
108 void SetFunction( const UserFunc & f, double xmin, double xlow, double xup) {
109 const void * p = &f;
110 SetFunction( &GSLFunctionAdapter<UserFunc>::F, const_cast<void *>(p), xmin, xlow, xup );
111 }
112
113 /**
114 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.
115 The condition : \f$ f(xlow) > f(xmin) < f(xup) \f$ must be satisfied
116
117 Method specialized on the GSL function type
118 */
119 void SetFunction( GSLFuncPointer f, void * params, double xmin, double xlow, double xup);
120
121 /**
122 Perform a minimizer iteration and
123 if an unexpected problem occurs then an error code will be returned
124 */
125 int Iterate();
126
127
128 /**
129 Return current estimate of the position of the minimum
130 */
131 double XMinimum() const override;
132
133 /**
134 Return current lower bound of the minimization interval
135 */
136 double XLower() const override;
137
138 /**
139 Return current upper bound of the minimization interval
140 */
141 double XUpper() const override;
142
143 /**
144 Return function value at current estimate of the minimum
145 */
146 double FValMinimum() const override;
147
148 /**
149 Return function value at current lower bound of the minimization interval
150 */
151 double FValLower() const override;
152
153 /**
154 Return function value at current upper bound of the minimization interval
155 */
156 double FValUpper() const override;
157
158
159 /**
160 Find minimum position iterating until convergence specified by the absolute and relative tolerance or
161 the maximum number of iteration is reached
162 Return true is result is successful
163 \@param maxIter maximum number of iteration
164 \@param absTol desired absolute error in the minimum position
165 \@param absTol desired relative error in the minimum position
166 */
167 bool Minimize( int maxIter, double absTol, double relTol) override;
168
169
170 /**
171 Return number of iteration used to find minimum
172 */
173 int Iterations() const override {
174 return fIter;
175 }
176
177 /**
178 Return status of last minimization
179 */
180 int Status() const override { return fStatus; }
181
182 /**
183 Return name of minimization algorithm
184 */
185 const char * Name() const override;
186
187 /**
188 Test convergence of the interval.
189 The test returns success if
190 \f[
191 |x_{min}-x_{truemin}| < epsAbs + epsRel *x_{truemin}
192 \f]
193 */
194 static int TestInterval( double xlow, double xup, double epsAbs, double epsRel);
195
196
197 protected:
198
199
200 private:
201
202 double fXmin;
203 double fXlow;
204 double fXup;
205 double fMin;
206 double fLow;
207 double fUp;
208 int fIter;
209 int fStatus; // status of last minimization (==0 ok =1 failed)
210 bool fIsSet;
211
212
215
216 };
217
218} // end namespace Math
219
220} // end namespace ROOT
221
222
223#endif /* ROOT_Math_GSLMinimizer1D */
#define f(i)
Definition RSha256.hxx:104
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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 FValMinimum() const override
Return function value at current estimate of the minimum.
const char * Name() const override
Return name of minimization algorithm.
GSLMinimizer1D(GSLMinimizer1D &&)=delete
GSLMinimizer1D(const GSLMinimizer1D &)=delete
int Status() const override
Return status of last minimization.
int Iterate()
Perform a minimizer iteration and if an unexpected problem occurs then an error code will be returned...
GSL1DMinimizerWrapper * fMinimizer
double XLower() const override
Return current lower bound of the minimization interval.
static int TestInterval(double xlow, double xup, double epsAbs, double epsRel)
Test convergence of the interval.
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,...
int Iterations() const override
Return number of iteration used to find minimum.
double XUpper() const override
Return current upper bound of the minimization interval.
GSLMinimizer1D & operator=(const GSLMinimizer1D &)=delete
double FValUpper() const override
Return function value at current upper bound of the minimization interval.
~GSLMinimizer1D() override
Destructor: free allocated resources.
double FValLower() const override
Return function value at current lower bound of the minimization interval.
GSLFunctionWrapper * fFunction
double XMinimum() const override
Return current estimate of the position of the minimum.
bool Minimize(int maxIter, double absTol, double relTol) override
Find minimum position iterating until convergence specified by the absolute and relative tolerance or...
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...