Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:50

0001 // @(#)root/tmva $Id$
0002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : ConvergenceTest                                                             *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      Contains all the data information                                         *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
0015  *      Peter Speckmayer <Peter.Speckmayer@cern.ch>  - CERN, Switzerland          *
0016  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
0017  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
0018  *                                                                                *
0019  * Copyright (c) 2006:                                                            *
0020  *      CERN, Switzerland                                                         *
0021  *      U. of Victoria, Canada                                                    *
0022  *      MPI-K Heidelberg, Germany                                                 *
0023  *                                                                                *
0024  * Redistribution and use in source and binary forms, with or without             *
0025  * modification, are permitted according to the terms listed in LICENSE           *
0026  * (see tmva/doc/LICENSE)                                          *
0027  **********************************************************************************/
0028 
0029 #ifndef ROOT_TMVA_ConvergenceTest
0030 #define ROOT_TMVA_ConvergenceTest
0031 
0032 //////////////////////////////////////////////////////////////////////////
0033 //                                                                      //
0034 // ConvergenceTest                                                      //
0035 //                                                                      //
0036 // check for convergence                                                //
0037 //                                                                      //
0038 //////////////////////////////////////////////////////////////////////////
0039 
0040 #include <deque>
0041 
0042 #include "RtypesCore.h"
0043 
0044 namespace TMVA {
0045 
0046    class ConvergenceTest {
0047 
0048    public:
0049 
0050       ConvergenceTest();
0051       ~ConvergenceTest();
0052 
0053       // setters
0054       void                       SetConvergenceParameters(  Int_t steps, Double_t improvement )
0055       { fSteps = steps; fImprovement = improvement; }
0056       void                       SetCurrentValue(  Float_t value )  { fCurrentValue = value; }
0057       Float_t                    GetCurrentValue()                  { return fCurrentValue; }
0058       void                       ResetConvergenceCounter()  { fCounter = -1; fMaxCounter = 0; }
0059 
0060       // getters
0061       Bool_t                     HasConverged( Bool_t withinConvergenceBand = kFALSE );
0062       Float_t                    Progress();          // from 0 (just started) to 1 (finished)
0063       Float_t                    SpeedControl( UInt_t ofSteps );
0064 
0065 
0066    protected:
0067 
0068       Float_t                    fCurrentValue;      ///<! current value
0069 
0070       Float_t                    fImprovement;       ///<! minimum improvement which counts as improvement
0071       Int_t                      fSteps;             ///<! number of steps without improvement required for convergence
0072 
0073    private:
0074 
0075       Int_t                      fCounter;           ///<! counts the number of steps without improvement
0076       Float_t                    fConvValue;         ///<! the best "fitness" value
0077       Int_t                      fMaxCounter;        ///<! maximum value for the counter so far
0078 
0079       // speed-control (gives back the learning speed = improvement-rate in the last N steps)
0080       // successList keeps track of the improvements to be able
0081       Float_t                    fBestResult;
0082       Float_t                    fLastResult;
0083       std::deque<Short_t>        fSuccessList;       ///< to calculate the improvement-speed
0084 
0085    };
0086 }
0087 
0088 #endif