// @(#)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
 MinimizerOptions.h:1
 MinimizerOptions.h:2
 MinimizerOptions.h:3
 MinimizerOptions.h:4
 MinimizerOptions.h:5
 MinimizerOptions.h:6
 MinimizerOptions.h:7
 MinimizerOptions.h:8
 MinimizerOptions.h:9
 MinimizerOptions.h:10
 MinimizerOptions.h:11
 MinimizerOptions.h:12
 MinimizerOptions.h:13
 MinimizerOptions.h:14
 MinimizerOptions.h:15
 MinimizerOptions.h:16
 MinimizerOptions.h:17
 MinimizerOptions.h:18
 MinimizerOptions.h:19
 MinimizerOptions.h:20
 MinimizerOptions.h:21
 MinimizerOptions.h:22
 MinimizerOptions.h:23
 MinimizerOptions.h:24
 MinimizerOptions.h:25
 MinimizerOptions.h:26
 MinimizerOptions.h:27
 MinimizerOptions.h:28
 MinimizerOptions.h:29
 MinimizerOptions.h:30
 MinimizerOptions.h:31
 MinimizerOptions.h:32
 MinimizerOptions.h:33
 MinimizerOptions.h:34
 MinimizerOptions.h:35
 MinimizerOptions.h:36
 MinimizerOptions.h:37
 MinimizerOptions.h:38
 MinimizerOptions.h:39
 MinimizerOptions.h:40
 MinimizerOptions.h:41
 MinimizerOptions.h:42
 MinimizerOptions.h:43
 MinimizerOptions.h:44
 MinimizerOptions.h:45
 MinimizerOptions.h:46
 MinimizerOptions.h:47
 MinimizerOptions.h:48
 MinimizerOptions.h:49
 MinimizerOptions.h:50
 MinimizerOptions.h:51
 MinimizerOptions.h:52
 MinimizerOptions.h:53
 MinimizerOptions.h:54
 MinimizerOptions.h:55
 MinimizerOptions.h:56
 MinimizerOptions.h:57
 MinimizerOptions.h:58
 MinimizerOptions.h:59
 MinimizerOptions.h:60
 MinimizerOptions.h:61
 MinimizerOptions.h:62
 MinimizerOptions.h:63
 MinimizerOptions.h:64
 MinimizerOptions.h:65
 MinimizerOptions.h:66
 MinimizerOptions.h:67
 MinimizerOptions.h:68
 MinimizerOptions.h:69
 MinimizerOptions.h:70
 MinimizerOptions.h:71
 MinimizerOptions.h:72
 MinimizerOptions.h:73
 MinimizerOptions.h:74
 MinimizerOptions.h:75
 MinimizerOptions.h:76
 MinimizerOptions.h:77
 MinimizerOptions.h:78
 MinimizerOptions.h:79
 MinimizerOptions.h:80
 MinimizerOptions.h:81
 MinimizerOptions.h:82
 MinimizerOptions.h:83
 MinimizerOptions.h:84
 MinimizerOptions.h:85
 MinimizerOptions.h:86
 MinimizerOptions.h:87
 MinimizerOptions.h:88
 MinimizerOptions.h:89
 MinimizerOptions.h:90
 MinimizerOptions.h:91
 MinimizerOptions.h:92
 MinimizerOptions.h:93
 MinimizerOptions.h:94
 MinimizerOptions.h:95
 MinimizerOptions.h:96
 MinimizerOptions.h:97
 MinimizerOptions.h:98
 MinimizerOptions.h:99
 MinimizerOptions.h:100
 MinimizerOptions.h:101
 MinimizerOptions.h:102
 MinimizerOptions.h:103
 MinimizerOptions.h:104
 MinimizerOptions.h:105
 MinimizerOptions.h:106
 MinimizerOptions.h:107
 MinimizerOptions.h:108
 MinimizerOptions.h:109
 MinimizerOptions.h:110
 MinimizerOptions.h:111
 MinimizerOptions.h:112
 MinimizerOptions.h:113
 MinimizerOptions.h:114
 MinimizerOptions.h:115
 MinimizerOptions.h:116
 MinimizerOptions.h:117
 MinimizerOptions.h:118
 MinimizerOptions.h:119
 MinimizerOptions.h:120
 MinimizerOptions.h:121
 MinimizerOptions.h:122
 MinimizerOptions.h:123
 MinimizerOptions.h:124
 MinimizerOptions.h:125
 MinimizerOptions.h:126
 MinimizerOptions.h:127
 MinimizerOptions.h:128
 MinimizerOptions.h:129
 MinimizerOptions.h:130
 MinimizerOptions.h:131
 MinimizerOptions.h:132
 MinimizerOptions.h:133
 MinimizerOptions.h:134
 MinimizerOptions.h:135
 MinimizerOptions.h:136
 MinimizerOptions.h:137
 MinimizerOptions.h:138
 MinimizerOptions.h:139
 MinimizerOptions.h:140
 MinimizerOptions.h:141
 MinimizerOptions.h:142
 MinimizerOptions.h:143
 MinimizerOptions.h:144
 MinimizerOptions.h:145
 MinimizerOptions.h:146
 MinimizerOptions.h:147
 MinimizerOptions.h:148
 MinimizerOptions.h:149
 MinimizerOptions.h:150
 MinimizerOptions.h:151
 MinimizerOptions.h:152
 MinimizerOptions.h:153
 MinimizerOptions.h:154
 MinimizerOptions.h:155
 MinimizerOptions.h:156
 MinimizerOptions.h:157
 MinimizerOptions.h:158
 MinimizerOptions.h:159
 MinimizerOptions.h:160
 MinimizerOptions.h:161
 MinimizerOptions.h:162
 MinimizerOptions.h:163
 MinimizerOptions.h:164
 MinimizerOptions.h:165
 MinimizerOptions.h:166
 MinimizerOptions.h:167
 MinimizerOptions.h:168
 MinimizerOptions.h:169
 MinimizerOptions.h:170
 MinimizerOptions.h:171
 MinimizerOptions.h:172