source: branches/removing_cpp11_features/mtools/MSimulatedAnnealing.h@ 18250

Last change on this file since 18250 was 5832, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.1 KB
Line 
1#ifndef MARS_MSimulatedAnnealing
2#define MARS_MSimulatedAnnealing
3
4#ifndef MARS_MAGIC
5#include "MAGIC.h"
6#endif
7
8#ifndef ROOT_TMatrix
9#include <TMatrix.h>
10#endif
11
12#ifndef ROOT_TVector
13#include <TVector.h>
14#endif
15
16class MHSimulatedAnnealing;
17class TRandom;
18
19class MSimulatedAnnealing : public TObject
20{
21private:
22
23 static const Float_t gsYtryStr; // Fixed high value to keep the simplex inside the borders
24 static const Float_t gsYtryCon; // Fixed high value to keep the simplex inside the borders
25 static const Int_t gsMaxDim; // Fixed maximum number of dimensions
26 static const Int_t gsMaxStep; // Fixed maximum number of loops with temperature=0
27
28 MHSimulatedAnnealing *fResult; //! The histogram output container
29
30 TRandom *fRandom; // The random number generator -> random numbers between 0 and 1
31
32 Real_t fTolerance; // The convergence break condition
33
34 UShort_t fNdim; // The number of parameters
35 UShort_t fMpts; // The number of simplex points (=fNdim+1)
36
37 UShort_t fNumberOfMoves; // The total number of moves (== CPU time)
38
39 Real_t fStartTemperature; // The start temperature -> will slowly get decreased to 0
40
41 Bool_t fFullStorage; // kTRUE -> the whole simplex gets stored in MHSimlutedAnnealing
42 Bool_t fInit; // kTRUE -> initialization was succesful
43
44 TMatrix fP; // The (ndim+1,ndim) matrix containing the simplex
45
46 TVector fPsum; // The sum of each point of the simplex
47
48 TVector fP0; // The boundary conditions on the weak side
49 TVector fP1; // The boundary conditions on the strong side
50 TVector fY; // The array containing the function evaluation results
51
52 Real_t fYb; // The best function evaluation value ever found
53 Real_t fYconv; // The function evaluation value at the convergence point
54
55 TVector fPb; // The parameters belonging to fYb
56 TVector fPconv; // The parameters belonging to fYconv
57
58 Int_t Amebsa(Int_t iter,
59 const Real_t temp); // The function deciding if the simplex has to get reflected, expanded or contracted
60
61 Real_t Amotsa(const Float_t fac,
62 const UShort_t ihi,
63 Real_t &yhi,
64 const Real_t temp); // The function reflecting, expanding and contracting the simplex: fac=-1 -> reflection, fac=0.5 -> contraction, fac=2.0 -> expansion
65
66 void GetPsum();
67
68protected:
69
70 virtual Float_t FunctionToMinimize(const TVector &arr); // The optimization function
71
72public:
73 enum BorderFlag_t { kENoBorder, kEStrictBorder, kEContractBorder };
74 enum Verbosity_t { kEDefault, kEVerbose, kEDebug };
75
76private:
77 BorderFlag_t fBorder;
78 Verbosity_t fVerbose;
79
80public:
81 MSimulatedAnnealing();
82 virtual ~MSimulatedAnnealing();
83
84 void ModifyTolerance(Float_t tol) { fTolerance = tol; }
85 void ModifyBorderFlag(BorderFlag_t border) { fBorder = border; }
86
87 Bool_t Initialize(const TMatrix &p, const TVector &y,
88 const TVector &p0, const TVector &p1);
89
90 void SetNumberOfMoves(UShort_t moves) { fNumberOfMoves = moves; }
91 void SetStartTemperature(Float_t temp) { fStartTemperature = temp; }
92 void SetFullStorage() { fFullStorage = kTRUE; }
93 void SetVerbosityLevel(Verbosity_t level) { fVerbose = level; }
94 void SetRandom(TRandom *rand) { fRandom = rand; }
95
96 const TVector &GetPb() const { return fPb; }
97 Float_t GetYb() const { return fYb; }
98
99 const TVector &GetPconv() const { return fPconv; }
100 Float_t GetYconv() const { return fYconv; }
101
102
103 MHSimulatedAnnealing *GetResult() { return fResult; }
104
105 Bool_t RunMinimization();
106
107 ClassDef(MSimulatedAnnealing,1) // Class to perform a Simulated Annealing Minimization
108};
109
110#endif
Note: See TracBrowser for help on using the repository browser.