CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
DeterministicAnnealingclone () const
 
double currentTemp () const
 
double cutoff () const
 
void debug () const
 
 DeterministicAnnealing (float cutoff=3.0)
 
 DeterministicAnnealing (const std::vector< float > &sched, float cutoff=3.0)
 
double initialTemp () const
 
bool isAnnealed () const
 
double phi (double chi2) const
 
void resetAnnealing ()
 
double weight (double chi2) const
 
- Public Member Functions inherited from AnnealingSchedule
virtual ~AnnealingSchedule ()
 

Private Attributes

double theChi2cut
 
unsigned int theIndex
 
bool theIsAnnealed
 

Detailed Description

Definition at line 7 of file DeterministicAnnealing.h.

Constructor & Destructor Documentation

DeterministicAnnealing::DeterministicAnnealing ( float  cutoff = 3.0)

Definition at line 13 of file DeterministicAnnealing.cc.

Referenced by clone().

13  :
14  theIndex(0), theChi2cut ( cutoff*cutoff ), theIsAnnealed ( false )
15 {
16  temperatures.push_back(256);
17  temperatures.push_back(64);
18  temperatures.push_back(16);
19  temperatures.push_back(4);
20  temperatures.push_back(2);
21  temperatures.push_back(1);
22 }
DeterministicAnnealing::DeterministicAnnealing ( const std::vector< float > &  sched,
float  cutoff = 3.0 
)

Definition at line 24 of file DeterministicAnnealing.cc.

25  : theIndex(0), theChi2cut ( cutoff*cutoff ), theIsAnnealed ( false )
26 {
27  temperatures = sched;
28 }

Member Function Documentation

void DeterministicAnnealing::anneal ( )
virtual

Implements AnnealingSchedule.

Definition at line 30 of file DeterministicAnnealing.cc.

References theIndex, and theIsAnnealed.

31 {
32  if ( theIndex < ( temperatures.size() - 1 ) )
33  {
34  theIndex++;
35  } else {
36  theIsAnnealed = true;
37  };
38 }
DeterministicAnnealing* DeterministicAnnealing::clone ( void  ) const
inlinevirtual

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
virtual

Implements AnnealingSchedule.

Definition at line 73 of file DeterministicAnnealing.cc.

References theIndex.

74 {
75  return temperatures[theIndex];
76 }
double DeterministicAnnealing::cutoff ( ) const
virtual

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

Implements AnnealingSchedule.

Definition at line 68 of file DeterministicAnnealing.cc.

References mathSSE::sqrt(), and theChi2cut.

69 {
70  return sqrt(theChi2cut);
71 }
T sqrt(T t)
Definition: SSEVec.h:46
void DeterministicAnnealing::debug ( ) const
virtual

Implements AnnealingSchedule.

Definition at line 88 of file DeterministicAnnealing.cc.

References gather_cfg::cout, and i.

89 {
90  cout << "[DeterministicAnnealing] schedule=";
91  for ( vector< float >::const_iterator i=temperatures.begin();
92  i!=temperatures.end() ; ++i )
93  {
94  cout << *i << " ";
95  };
96  cout << endl;
97 }
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121
double DeterministicAnnealing::initialTemp ( ) const
virtual

Implements AnnealingSchedule.

Definition at line 78 of file DeterministicAnnealing.cc.

79 {
80  return temperatures[0];
81 }
bool DeterministicAnnealing::isAnnealed ( ) const
virtual

is it annealed yet?

Implements AnnealingSchedule.

Definition at line 83 of file DeterministicAnnealing.cc.

References theIsAnnealed.

84 {
85  return theIsAnnealed;
86 }
double DeterministicAnnealing::phi ( double  chi2) const
inlinevirtual

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

Implements AnnealingSchedule.

Definition at line 63 of file DeterministicAnnealing.cc.

References create_public_lumi_plots::exp, and theIndex.

Referenced by weight().

64 {
65  return exp ( -.5 * chi2 / temperatures[theIndex] );
66 }
void DeterministicAnnealing::resetAnnealing ( )
virtual

Implements AnnealingSchedule.

Definition at line 57 of file DeterministicAnnealing.cc.

References theIndex, and theIsAnnealed.

58 {
59  theIndex=0;
60  theIsAnnealed = false;
61 }
double DeterministicAnnealing::weight ( double  chi2) const
virtual

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

Implements AnnealingSchedule.

Definition at line 40 of file DeterministicAnnealing.cc.

References phi(), and theChi2cut.

41 {
42  long double mphi = phi ( chi2 );
43  /*
44  if ( mphi < std::numeric_limits<double>::epsilon() ) return 0.;
45  return 1. / ( 1. + phi ( theChi2cut * theChi2cut ) / mphi );
46  */
47  // return mphi / ( mphi + phi ( theChi2cut ) );
48  long double newtmp = mphi / ( mphi + phi ( theChi2cut ) );
49  if ( std::isinf(newtmp ) )
50  {
51  if ( chi2 < theChi2cut ) newtmp=1.;
52  else newtmp=0.;
53  }
54  return newtmp;
55 }
double phi(double chi2) const

Member Data Documentation

double DeterministicAnnealing::theChi2cut
private

Definition at line 58 of file DeterministicAnnealing.h.

Referenced by cutoff(), and weight().

unsigned int DeterministicAnnealing::theIndex
private

Definition at line 54 of file DeterministicAnnealing.h.

Referenced by anneal(), currentTemp(), phi(), and resetAnnealing().

bool DeterministicAnnealing::theIsAnnealed
private

Definition at line 59 of file DeterministicAnnealing.h.

Referenced by anneal(), isAnnealed(), and resetAnnealing().