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
 
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 9 of file DeterministicAnnealing.cc.

Referenced by clone().

9  :
10  theTemperatures({256,64,16,4,2,1}),
std::vector< float > theTemperatures
DeterministicAnnealing::DeterministicAnnealing ( const std::vector< float > &  sched,
float  cutoff = 3.0 
)

Definition at line 15 of file DeterministicAnnealing.cc.

Member Function Documentation

void DeterministicAnnealing::anneal ( )
virtual

Implements AnnealingSchedule.

Definition at line 20 of file DeterministicAnnealing.cc.

References theIndex, theIsAnnealed, and theTemperatures.

21 {
22  if ( theIndex < ( theTemperatures.size() - 1 ) )
23  {
24  theIndex++;
25  } else {
26  theIsAnnealed = true;
27  };
28 }
std::vector< float > theTemperatures
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 63 of file DeterministicAnnealing.cc.

References theIndex, and theTemperatures.

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

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

Implements AnnealingSchedule.

Definition at line 58 of file DeterministicAnnealing.cc.

References mathSSE::sqrt(), and theChi2cut.

59 {
60  return sqrt(theChi2cut);
61 }
T sqrt(T t)
Definition: SSEVec.h:48
void DeterministicAnnealing::debug ( ) const
virtual

Implements AnnealingSchedule.

Definition at line 78 of file DeterministicAnnealing.cc.

References gather_cfg::cout, i, and theTemperatures.

79 {
80  cout << "[DeterministicAnnealing] schedule=";
81  for ( vector< float >::const_iterator i=theTemperatures.begin();
82  i!=theTemperatures.end() ; ++i )
83  {
84  cout << *i << " ";
85  };
86  cout << endl;
87 }
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121
std::vector< float > theTemperatures
double DeterministicAnnealing::initialTemp ( ) const
virtual

Implements AnnealingSchedule.

Definition at line 68 of file DeterministicAnnealing.cc.

References theTemperatures.

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

is it annealed yet?

Implements AnnealingSchedule.

Definition at line 73 of file DeterministicAnnealing.cc.

References theIsAnnealed.

74 {
75  return theIsAnnealed;
76 }
double DeterministicAnnealing::phi ( double  chi2) const
inlinevirtual

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

Implements AnnealingSchedule.

Definition at line 53 of file DeterministicAnnealing.cc.

References create_public_lumi_plots::exp, theIndex, and theTemperatures.

Referenced by weight().

54 {
55  return exp ( -.5 * chi2 / theTemperatures[theIndex] );
56 }
std::vector< float > theTemperatures
void DeterministicAnnealing::resetAnnealing ( )
virtual

Implements AnnealingSchedule.

Definition at line 47 of file DeterministicAnnealing.cc.

References theIndex, and theIsAnnealed.

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

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

Implements AnnealingSchedule.

Definition at line 30 of file DeterministicAnnealing.cc.

References CommonUtils::isinf(), phi(), and theChi2cut.

Referenced by cuy.ValElement::__init__(), cuy.additionElement::__init__(), cuy.superimposeElement::__init__(), and cuy.graphElement::__init__().

31 {
32  long double mphi = phi ( chi2 );
33  /*
34  if ( mphi < std::numeric_limits<double>::epsilon() ) return 0.;
35  return 1. / ( 1. + phi ( theChi2cut * theChi2cut ) / mphi );
36  */
37  // return mphi / ( mphi + phi ( theChi2cut ) );
38  long double newtmp = mphi / ( mphi + phi ( theChi2cut ) );
39  if ( std::isinf(newtmp ) )
40  {
41  if ( chi2 < theChi2cut ) newtmp=1.;
42  else newtmp=0.;
43  }
44  return newtmp;
45 }
bool isinf(T value)
Definition: CommonUtils.h:7
double phi(double chi2) const

Member Data Documentation

double DeterministicAnnealing::theChi2cut
private

Definition at line 59 of file DeterministicAnnealing.h.

Referenced by cutoff(), and weight().

unsigned int DeterministicAnnealing::theIndex
private

Definition at line 58 of file DeterministicAnnealing.h.

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

bool DeterministicAnnealing::theIsAnnealed
private

Definition at line 60 of file DeterministicAnnealing.h.

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

std::vector<float> DeterministicAnnealing::theTemperatures
private

Definition at line 54 of file DeterministicAnnealing.h.

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