51 : fKernelTemperature (kIncreasingAdaptive),
52 fFitterTarget ( target ),
56 fInitialTemperature ( 1000 ),
57 fMinTemperature ( 0 ),
59 fTemperatureScale ( 0.06 ),
60 fAdaptiveSpeed ( 1.0 ),
61 fTemperatureAdaptiveStep( 0.0 ),
62 fUseDefaultScale (
kFALSE ),
63 fUseDefaultTemperature ( kFALSE ),
67 fKernelTemperature = kIncreasingAdaptive;
82 Bool_t useDefaultTemperature)
89 if (kernelTemperatureS ==
"IncreasingAdaptive") {
91 Log() <<
kINFO <<
"Using increasing adaptive algorithm" <<
Endl;
93 else if (kernelTemperatureS ==
"DecreasingAdaptive") {
95 Log() <<
kINFO <<
"Using decreasing adaptive algorithm" <<
Endl;
97 else if (kernelTemperatureS ==
"Sqrt") {
101 else if (kernelTemperatureS ==
"Homo") {
105 else if (kernelTemperatureS ==
"Log") {
109 else if (kernelTemperatureS ==
"Sin") {
133 for (
UInt_t rIter = 0; rIter < parameters.size(); rIter++) {
143 for (
UInt_t rIter = 0; rIter < from.size(); rIter++) to[rIter] = from[rIter];
154 for (
UInt_t rIter=0;rIter<parameters.size();rIter++) {
158 sign = (uni - 0.5 >= 0.0) ? (1.0) : (-1.0);
159 distribution = currentTemperature * (
TMath::Power(1.0 + 1.0/currentTemperature,
TMath::Abs(2.0*uni - 1.0)) -1.0)*sign;
160 parameters[rIter] = oldParameters[rIter] + (
fRanges[rIter]->GetMax()-
fRanges[rIter]->GetMin())*0.1*distribution;
162 while (parameters[rIter] <
fRanges[rIter]->GetMin() || parameters[rIter] >
fRanges[rIter]->GetMax() );
170 std::vector<Double_t> newParameters(
fRanges.size() );
172 for (
UInt_t rIter=0; rIter<parameters.size(); rIter++) {
176 sign = (uni - 0.5 >= 0.0) ? (1.0) : (-1.0);
177 distribution = currentTemperature * (
TMath::Power(1.0 + 1.0/currentTemperature,
TMath::Abs(2.0*uni - 1.0)) -1.0)*sign;
178 newParameters[rIter] = parameters[rIter] + (
fRanges[rIter]->GetMax()-
fRanges[rIter]->GetMin())*0.1*distribution;
180 while (newParameters[rIter] <
fRanges[rIter]->GetMin() || newParameters[rIter] >
fRanges[rIter]->GetMax() );
183 return newParameters;
254 Double_t t, dT, cold, delta, deltaY,
y, yNew, yBest, yOld;
259 for (
UInt_t rIter = 0; rIter <
x.size(); rIter++)
260 x[rIter] = (
fRanges[rIter]->GetMax() +
fRanges[rIter]->GetMin() ) / 2.0;
263 if ((i>0) && (deltaY>0.0)) {
271 for (
Int_t k=0; (k<30) && (equilibrium<=12); k++ ) {
284 if (y != 0.0) delta /=
y;
285 else if (yNew != 0.0) delta /=
y;
288 if (delta < 0.1) equilibrium++;
289 else equilibrium = 0;
296 deltaY = yNew - yOld;
297 if ( (deltaY < 0.0 )&&( yNew < yBest)) {
302 if ((stopper) && (deltaY >= (100.0 * cold)))
break;
313 std::vector<Double_t> bestParameters(
fRanges.size());
314 std::vector<Double_t> oldParameters (
fRanges.size());
316 Double_t currentTemperature, bestFit, currentFit;
340 <<
", current temperature = " << currentTemperature <<
Endl;
342 bestParameters = parameters;
346 generalCalls =
fMaxCalls - optimizeCalls;
351 for (
Int_t sample = 0; sample < generalCalls; sample++) {
357 if (localFit < currentFit ||
TMath::Abs(currentFit-localFit) <
fEps) {
368 currentFit = localFit;
370 if (currentFit < bestFit) {
372 bestFit = currentFit;
376 if (!
ShouldGoIn(localFit, currentFit, currentTemperature))
379 currentFit = localFit;
397 currentTemperature = startingTemperature;
400 for (
Int_t sample=0;sample<optimizeCalls;sample++) {
404 if (localFit < currentFit) {
405 currentFit = localFit;
408 if (currentFit < bestFit) {
410 bestFit = currentFit;
415 currentTemperature-=(startingTemperature -
fEps)/optimizeCalls;
Double_t GenerateMaxTemperature(std::vector< Double_t > ¶meters)
maximum temperature
void FillWithRandomValues(std::vector< Double_t > ¶meters)
random starting parameters
virtual Double_t EstimatorFunction(std::vector< Double_t > ¶meters)=0
void GenerateNewTemperature(Double_t ¤tTemperature, Int_t Iter)
generate new temperature
Random number generator class based on M.
MsgLogger & Endl(MsgLogger &ml)
const std::vector< TMVA::Interval * > & fRanges
void swap(TDirectoryEntry &e1, TDirectoryEntry &e2) noexcept
IFitterTarget & fFitterTarget
int equals(Double_t n1, Double_t n2, double ERRORLIMIT=1.E-10)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
void GenerateNeighbour(std::vector< Double_t > ¶meters, std::vector< Double_t > &oldParameters, Double_t currentTemperature)
generate adjacent parameters
Double_t fTemperatureAdaptiveStep
Bool_t fUseDefaultTemperature
virtual ~SimulatedAnnealing()
destructor
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
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
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.
std::string GetSource() const
Double_t Minimize(std::vector< Double_t > ¶meters)
minimisation algorithm
Double_t fInitialTemperature
Double_t Sqrt(Double_t x)
Double_t fTemperatureScale
void ReWriteParameters(std::vector< Double_t > &from, std::vector< Double_t > &to)
copy parameters