Logo ROOT   6.10/09
Reference Guide
MinimizerOptions.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: L. Moneta Fri Aug 15 2008
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2008 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 #ifndef ROOT_Math_MinimizerOptions
12 #define ROOT_Math_MinimizerOptions
13 
14 #include <string>
15 
16 #include <iostream>
17 
18 namespace ROOT {
19 
20 
21 namespace Math {
22 
23 
24 class IOptions;
25 
26 //_______________________________________________________________________________
27 /**
28  Minimizer options
29 
30  @ingroup MultiMin
31 */
33 
34 public:
35 
36  // static methods for setting and retrieving the default options
37 
38  static void SetDefaultMinimizer(const char * type, const char * algo = 0);
39  static void SetDefaultErrorDef( double up);
40  static void SetDefaultTolerance(double tol);
41  static void SetDefaultPrecision(double prec);
42  static void SetDefaultMaxFunctionCalls(int maxcall);
43  static void SetDefaultMaxIterations(int maxiter);
44  static void SetDefaultStrategy(int strat);
45  static void SetDefaultPrintLevel(int level);
46  static void SetDefaultExtraOptions(const IOptions * extraoptions);
47 
48  static const std::string & DefaultMinimizerType();
49  static const std::string & DefaultMinimizerAlgo();
50  static double DefaultErrorDef();
51  static double DefaultTolerance();
52  static double DefaultPrecision();
53  static int DefaultMaxFunctionCalls();
54  static int DefaultMaxIterations();
55  static int DefaultStrategy();
56  static int DefaultPrintLevel();
57  static IOptions * DefaultExtraOptions();
58 
59  /// retrieve extra options - if not existing create a IOptions
60  static ROOT::Math::IOptions & Default(const char * name);
61 
62  // find extra options - return 0 if not existing
63  static ROOT::Math::IOptions * FindDefault(const char * name);
64 
65  /// print all the default options for the name given
66  static void PrintDefault(const char * name, std::ostream & os = std::cout);
67 
68 public:
69 
70  // constructor using the default options
72 
73  // destructor
75 
76  // copy constructor
78 
79  /// assignment operators
81 
82  /** non-static methods for retrieving options */
83 
84  /// set print level
85  int PrintLevel() const { return fLevel; }
86 
87  /// max number of function calls
88  unsigned int MaxFunctionCalls() const { return fMaxCalls; }
89 
90  /// max iterations
91  unsigned int MaxIterations() const { return fMaxIter; }
92 
93  /// strategy
94  int Strategy() const { return fStrategy; }
95 
96  /// absolute tolerance
97  double Tolerance() const { return fTolerance; }
98 
99  /// precision in the objective funciton calculation (value <=0 means left to default)
100  double Precision() const { return fPrecision; }
101 
102  /// error definition
103  double ErrorDef() const { return fErrorDef; }
104 
105  /// return extra options (NULL pointer if they are not present)
106  const IOptions * ExtraOptions() const { return fExtraOptions; }
107 
108  /// type of minimizer
109  const std::string & MinimizerType() const { return fMinimType; }
110 
111  /// type of algorithm
112  const std::string & MinimizerAlgorithm() const { return fAlgoType; }
113 
114  /// print all the options
115  void Print(std::ostream & os = std::cout) const;
116 
117  /** non-static methods for setting options */
118  void ResetToDefaultOptions();
119 
120  /// set print level
121  void SetPrintLevel(int level) { fLevel = level; }
122 
123  ///set maximum of function calls
124  void SetMaxFunctionCalls(unsigned int maxfcn) { fMaxCalls = maxfcn; }
125 
126  /// set maximum iterations (one iteration can have many function calls)
127  void SetMaxIterations(unsigned int maxiter) { fMaxIter = maxiter; }
128 
129  /// set the tolerance
130  void SetTolerance(double tol) { fTolerance = tol; }
131 
132  /// set the precision
133  void SetPrecision(double prec) { fPrecision = prec; }
134 
135  /// set the strategy
136  void SetStrategy(int stra) { fStrategy = stra; }
137 
138  /// set error def
139  void SetErrorDef(double err) { fErrorDef = err; }
140 
141  /// set minimizer type
142  void SetMinimizerType(const char * type) { fMinimType = type; }
143 
144  /// set minimizer algorithm
145  void SetMinimizerAlgorithm(const char *type) { fAlgoType = type; }
146 
147  /// set extra options (in this case pointer is cloned)
148  void SetExtraOptions(const IOptions & opt);
149 
150 
151 private:
152 
153  int fLevel; // debug print level
154  int fMaxCalls; // maximum number of function calls
155  int fMaxIter; // maximum number of iterations
156  int fStrategy; // minimizer strategy (used by Minuit)
157  double fErrorDef; // error definition (=1. for getting 1 sigma error for chi2 fits)
158  double fTolerance; // minimize tolerance to reach solution
159  double fPrecision; // precision of the objective function evaluation (value <=0 means left to default)
160  std::string fMinimType; // Minimizer type (Minuit, Minuit2, etc..
161  std::string fAlgoType; // Minimizer algorithmic specification (Migrad, Minimize, ...)
162 
163  // extra options
165 
166 };
167 
168  } // end namespace Math
169 
170 } // end namespace ROOT
171 
172 #endif
unsigned int MaxFunctionCalls() const
max number of function calls
const std::string & MinimizerAlgorithm() const
type of algorithm
void SetPrintLevel(int level)
set print level
void SetTolerance(double tol)
set the tolerance
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
void SetMinimizerType(const char *type)
set minimizer type
void Print(std::ostream &os=std::cout) const
print all the options
static IOptions * DefaultExtraOptions()
const IOptions * ExtraOptions() const
return extra options (NULL pointer if they are not present)
static void SetDefaultExtraOptions(const IOptions *extraoptions)
void SetErrorDef(double err)
set error def
static void SetDefaultMaxIterations(int maxiter)
unsigned int MaxIterations() const
max iterations
const std::string & MinimizerType() const
type of minimizer
static ROOT::Math::IOptions & Default(const char *name)
retrieve extra options - if not existing create a IOptions
void ResetToDefaultOptions()
non-static methods for setting options
static void SetDefaultPrintLevel(int level)
void SetPrecision(double prec)
set the precision
MinimizerOptions & operator=(const MinimizerOptions &opt)
assignment operators
int PrintLevel() const
non-static methods for retrieving options
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
static void SetDefaultErrorDef(double up)
int Strategy() const
strategy
double Precision() const
precision in the objective funciton calculation (value <=0 means left to default) ...
static void SetDefaultStrategy(int strat)
static void SetDefaultMaxFunctionCalls(int maxcall)
const double tol
static ROOT::Math::IOptions * FindDefault(const char *name)
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
static const std::string & DefaultMinimizerType()
static void PrintDefault(const char *name, std::ostream &os=std::cout)
print all the default options for the name given
ROOT::Math::IOptions * fExtraOptions
static const std::string & DefaultMinimizerAlgo()
double Tolerance() const
absolute tolerance
static void SetDefaultTolerance(double tol)
int type
Definition: TGX11.cxx:120
static void SetDefaultPrecision(double prec)
Namespace for new Math classes and functions.
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:30
void SetStrategy(int stra)
set the strategy
double ErrorDef() const
error definition
static void SetDefaultMinimizer(const char *type, const char *algo=0)
void SetMinimizerAlgorithm(const char *type)
set minimizer algorithm