Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:17

0001 // @(#)root/mathmore:$Id$
0002 // Author: L. Moneta Wed Dec 20 17:16:32 2006
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
0007  *                                                                    *
0008  * This library is free software; you can redistribute it and/or      *
0009  * modify it under the terms of the GNU General Public License        *
0010  * as published by the Free Software Foundation; either version 2     *
0011  * of the License, or (at your option) any later version.             *
0012  *                                                                    *
0013  * This library is distributed in the hope that it will be useful,    *
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
0016  * General Public License for more details.                           *
0017  *                                                                    *
0018  * You should have received a copy of the GNU General Public License  *
0019  * along with this library (see file COPYING); if not, write          *
0020  * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
0021  * 330, Boston, MA 02111-1307 USA, or contact the author.             *
0022  *                                                                    *
0023  **********************************************************************/
0024 
0025 // Header file for class GSLSimAnMinimizer
0026 
0027 #ifndef ROOT_Math_GSLSimAnMinimizer
0028 #define ROOT_Math_GSLSimAnMinimizer
0029 
0030 
0031 
0032 #include "Math/BasicMinimizer.h"
0033 
0034 
0035 #include "Math/IFunctionfwd.h"
0036 
0037 #include "Math/IParamFunctionfwd.h"
0038 
0039 
0040 
0041 #include "Math/GSLSimAnnealing.h"
0042 
0043 
0044 
0045 
0046 namespace ROOT {
0047 
0048    namespace Math {
0049 
0050 
0051 
0052 //_____________________________________________________________________________________
0053    /**
0054       GSLSimAnMinimizer class for minimization using simulated annealing
0055       using the algorithm from
0056       <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Simulated-Annealing.html">
0057       GSL</A>.
0058       It implements the ROOT::Minimizer interface and
0059       a plug-in (name "GSLSimAn") exists to instantiate this class via the plug-in manager
0060       Configuration (Setting/getting) the options is done through the methods defined in the
0061       ROOT::Math::Minimizer class.
0062       The user needs to call the base class method ROOT::Math::Minimizer::SetOptions to set the
0063       corresponding options.
0064       Here is some code example for increasing n_tries from 200 (default) to 1000
0065        ```
0066          ROOT::Math::GenAlgoOptions simanOpt;
0067          simanOpt.SetValue("n_tries", 1000);
0068          ROOT::Math::MinimizerOptions opt;
0069          opt.SetExtraOptions(simanOpt);
0070          minimizer->SetOptions(opt);
0071        ```
0072 
0073       @ingroup MultiMin
0074    */
0075    class GSLSimAnMinimizer : public ROOT::Math::BasicMinimizer {
0076 
0077    public:
0078       /**
0079          Default constructor
0080       */
0081       GSLSimAnMinimizer(int type = 0);
0082 
0083       /**
0084          Destructor (no operations)
0085       */
0086       ~GSLSimAnMinimizer() override;
0087 
0088    private:
0089       // usually copying is non trivial, so we make this unaccessible
0090 
0091       /**
0092          Copy constructor
0093       */
0094       GSLSimAnMinimizer(const GSLSimAnMinimizer &) : ROOT::Math::BasicMinimizer() {}
0095 
0096       /**
0097          Assignment operator
0098       */
0099       GSLSimAnMinimizer &operator=(const GSLSimAnMinimizer &rhs)
0100       {
0101          if (this == &rhs)
0102             return *this; // time saving self-test
0103          return *this;
0104       }
0105 
0106    public:
0107       /// method to perform the minimization
0108       bool Minimize() override;
0109 
0110       /// number of calls
0111       unsigned int NCalls() const override;
0112 
0113       /// Get current minimizer option parameters
0114       const GSLSimAnParams &MinimizerParameters() const { return fSolver.Params(); }
0115 
0116       /// set new minimizer option parameters using directly the GSLSimAnParams structure
0117       void SetParameters(const GSLSimAnParams &params)
0118       {
0119          fSolver.SetParams(params);
0120          DoSetMinimOptions(params); // store new parameters also in MinimizerOptions
0121       }
0122 
0123    protected:
0124       /// set minimizer option parameters from stored ROOT::Math::MinimizerOptions (fOpt)
0125       void DoSetSimAnParameters(const MinimizerOptions &opt);
0126 
0127       /// Set the Minimizer options from the simulated annealing parameters
0128       void DoSetMinimOptions(const GSLSimAnParams &params);
0129 
0130    private:
0131       ROOT::Math::GSLSimAnnealing fSolver;
0132 
0133 
0134 };
0135 
0136    } // end namespace Math
0137 
0138 } // end namespace ROOT
0139 
0140 
0141 #endif /* ROOT_Math_GSLSimAnMinimizer */