Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Standard header files go here
#include "Examples/pbarpToOmegaPiLS/GOmegaPiIndividualLS.hh"
BOOST_CLASS_EXPORT_IMPLEMENT(Gem::Pawian::GOmegaPiIndividualLS)
namespace Gem
{
namespace Pawian
{
/********************************************************************************************/
/**
* A constructor that initializes the object with a likelihood calculator
*
* @param theLh The likelihood calculator
*/
GOmegaPiIndividualLS::GOmegaPiIndividualLS(boost::shared_ptr<AbsOmegaPiLhLS> theLh)
: GParameterSet()
,_omegaPiLhPtr( theLh->clone_() )
{
// Set up a GConstrainedDoubleObjectCollection
boost::shared_ptr<Gem::Geneva::GConstrainedDoubleObjectCollection> gbdc_ptr(new Gem::Geneva::GConstrainedDoubleObjectCollection());
_omegaPiLhPtr->setGenevaFitParamVal( gbdc_ptr );
for(std::size_t i=0; i<gbdc_ptr->size(); i++) {
// Create a suitable adaptor (sigma=0.1, sigma-adaption=0.5, min sigma=0, max sigma=0,5)
boost::shared_ptr<Gem::Geneva::GDoubleGaussAdaptor> gdga_ptr(new Gem::Geneva::GDoubleGaussAdaptor(0.1, 0.5, 0., 0.5));
gdga_ptr->setAdaptionThreshold(1); // Adaption parameters are modified after each adaption
gdga_ptr->setAdaptionProbability(0.2); // The likelihood for a parameter to be adapted
// Register the adaptor with GConstrainedDoubleObject objects
gbdc_ptr->at(i)->addAdaptor(gdga_ptr);
}
// Add the collection to this object
this->push_back(gbdc_ptr);
}
/********************************************************************************************/
/**
* A standard copy constructor
*
* @param cp A copy of another GOmegaPiIndividualLS
*/
GOmegaPiIndividualLS::GOmegaPiIndividualLS(const GOmegaPiIndividualLS& cp)
: GParameterSet(cp)
, _omegaPiLhPtr( cp._omegaPiLhPtr?boost::shared_ptr<AbsOmegaPiLhLS>((cp._omegaPiLhPtr)->clone_()):boost::shared_ptr<AbsOmegaPiLhLS>() )
{ /* nothing */ }
/********************************************************************************************/
/**
* The standard destructor
*/
GOmegaPiIndividualLS::~GOmegaPiIndividualLS()
{ /* nothing */ }
/********************************************************************************************/
/**
* Loads user-specified data
*/
void GOmegaPiIndividualLS::loadConstantData(boost::shared_ptr<GObject> cD_ptr) {
// Convert GObject smart pointer to local format
boost::shared_ptr<GOmegaPiIndividualLS> p_load = GObject::conversion_cast<GOmegaPiIndividualLS>(cD_ptr);
// Load the static data from the data model
if(p_load->omegaPiLhPtr()) {
_omegaPiLhPtr = boost::shared_ptr<AbsOmegaPiLhLS>(p_load->omegaPiLhPtr()->clone_());
}
}
/********************************************************************************************/
boost::shared_ptr<AbsOmegaPiLhLS> GOmegaPiIndividualLS::omegaPiLhPtr() const {
return _omegaPiLhPtr;
}
/********************************************************************************************/
/**
* A standard assignment operator
*
* @param cp A copy of another GOmegaPiIndividualLS object
* @return A constant reference to this object
*/
const GOmegaPiIndividualLS& GOmegaPiIndividualLS::operator=(const GOmegaPiIndividualLS& cp) {
GOmegaPiIndividualLS::load_(&cp);
return *this;
}
/********************************************************************************************/
/**
* Retrieval of fit parameters
*/
bool GOmegaPiIndividualLS::getFitParams(OmegaPiDataLS::fitParamVal& fitParmVal) {
std::vector<double> theParms;
// Extract the GDoubleCollection object. In a realistic scenario, you might want
// to add error checks here upon first invocation.
boost::shared_ptr<Gem::Geneva::GConstrainedDoubleObjectCollection> vC = at<Gem::Geneva::GConstrainedDoubleObjectCollection>(0);
std::vector<double> par;
for(std::size_t i=0; i<vC->size(); i++){
double value = vC->at(i)->value();
par.push_back(value);
}
_omegaPiLhPtr->getFitParamVal(fitParmVal, par);
return true;
}
/********************************************************************************************/
/*
* Printing of fit-parameters
*/
void GOmegaPiIndividualLS::printFitParams(OmegaPiDataLS::fitParamVal& fitParmVal) {
_omegaPiLhPtr->printFitParams(std::cout, fitParmVal);
std::cout << std::endl;
return;
}
/********************************************************************************************/
/**
* Loads the data of another GOmegaPiIndividualLS, camouflaged as a GObject.
*
* @param cp A copy of another GOmegaPiIndividualLS, camouflaged as a GObject
*/
void GOmegaPiIndividualLS::load_(const Gem::Geneva::GObject* cp)
{
// Check that we are not accidently assigning this object to itself
selfAssignmentCheck<GOmegaPiIndividualLS>(cp);
// Load our parent's data
GParameterSet::load_(cp);
// Note: We do not need to load _omegaPiLhPtr here, as it has been initialized during
// the construction of this object already.
}
/********************************************************************************************/
/**
* Creates a deep clone of this object
*
* @return A deep clone of this object, camouflaged as a GObject
*/
Gem::Geneva::GObject* GOmegaPiIndividualLS::clone_() const {
return new GOmegaPiIndividualLS(*this);
}
/********************************************************************************************/
/**
* The actual fitness calculation takes place here.
*
* @return The value of this object
*/
double GOmegaPiIndividualLS::fitnessCalculation(){
double result = 0.;
OmegaPiDataLS::fitParamVal theFitParmValTmp;
bool fitParamsSet=getFitParams(theFitParmValTmp);
if (!fitParamsSet){
std::cout << "fit parameters could not set properly " << std::endl;
exit(0);
}
result=_omegaPiLhPtr->calcLogLh(theFitParmValTmp);
// std::cout << "**** current fit params ***** " << std::endl;
// printFitParams(theFitParmValTmp);
// std::cout << std::endl;
return result;
}
/********************************************************************************************/
/**
* The default constructor. Intentionally private and empty, as it is only needed for
* serialization purposes.
*/
GOmegaPiIndividualLS::GOmegaPiIndividualLS() :GParameterSet()
{ /* nothing */ }
/********************************************************************************************/
} /* namespace Pawian */
} /* namespace Gem */