Logo ROOT  
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 */
32 class MinimizerOptions {
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
ROOT::Math::MinimizerOptions::fErrorDef
double fErrorDef
Definition: MinimizerOptions.h:167
ROOT::Math::MinimizerOptions::SetDefaultPrintLevel
static void SetDefaultPrintLevel(int level)
Definition: MinimizerOptions.cxx:82
ROOT::Math::MinimizerOptions::SetPrecision
void SetPrecision(double prec)
set the precision
Definition: MinimizerOptions.h:143
ROOT::Math::MinimizerOptions::SetDefaultMinimizer
static void SetDefaultMinimizer(const char *type, const char *algo=0)
Definition: MinimizerOptions.cxx:53
ROOT::Math::MinimizerOptions::SetMinimizerType
void SetMinimizerType(const char *type)
set minimizer type
Definition: MinimizerOptions.h:152
ROOT::Math::MinimizerOptions::Print
void Print(std::ostream &os=std::cout) const
print all the options
Definition: MinimizerOptions.cxx:211
ROOT::Math::MinimizerOptions::SetDefaultStrategy
static void SetDefaultStrategy(int strat)
Definition: MinimizerOptions.cxx:78
ROOT::Math::MinimizerOptions::SetDefaultExtraOptions
static void SetDefaultExtraOptions(const IOptions *extraoptions)
Definition: MinimizerOptions.cxx:86
ROOT::Math::MinimizerOptions::DefaultMaxFunctionCalls
static int DefaultMaxFunctionCalls()
Definition: MinimizerOptions.cxx:96
ROOT::Math::MinimizerOptions::fExtraOptions
ROOT::Math::IOptions * fExtraOptions
Definition: MinimizerOptions.h:174
ROOT::Math::MinimizerOptions::MinimizerAlgorithm
const std::string & MinimizerAlgorithm() const
type of algorithm
Definition: MinimizerOptions.h:122
ROOT::Math::MinimizerOptions::SetDefaultMaxIterations
static void SetDefaultMaxIterations(int maxiter)
Definition: MinimizerOptions.cxx:74
ROOT::Math::MinimizerOptions::fAlgoType
std::string fAlgoType
Definition: MinimizerOptions.h:171
ROOT::Math::MinimizerOptions::PrintDefault
static void PrintDefault(const char *name, std::ostream &os=std::cout)
print all the default options for the name given
Definition: MinimizerOptions.cxx:239
ROOT::Math::MinimizerOptions::MaxFunctionCalls
unsigned int MaxFunctionCalls() const
max number of function calls
Definition: MinimizerOptions.h:98
ROOT::Math::MinimizerOptions::SetPrintLevel
void SetPrintLevel(int level)
set print level
Definition: MinimizerOptions.h:131
ROOT::Math::MinimizerOptions::fTolerance
double fTolerance
Definition: MinimizerOptions.h:168
ROOT::Math::MinimizerOptions::Precision
double Precision() const
precision in the objective funciton calculation (value <=0 means left to default)
Definition: MinimizerOptions.h:110
ROOT::Math::MinimizerOptions::SetErrorDef
void SetErrorDef(double err)
set error def
Definition: MinimizerOptions.h:149
ROOT::Math::MinimizerOptions::FindDefault
static ROOT::Math::IOptions * FindDefault(const char *name)
Definition: MinimizerOptions.cxx:234
ROOT::Math::MinimizerOptions::ResetToDefaultOptions
void ResetToDefaultOptions()
non-static methods for setting options
Definition: MinimizerOptions.cxx:172
ROOT::Math::MinimizerOptions::SetMaxFunctionCalls
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
Definition: MinimizerOptions.h:134
ROOT::Math::MinimizerOptions::DefaultMinimizerType
static const std::string & DefaultMinimizerType()
Definition: MinimizerOptions.cxx:102
ROOT::Math::MinimizerOptions::SetMinimizerAlgorithm
void SetMinimizerAlgorithm(const char *type)
set minimizer algorithm
Definition: MinimizerOptions.h:155
ROOT::Math::MinimizerOptions::DefaultErrorDef
static double DefaultErrorDef()
Definition: MinimizerOptions.cxx:93
ROOT::Math::MinimizerOptions::SetMaxIterations
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
Definition: MinimizerOptions.h:137
ROOT::Math::MinimizerOptions
Minimizer options.
Definition: MinimizerOptions.h:42
ROOT::Math::MinimizerOptions::DefaultPrecision
static double DefaultPrecision()
Definition: MinimizerOptions.cxx:95
ROOT::Math::IOptions
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:41
ROOT::Math::MinimizerOptions::MinimizerOptions
MinimizerOptions()
Definition: MinimizerOptions.cxx:135
ROOT::Math::MinimizerOptions::MaxIterations
unsigned int MaxIterations() const
max iterations
Definition: MinimizerOptions.h:101
ROOT::Math::MinimizerOptions::SetTolerance
void SetTolerance(double tol)
set the tolerance
Definition: MinimizerOptions.h:140
ROOT::Math::MinimizerOptions::SetDefaultErrorDef
static void SetDefaultErrorDef(double up)
Definition: MinimizerOptions.cxx:58
ROOT::Math::MinimizerOptions::DefaultStrategy
static int DefaultStrategy()
Definition: MinimizerOptions.cxx:98
ROOT::Math::MinimizerOptions::fStrategy
int fStrategy
Definition: MinimizerOptions.h:166
ROOT::Math::MinimizerOptions::fMaxCalls
int fMaxCalls
Definition: MinimizerOptions.h:164
ROOT::Math::MinimizerOptions::DefaultMaxIterations
static int DefaultMaxIterations()
Definition: MinimizerOptions.cxx:97
ROOT::Math::MinimizerOptions::SetDefaultMaxFunctionCalls
static void SetDefaultMaxFunctionCalls(int maxcall)
Definition: MinimizerOptions.cxx:70
ROOT::Math::MinimizerOptions::ExtraOptions
const IOptions * ExtraOptions() const
return extra options (NULL pointer if they are not present)
Definition: MinimizerOptions.h:116
ROOT::Math::MinimizerOptions::DefaultTolerance
static double DefaultTolerance()
Definition: MinimizerOptions.cxx:94
ROOT::Math::MinimizerOptions::DefaultExtraOptions
static IOptions * DefaultExtraOptions()
Definition: MinimizerOptions.cxx:100
ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo
static const std::string & DefaultMinimizerAlgo()
Definition: MinimizerOptions.cxx:92
ROOT::Math::MinimizerOptions::Tolerance
double Tolerance() const
absolute tolerance
Definition: MinimizerOptions.h:107
ROOT::Math::MinimizerOptions::fMinimType
std::string fMinimType
Definition: MinimizerOptions.h:170
ROOT::Math::MinimizerOptions::SetStrategy
void SetStrategy(int stra)
set the strategy
Definition: MinimizerOptions.h:146
ROOT::Math::MinimizerOptions::DefaultPrintLevel
static int DefaultPrintLevel()
Definition: MinimizerOptions.cxx:99
ROOT::Math::MinimizerOptions::SetDefaultPrecision
static void SetDefaultPrecision(double prec)
Definition: MinimizerOptions.cxx:66
ROOT::Math::MinimizerOptions::MinimizerType
const std::string & MinimizerType() const
type of minimizer
Definition: MinimizerOptions.h:119
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Math::MinimizerOptions::fPrecision
double fPrecision
Definition: MinimizerOptions.h:169
ROOT::Math::MinimizerOptions::PrintLevel
int PrintLevel() const
non-static methods for retrieving options
Definition: MinimizerOptions.h:95
type
int type
Definition: TGX11.cxx:121
ROOT::Math::MinimizerOptions::Strategy
int Strategy() const
strategy
Definition: MinimizerOptions.h:104
ROOT::Math::MinimizerOptions::~MinimizerOptions
~MinimizerOptions()
Definition: MinimizerOptions.cxx:168
ROOT::Math::MinimizerOptions::operator=
MinimizerOptions & operator=(const MinimizerOptions &opt)
assignment operators
Definition: MinimizerOptions.cxx:149
ROOT::Math::MinimizerOptions::SetDefaultTolerance
static void SetDefaultTolerance(double tol)
Definition: MinimizerOptions.cxx:62
ROOT::Math::MinimizerOptions::ErrorDef
double ErrorDef() const
error definition
Definition: MinimizerOptions.h:113
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Math::MinimizerOptions::fMaxIter
int fMaxIter
Definition: MinimizerOptions.h:165
Math
ROOT::Math::MinimizerOptions::Default
static ROOT::Math::IOptions & Default(const char *name)
retrieve extra options - if not existing create a IOptions
Definition: MinimizerOptions.cxx:229
ROOT::Math::MinimizerOptions::SetExtraOptions
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
Definition: MinimizerOptions.cxx:205
ROOT::Math::MinimizerOptions::fLevel
int fLevel
Definition: MinimizerOptions.h:163