1 #ifndef __TRADEMGEN_BAS_CONTINUOUSATTRIBUTELITE_HPP
2 #define __TRADEMGEN_BAS_CONTINUOUSATTRIBUTELITE_HPP
14 #include <stdair/stdair_basic_types.hpp>
39 const T
getValue(
const stdair::Probability_T& iCumulativeProbability)
const{
45 for (; idx < _size; ++idx) {
46 if (_cumulativeDistribution.at(idx) > lKey) {
52 return _valueArray.at(idx);
55 return _valueArray.at(idx-1);
59 const stdair::Probability_T& lCumulativeCurrentPoint =
61 const T& lValueCurrentPoint = _valueArray.at(idx);
64 const stdair::Probability_T& lCumulativePreviousPoint =
66 const T& lValuePreviousPoint = _valueArray.at(idx-1);
68 if (lCumulativePreviousPoint == lCumulativeCurrentPoint) {
69 return lValuePreviousPoint;
72 T oValue= lValuePreviousPoint + (lValueCurrentPoint - lValuePreviousPoint)
73 * (iCumulativeProbability - lCumulativePreviousPoint)
74 / (lCumulativeCurrentPoint - lCumulativePreviousPoint);
86 for (; idx < _size; ++idx) {
87 if (_valueArray.at(idx) > iKey) {
93 assert (idx != _size);
96 const stdair::Probability_T& lCumulativeCurrentPoint =
98 const T& lValueCurrentPoint = _valueArray.at(idx);
101 const stdair::Probability_T& lCumulativePreviousPoint =
103 const T& lValuePreviousPoint = _valueArray.at(idx-1);
105 assert (lValueCurrentPoint != lValuePreviousPoint);
107 const double oValue= (lCumulativeCurrentPoint - lCumulativePreviousPoint)
108 / (lValueCurrentPoint - lValuePreviousPoint);
118 unsigned int idx = 0;
119 for (; idx < _size; ++idx) {
120 if (_valueArray.at(idx) > iKey) {
125 assert (idx != _size);
127 return _valueArray.at (idx);
136 std::ostringstream oStr;
138 for (
unsigned int idx = 0; idx < _size; ++idx) {
143 const stdair::Probability_T& lProbability =
146 oStr << _valueArray.at(idx) <<
":" << lProbability;
158 : _size (iValueMap.size()) {
166 : _size (iCAL._size),
167 _cumulativeDistribution (iCAL._cumulativeDistribution),
168 _valueArray (iCAL._valueArray) {
176 _cumulativeDistribution = iCAL._cumulativeDistribution;
177 _valueArray = iCAL._valueArray;
200 const unsigned int lSize = iValueMap.size();
201 _cumulativeDistribution.reserve (lSize);
202 _valueArray.reserve (lSize);
205 for (
typename ContinuousDistribution_T::const_iterator it =
206 iValueMap.begin(); it != iValueMap.end(); ++it) {
208 const T& attributeValue = it->first;
212 _cumulativeDistribution.push_back (lKey);
213 _valueArray.push_back (attributeValue);
228 std::vector<DictionaryKey_T> _cumulativeDistribution;
233 std::vector<T> _valueArray;
237 #endif // __TRADEMGEN_BAS_CONTINUOUSATTRIBUTELITE_HPP