Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
41#include "TMVA/Types.h"
42
43class TRandom;
44
45namespace TMVA {
46
47 class IFitterTarget;
48 class Interval;
49 class MsgLogger;
50
52
53 public:
54
55 SimulatedAnnealing( IFitterTarget& target, const std::vector<TMVA::Interval*>& ranges );
56 virtual ~SimulatedAnnealing();
57
58 // returns FCN value at minimum
59 Double_t Minimize( std::vector<Double_t>& parameters );
60
61 // accessors
62 void SetMaxCalls ( Int_t mc ) { fMaxCalls = mc; }
64 void SetMinTemp ( Double_t min ) { fMinTemperature = min; }
65 void SetAccuracy ( Double_t eps ) { fEps = eps; }
67 void SetAdaptiveSpeed ( Double_t speed ) { fAdaptiveSpeed = speed; }
68
69 void SetOptions( Int_t maxCalls, Double_t initialTemperature, Double_t minTemperature, Double_t eps,
70 TString kernelTemperatureS, Double_t temperatureScale, Double_t adaptiveSpeed,
71 Double_t temperatureAdaptiveStep, Bool_t useDefaultScale, Bool_t useDefaultTemperature );
72
73 //setting up helper variables for JsMVA
74 void SetIPythonInteractive(bool* ExitFromTraining, UInt_t *fIPyCurrentIter_){
75 fExitFromTraining = ExitFromTraining;
76 fIPyCurrentIter = fIPyCurrentIter_;
77 }
78
79 private:
80
82 kSqrt = 0,
88 kGeo
90
91 void FillWithRandomValues( std::vector<Double_t>& parameters );
92 void ReWriteParameters( std::vector<Double_t>& from, std::vector<Double_t>& to );
93 void GenerateNewTemperature(Double_t& currentTemperature, Int_t Iter );
94 void GenerateNeighbour( std::vector<Double_t>& parameters, std::vector<Double_t>& oldParameters, Double_t currentTemperature );
95 Bool_t ShouldGoIn( Double_t currentFit, Double_t localFit, Double_t currentTemperature );
96 void SetDefaultScale();
97 Double_t GenerateMaxTemperature( std::vector<Double_t>& parameters );
98 std::vector<Double_t> GenerateNeighbour( std::vector<Double_t>& parameters, Double_t currentTemperature );
99
100 IFitterTarget& fFitterTarget; ///< the fitter target
101 TRandom* fRandom; ///< random generator
102 const std::vector<TMVA::Interval*>& fRanges; ///< parameter ranges
103
104 // fitter setup
105 Int_t fMaxCalls; ///< maximum number of minimisation calls
106 Double_t fInitialTemperature; ///< initial temperature
107 Double_t fMinTemperature; ///< minimum temperature
108 Double_t fEps; ///< epsilon
109 Double_t fTemperatureScale; ///< how fast temperature change
110 Double_t fAdaptiveSpeed; ///< how fast temperature change in adaptive (in adaptive two variables describe
111 ///< the change of temperature, but fAdaptiveSpeed should be 1.0 and its not
112 ///< recommended to change it)
113 Double_t fTemperatureAdaptiveStep;///< used to calculate InitialTemperature if fUseDefaultTemperature
114
115 Bool_t fUseDefaultScale; ///< if TRUE, SA calculates its own TemperatureScale
116 Bool_t fUseDefaultTemperature; ///< if TRUE, SA calculates its own InitialTemperature (MinTemperautre)
117
118 mutable MsgLogger* fLogger; ///< message logger
119 MsgLogger& Log() const { return *fLogger; }
120
122
123 // variables for JsMVA
125 bool * fExitFromTraining = nullptr;
126
127 ClassDef(SimulatedAnnealing,0); // Base class for Simulated Annealing fitting
128 };
129
130} // namespace TMVA
131
132#endif
133
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
#define ClassDef(name, id)
Definition Rtypes.h:337
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Interface for a fitter 'target'.
ostringstream derivative to redirect and format output
Definition MsgLogger.h:57
Base implementation of simulated annealing fitting procedure.
TRandom * fRandom
random generator
void GenerateNeighbour(std::vector< Double_t > &parameters, std::vector< Double_t > &oldParameters, Double_t currentTemperature)
generate adjacent parameters
Double_t Minimize(std::vector< Double_t > &parameters)
minimisation algorithm
Double_t fInitialTemperature
initial temperature
virtual ~SimulatedAnnealing()
destructor
Double_t GenerateMaxTemperature(std::vector< Double_t > &parameters)
maximum temperature
Double_t fTemperatureScale
how fast temperature change
Bool_t fUseDefaultTemperature
if TRUE, SA calculates its own InitialTemperature (MinTemperautre)
Bool_t fUseDefaultScale
if TRUE, SA calculates its own TemperatureScale
void SetInitTemp(Double_t it)
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 SetDefaultScale()
setting of default scale
void GenerateNewTemperature(Double_t &currentTemperature, Int_t Iter)
generate new temperature
void SetAccuracy(Double_t eps)
void SetMinTemp(Double_t min)
void FillWithRandomValues(std::vector< Double_t > &parameters)
random starting parameters
const std::vector< TMVA::Interval * > & fRanges
parameter ranges
Double_t fTemperatureAdaptiveStep
used to calculate InitialTemperature if fUseDefaultTemperature
void ReWriteParameters(std::vector< Double_t > &from, std::vector< Double_t > &to)
copy parameters
enum TMVA::SimulatedAnnealing::EKernelTemperature fKernelTemperature
IFitterTarget & fFitterTarget
the fitter target
Double_t fAdaptiveSpeed
how fast temperature change in adaptive (in adaptive two variables describe the change of temperature...
void SetTemperatureScale(Double_t scale)
Int_t fMaxCalls
maximum number of minimisation calls
void SetAdaptiveSpeed(Double_t speed)
void SetIPythonInteractive(bool *ExitFromTraining, UInt_t *fIPyCurrentIter_)
MsgLogger * fLogger
message logger
Bool_t ShouldGoIn(Double_t currentFit, Double_t localFit, Double_t currentTemperature)
result checker
Double_t fMinTemperature
minimum temperature
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Basic string class.
Definition TString.h:139
create variable transformations