ROOT  6.06/09
Reference Guide
SimulatedAnnealing.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Krzysztof Danielowski, Kamil Kraszewski, Maciej Kruk
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : SimulatedAnnealing *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation of simulated annealing fitting procedure *
12  * *
13  * Authors (alphabetical): *
14  * Krzysztof Danielowski <danielow@cern.ch> - IFJ & AGH, Poland *
15  * Kamil Kraszewski <kalq@cern.ch> - IFJ & UJ, Poland *
16  * Maciej Kruk <mkruk@cern.ch> - IFJ & AGH, Poland *
17  * *
18  * Copyright (c) 2008: *
19  * IFJ-Krakow, Poland *
20  * CERN, Switzerland *
21  * MPI-K Heidelberg, Germany *
22  * *
23  * Redistribution and use in source and binary forms, with or without *
24  * modification, are permitted according to the terms listed in LICENSE *
25  * (http://tmva.sourceforge.net/LICENSE) *
26  **********************************************************************************/
27 
28 #ifndef ROOT_TMVA_SimulatedAnnealing
29 #define ROOT_TMVA_SimulatedAnnealing
30 
31 //////////////////////////////////////////////////////////////////////////
32 // //
33 // SimulatedAnnealing //
34 // //
35 // Base implementation of simulated annealing fitting procedure //
36 // //
37 //////////////////////////////////////////////////////////////////////////
38 
39 #include <vector>
40 #include <list>
41 
42 #ifndef ROOT_TMVA_Types
43 #include "TMVA/Types.h"
44 #endif
45 
46 class TRandom;
47 
48 namespace TMVA {
49 
50  class IFitterTarget;
51  class Interval;
52  class MsgLogger;
53 
55 
56  public:
57 
58  SimulatedAnnealing( IFitterTarget& target, const std::vector<TMVA::Interval*>& ranges );
59  virtual ~SimulatedAnnealing();
60 
61  // returns FCN value at minimum
62  Double_t Minimize( std::vector<Double_t>& parameters );
63 
64  // accessors
65  void SetMaxCalls ( Int_t mc ) { fMaxCalls = mc; }
68  void SetAccuracy ( Double_t eps ) { fEps = eps; }
69  void SetTemperatureScale ( Double_t scale ) { fTemperatureScale = scale; }
70  void SetAdaptiveSpeed ( Double_t speed ) { fAdaptiveSpeed = speed; }
71 
72  void SetOptions( Int_t maxCalls, Double_t initialTemperature, Double_t minTemperature, Double_t eps,
73  TString kernelTemperatureS, Double_t temperatureScale, Double_t adaptiveSpeed,
74  Double_t temperatureAdaptiveStep, Bool_t useDefaultScale, Bool_t useDefaultTemperature );
75 
76 
77  private:
78 
80  kSqrt = 0,
88 
89  void FillWithRandomValues( std::vector<Double_t>& parameters );
90  void ReWriteParameters( std::vector<Double_t>& from, std::vector<Double_t>& to );
91  void GenerateNewTemperature(Double_t& currentTemperature, Int_t Iter );
92  void GenerateNeighbour( std::vector<Double_t>& parameters, std::vector<Double_t>& oldParameters, Double_t currentTemperature );
93  Bool_t ShouldGoIn( Double_t currentFit, Double_t localFit, Double_t currentTemperature );
94  void SetDefaultScale();
95  Double_t GenerateMaxTemperature( std::vector<Double_t>& parameters );
96  std::vector<Double_t> GenerateNeighbour( std::vector<Double_t>& parameters, Double_t currentTemperature );
97 
98  IFitterTarget& fFitterTarget; // the fitter target
99  TRandom* fRandom; // random generator
100  const std::vector<TMVA::Interval*>& fRanges; // parameter ranges
101 
102  // fitter setup
103  Int_t fMaxCalls; // maximum number of minimisation calls
104  Double_t fInitialTemperature; // initial temperature
105  Double_t fMinTemperature; // mimimum temperature
106  Double_t fEps; // epsilon
107  Double_t fTemperatureScale; // how fast temperature change
108  Double_t fAdaptiveSpeed; // how fast temperature change in adaptive (in adaptive two variables describe
109  // the change of temperature, but fAdaptiveSpeed should be 1.0 and its not
110  // recomended to change it)
111  Double_t fTemperatureAdaptiveStep;// used to calculate InitialTemperature if fUseDefaultTemperature
112 
113  Bool_t fUseDefaultScale; // if TRUE, SA calculates its own TemperatureScale
114  Bool_t fUseDefaultTemperature; // if TRUE, SA calculates its own InitialTemperature (MinTemperautre)
115 
116  mutable MsgLogger* fLogger; // message logger
117  MsgLogger& Log() const { return *fLogger; }
118 
120 
121  ClassDef(SimulatedAnnealing,0) // Base class for Simulated Annealing fitting
122  };
123 
124 } // namespace TMVA
125 
126 #endif
127 
Double_t GenerateMaxTemperature(std::vector< Double_t > &parameters)
maximum temperature
void FillWithRandomValues(std::vector< Double_t > &parameters)
random starting parameters
void GenerateNewTemperature(Double_t &currentTemperature, Int_t Iter)
generate new temperature
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
const std::vector< TMVA::Interval * > & fRanges
void SetAccuracy(Double_t eps)
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void GenerateNeighbour(std::vector< Double_t > &parameters, std::vector< Double_t > &oldParameters, Double_t currentTemperature)
generate adjacent parameters
#define ClassDef(name, id)
Definition: Rtypes.h:254
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:29
virtual ~SimulatedAnnealing()
destructor
void SetTemperatureScale(Double_t scale)
void SetOptions(Int_t maxCalls, Double_t initialTemperature, Double_t minTemperature, Double_t eps, TString kernelTemperatureS, Double_t temperatureScale, Double_t adaptiveSpeed, Double_t temperatureAdaptiveStep, Bool_t useDefaultScale, Bool_t useDefaultTemperature)
option setter
void SetInitTemp(Double_t it)
SimulatedAnnealing(IFitterTarget &target, const std::vector< TMVA::Interval * > &ranges)
void SetDefaultScale()
setting of default scale
double Double_t
Definition: RtypesCore.h:55
Bool_t ShouldGoIn(Double_t currentFit, Double_t localFit, Double_t currentTemperature)
result checker
enum TMVA::SimulatedAnnealing::EKernelTemperature fKernelTemperature
Abstract ClassifierFactory template that handles arbitrary types.
Double_t Minimize(std::vector< Double_t > &parameters)
minimisation algorithm
MsgLogger & Log() const
void ReWriteParameters(std::vector< Double_t > &from, std::vector< Double_t > &to)
copy parameters
void SetAdaptiveSpeed(Double_t speed)
void SetMinTemp(Double_t min)