CMS 3D CMS Logo

DeterministicAnnealing.cc
Go to the documentation of this file.
3 #include <cmath>
4 #include <vector>
5 #include <iostream>
6 #include <limits>
7 
8 using namespace std;
9 
11  : theTemperatures({256, 64, 16, 4, 2, 1}), theIndex(0), theChi2cut(cutoff * cutoff), theIsAnnealed(false) {}
12 
13 DeterministicAnnealing::DeterministicAnnealing(const vector<float>& sched, float cutoff)
14  : theTemperatures(sched), theIndex(0), theChi2cut(cutoff * cutoff), theIsAnnealed(false) {}
15 
17  if (theIndex < (theTemperatures.size() - 1)) {
18  theIndex++;
19  } else {
20  theIsAnnealed = true;
21  };
22 }
23 
24 double DeterministicAnnealing::weight(double chi2) const {
25  long double mphi = phi(chi2);
26  /*
27  if ( mphi < std::numeric_limits<double>::epsilon() ) return 0.;
28  return 1. / ( 1. + phi ( theChi2cut * theChi2cut ) / mphi );
29  */
30  // return mphi / ( mphi + phi ( theChi2cut ) );
31  long double newtmp = mphi / (mphi + phi(theChi2cut));
32  if (edm::isNotFinite(newtmp)) {
33  if (chi2 < theChi2cut)
34  newtmp = 1.;
35  else
36  newtmp = 0.;
37  }
38  return newtmp;
39 }
40 
42  theIndex = 0;
43  theIsAnnealed = false;
44 }
45 
46 inline double DeterministicAnnealing::phi(double chi2) const { return exp(-.5 * chi2 / theTemperatures[theIndex]); }
47 
48 double DeterministicAnnealing::cutoff() const { return sqrt(theChi2cut); }
49 
51 
53 
55 
57  cout << "[DeterministicAnnealing] schedule=";
58  for (vector<float>::const_iterator i = theTemperatures.begin(); i != theTemperatures.end(); ++i) {
59  cout << *i << " ";
60  };
61  cout << endl;
62 }
mps_fire.i
i
Definition: mps_fire.py:355
DeterministicAnnealing::cutoff
double cutoff() const override
Definition: DeterministicAnnealing.cc:48
funct::false
false
Definition: Factorize.h:34
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
qjetsadder_cfi.cutoff
cutoff
Definition: qjetsadder_cfi.py:11
DeterministicAnnealing::weight
double weight(double chi2) const override
Definition: DeterministicAnnealing.cc:24
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DeterministicAnnealing::theIsAnnealed
bool theIsAnnealed
Definition: DeterministicAnnealing.h:54
DeterministicAnnealing::anneal
void anneal() override
Definition: DeterministicAnnealing.cc:16
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
DeterministicAnnealing::DeterministicAnnealing
DeterministicAnnealing(float cutoff=3.0)
Definition: DeterministicAnnealing.cc:10
DeterministicAnnealing::isAnnealed
bool isAnnealed() const override
Definition: DeterministicAnnealing.cc:54
DeterministicAnnealing.h
DeterministicAnnealing::theTemperatures
std::vector< float > theTemperatures
Definition: DeterministicAnnealing.h:48
DeterministicAnnealing::initialTemp
double initialTemp() const override
Definition: DeterministicAnnealing.cc:52
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DeterministicAnnealing::debug
void debug() const override
Definition: DeterministicAnnealing.cc:56
std
Definition: JetResolutionObject.h:76
isFinite.h
DeterministicAnnealing::theIndex
unsigned int theIndex
Definition: DeterministicAnnealing.h:52
DeterministicAnnealing::currentTemp
double currentTemp() const override
Definition: DeterministicAnnealing.cc:50
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
DeterministicAnnealing::phi
double phi(double chi2) const override
Definition: DeterministicAnnealing.cc:46
DeterministicAnnealing::theChi2cut
double theChi2cut
Definition: DeterministicAnnealing.h:53
DeterministicAnnealing::resetAnnealing
void resetAnnealing() override
Definition: DeterministicAnnealing.cc:41