Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:31:46

0001 // @(#)root/minuit2:$Id$
0002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
0007  *                                                                    *
0008  **********************************************************************/
0009 
0010 #ifndef ROOT_Minuit2_MnStrategy
0011 #define ROOT_Minuit2_MnStrategy
0012 
0013 namespace ROOT {
0014 
0015 namespace Minuit2 {
0016 
0017 //_________________________________________________________________________
0018 /**
0019     API class for defining four levels of strategies: low (0), medium (1),
0020     high (2), very high (>=3);
0021     acts on: Migrad (behavioural),
0022              Minos (lowers strategy by 1 for Minos-own minimization),
0023              Hesse (iterations),
0024              Numerical2PDerivative (iterations)
0025  */
0026 
0027 class MnStrategy {
0028 
0029 public:
0030    // default strategy
0031    MnStrategy();
0032 
0033    // user defined strategy (0, 1, 2, >=3)
0034    explicit MnStrategy(unsigned int);
0035 
0036    unsigned int Strategy() const { return fStrategy; }
0037 
0038    unsigned int GradientNCycles() const { return fGradNCyc; }
0039    double GradientStepTolerance() const { return fGradTlrStp; }
0040    double GradientTolerance() const { return fGradTlr; }
0041 
0042    unsigned int HessianNCycles() const { return fHessNCyc; }
0043    double HessianStepTolerance() const { return fHessTlrStp; }
0044    double HessianG2Tolerance() const { return fHessTlrG2; }
0045    unsigned int HessianGradientNCycles() const { return fHessGradNCyc; }
0046    unsigned int HessianCentralFDMixedDerivatives() const { return fHessCFDG2; }
0047    unsigned int HessianForcePosDef() const { return fHessForcePosDef; }
0048 
0049    int StorageLevel() const { return fStoreLevel; }
0050 
0051    bool IsLow() const { return fStrategy == 0; }
0052    bool IsMedium() const { return fStrategy == 1; }
0053    bool IsHigh() const { return fStrategy == 2; }
0054    bool IsVeryHigh() const { return fStrategy >= 3; }
0055 
0056    void SetLowStrategy();
0057    void SetMediumStrategy();
0058    void SetHighStrategy();
0059    void SetVeryHighStrategy();
0060 
0061    void SetGradientNCycles(unsigned int n) { fGradNCyc = n; }
0062    void SetGradientStepTolerance(double stp) { fGradTlrStp = stp; }
0063    void SetGradientTolerance(double toler) { fGradTlr = toler; }
0064 
0065    void SetHessianNCycles(unsigned int n) { fHessNCyc = n; }
0066    void SetHessianStepTolerance(double stp) { fHessTlrStp = stp; }
0067    void SetHessianG2Tolerance(double toler) { fHessTlrG2 = toler; }
0068    void SetHessianGradientNCycles(unsigned int n) { fHessGradNCyc = n; }
0069 
0070    // 1 = calculate central finite difference mixed derivatives (involves 3 extra evaluations per derivative)
0071    // 0 = use forward finite difference (default)
0072    void SetHessianCentralFDMixedDerivatives(unsigned int flag) { fHessCFDG2 = flag; }
0073 
0074    // 1 = returned matrix from Hesse should be forced positive definite (default)
0075    // 0 = do not force matrix positive definite
0076    void SetHessianForcePosDef(unsigned int flag) { fHessForcePosDef = flag; }
0077 
0078    // set storage level of iteration quantities
0079    // 0 = store only last iterations 1 = full storage (default)
0080    void SetStorageLevel(unsigned int level) { fStoreLevel = level; }
0081 
0082 private:
0083    unsigned int fStrategy;
0084 
0085    unsigned int fGradNCyc;
0086    double fGradTlrStp;
0087    double fGradTlr;
0088    unsigned int fHessNCyc;
0089    double fHessTlrStp;
0090    double fHessTlrG2;
0091    unsigned int fHessGradNCyc;
0092    int fHessCFDG2;
0093    int fHessForcePosDef;
0094    int fStoreLevel;
0095 };
0096 
0097 } // namespace Minuit2
0098 
0099 } // namespace ROOT
0100 
0101 #endif // ROOT_Minuit2_MnStrategy