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