CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
DeterministicAnnealing Class Reference

#include <DeterministicAnnealing.h>

Inheritance diagram for DeterministicAnnealing:
AnnealingSchedule

Classes

class  A
 

Public Member Functions

void anneal () override
 
DeterministicAnnealingclone () const override
 
double currentTemp () const override
 
double cutoff () const override
 
void debug () const override
 
 DeterministicAnnealing (float cutoff=3.0)
 
 DeterministicAnnealing (const std::vector< float > &sched, float cutoff=3.0)
 
double initialTemp () const override
 
bool isAnnealed () const override
 
double phi (double chi2) const override
 
void resetAnnealing () override
 
double weight (double chi2) const override
 
- Public Member Functions inherited from AnnealingSchedule
virtual ~AnnealingSchedule ()
 

Private Attributes

double theChi2cut
 
unsigned int theIndex
 
bool theIsAnnealed
 
std::vector< float > theTemperatures
 

Detailed Description

Definition at line 7 of file DeterministicAnnealing.h.

Constructor & Destructor Documentation

DeterministicAnnealing::DeterministicAnnealing ( float  cutoff = 3.0)

Definition at line 10 of file DeterministicAnnealing.cc.

References cutoff(), theChi2cut, theIndex, and theIsAnnealed.

Referenced by clone().

10  :
11  theTemperatures({256,64,16,4,2,1}),
12  theIndex(0), theChi2cut ( cutoff*cutoff ), theIsAnnealed ( false )
13 {
14 }
double cutoff() const override
std::vector< float > theTemperatures
DeterministicAnnealing::DeterministicAnnealing ( const std::vector< float > &  sched,
float  cutoff = 3.0 
)

Definition at line 16 of file DeterministicAnnealing.cc.

Member Function Documentation

void DeterministicAnnealing::anneal ( )
overridevirtual

Implements AnnealingSchedule.

Definition at line 21 of file DeterministicAnnealing.cc.

References theIndex, theIsAnnealed, and theTemperatures.

22 {
23  if ( theIndex < ( theTemperatures.size() - 1 ) )
24  {
25  theIndex++;
26  } else {
27  theIsAnnealed = true;
28  };
29 }
std::vector< float > theTemperatures
DeterministicAnnealing* DeterministicAnnealing::clone ( void  ) const
inlineoverridevirtual

Implements AnnealingSchedule.

Definition at line 51 of file DeterministicAnnealing.h.

References DeterministicAnnealing().

52  {
53  return new DeterministicAnnealing ( * this );
54  };
DeterministicAnnealing(float cutoff=3.0)
double DeterministicAnnealing::currentTemp ( ) const
overridevirtual

Implements AnnealingSchedule.

Definition at line 64 of file DeterministicAnnealing.cc.

References theIndex, and theTemperatures.

65 {
66  return theTemperatures[theIndex];
67 }
std::vector< float > theTemperatures
double DeterministicAnnealing::cutoff ( ) const
overridevirtual

Returns phi(chi2) / ( phi(cutoff^2) + sum_i { phi(chi2s[i]) } )

Implements AnnealingSchedule.

Definition at line 59 of file DeterministicAnnealing.cc.

References mathSSE::sqrt(), and theChi2cut.

Referenced by DeterministicAnnealing().

60 {
61  return sqrt(theChi2cut);
62 }
T sqrt(T t)
Definition: SSEVec.h:18
void DeterministicAnnealing::debug ( ) const
overridevirtual

Implements AnnealingSchedule.

Definition at line 79 of file DeterministicAnnealing.cc.

References gather_cfg::cout, mps_fire::i, and theTemperatures.

80 {
81  cout << "[DeterministicAnnealing] schedule=";
82  for ( vector< float >::const_iterator i=theTemperatures.begin();
83  i!=theTemperatures.end() ; ++i )
84  {
85  cout << *i << " ";
86  };
87  cout << endl;
88 }
std::vector< float > theTemperatures
double DeterministicAnnealing::initialTemp ( ) const
overridevirtual

Implements AnnealingSchedule.

Definition at line 69 of file DeterministicAnnealing.cc.

References theTemperatures.

70 {
71  return theTemperatures[0];
72 }
std::vector< float > theTemperatures
bool DeterministicAnnealing::isAnnealed ( ) const
overridevirtual

is it annealed yet?

Implements AnnealingSchedule.

Definition at line 74 of file DeterministicAnnealing.cc.

References theIsAnnealed.

75 {
76  return theIsAnnealed;
77 }
double DeterministicAnnealing::phi ( double  chi2) const
inlineoverridevirtual

phi ( chi2 ) = e^( -.5*chi2 / T )

Implements AnnealingSchedule.

Definition at line 54 of file DeterministicAnnealing.cc.

References JetChargeProducer_cfi::exp, theIndex, and theTemperatures.

Referenced by Particle.Particle::__str__(), ntupleDataFormat.Track::phiPull(), and weight().

void DeterministicAnnealing::resetAnnealing ( )
overridevirtual

Implements AnnealingSchedule.

Definition at line 48 of file DeterministicAnnealing.cc.

References theIndex, and theIsAnnealed.

49 {
50  theIndex=0;
51  theIsAnnealed = false;
52 }
double DeterministicAnnealing::weight ( double  chi2) const
overridevirtual

Returns phi(chi2) / ( phi(cutoff^2) + phi(chi2) ),

Implements AnnealingSchedule.

Definition at line 31 of file DeterministicAnnealing.cc.

References edm::isNotFinite(), phi(), and theChi2cut.

32 {
33  long double mphi = phi ( chi2 );
34  /*
35  if ( mphi < std::numeric_limits<double>::epsilon() ) return 0.;
36  return 1. / ( 1. + phi ( theChi2cut * theChi2cut ) / mphi );
37  */
38  // return mphi / ( mphi + phi ( theChi2cut ) );
39  long double newtmp = mphi / ( mphi + phi ( theChi2cut ) );
40  if ( edm::isNotFinite(newtmp ) )
41  {
42  if ( chi2 < theChi2cut ) newtmp=1.;
43  else newtmp=0.;
44  }
45  return newtmp;
46 }
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
double phi(double chi2) const override

Member Data Documentation

double DeterministicAnnealing::theChi2cut
private

Definition at line 59 of file DeterministicAnnealing.h.

Referenced by cutoff(), DeterministicAnnealing(), and weight().

unsigned int DeterministicAnnealing::theIndex
private
bool DeterministicAnnealing::theIsAnnealed
private
std::vector<float> DeterministicAnnealing::theTemperatures
private

Definition at line 54 of file DeterministicAnnealing.h.

Referenced by anneal(), currentTemp(), debug(), initialTemp(), and phi().