9 #include <stdair/basic/BasConst_General.hpp>
10 #include <stdair/basic/BasConst_Inventory.hpp>
11 #include <stdair/bom/BomManager.hpp>
12 #include <stdair/bom/LegDate.hpp>
13 #include <stdair/bom/SegmentDate.hpp>
14 #include <stdair/bom/LegCabin.hpp>
15 #include <stdair/bom/SegmentCabin.hpp>
16 #include <stdair/bom/SegmentSnapshotTable.hpp>
17 #include <stdair/bom/FareFamily.hpp>
18 #include <stdair/bom/BookingClass.hpp>
19 #include <stdair/service/Logger.hpp>
31 forecast (stdair::SegmentCabin& ioSegmentCabin,
32 const stdair::Date_T& iCurrentDate,
33 const stdair::DTD_T& iCurrentDTD,
34 const stdair::UnconstrainingMethod& iUnconstrainingMethod,
35 const stdair::NbOfSegments_T& iNbOfDepartedSegments) {
37 const stdair::SegmentSnapshotTable& lSegmentSnapshotTable =
38 ioSegmentCabin.getSegmentSnapshotTable();
41 const stdair::FareFamilyList_T& lFFList =
42 stdair::BomManager::getList<stdair::FareFamily>(ioSegmentCabin);
43 stdair::FareFamilyList_T::const_reverse_iterator itFF = lFFList.rbegin();
44 assert (itFF != lFFList.rend());
45 stdair::FareFamily* lFF_ptr = *itFF;
46 assert (lFF_ptr != NULL);
47 const stdair::FRAT5Curve_T lFRAT5Curve = lFF_ptr->getFrat5Curve();
51 const stdair::BookingClassList_T& lBCList =
52 stdair::BomManager::getList<stdair::BookingClass>(ioSegmentCabin);
53 const stdair::BookingClassSellUpCurveMap_T lBCSellUpCurveMap =
55 const stdair::BookingClassDispatchingCurveMap_T lBCDispatchingCurveMap =
61 const stdair::DCPList_T lWholeDCPList = stdair::DEFAULT_DCP_LIST;
62 stdair::DCPList_T::const_iterator itDCP = lWholeDCPList.begin();
63 stdair::DCPList_T::const_iterator itNextDCP = itDCP; ++itNextDCP;
64 for (; itNextDCP != lWholeDCPList.end(); ++itDCP, ++itNextDCP) {
65 const stdair::DCP_T& lCurrentDCP = *itDCP;
66 const stdair::DCP_T& lNextDCP = *itNextDCP;
69 if (lNextDCP < iCurrentDTD) {
72 const stdair::NbOfSegments_T& lNbOfUsableSegments =
77 stdair::NbOfSegments_T lSegmentBegin = 0;
78 const stdair::NbOfSegments_T lSegmentEnd = lNbOfUsableSegments-1;
79 if (iNbOfDepartedSegments > 52) {
80 lSegmentBegin = iNbOfDepartedSegments - 52;
87 lSegmentSnapshotTable, lHBHolder,
88 lCurrentDCP, lNextDCP,
89 lSegmentBegin, lSegmentEnd,
97 stdair::UncDemVector_T lUncDemVector;
99 for (
short i = 0; i < lNbOfHistoricalFlights; ++i) {
100 const stdair::NbOfBookings_T& lUncDemand =
102 lUncDemVector.push_back (lUncDemand);
104 stdair::MeanValue_T lMean = 0.0;
105 stdair::StdDevValue_T lStdDev = 0.0;
111 lMean, lStdDev, lCurrentDCP);
116 lMean, lStdDev, lCurrentDCP);
119 const stdair::MeanValue_T& lCurrentMean = lFF_ptr->getMean();
120 const stdair::StdDevValue_T& lCurrentStdDev = lFF_ptr->getStdDev();
122 const stdair::MeanValue_T lNewMean = lCurrentMean + lMean;
123 const stdair::StdDevValue_T lNewStdDev =
124 std::sqrt (lCurrentStdDev * lCurrentStdDev + lStdDev * lStdDev);
126 lFF_ptr->setMean (lNewMean);
127 lFF_ptr->setStdDev (lNewStdDev);
136 (
const stdair::SegmentCabin& iSegmentCabin,
137 const stdair::SegmentSnapshotTable& iSegmentSnapshotTable,
139 const stdair::DCP_T& iDCPBegin,
const stdair::DCP_T& iDCPEnd,
140 const stdair::NbOfSegments_T& iSegmentBegin,
141 const stdair::NbOfSegments_T& iSegmentEnd,
142 const stdair::BookingClassSellUpCurveMap_T& iBCSellUpCurveMap) {
145 std::ostringstream lSCMapKey;
146 lSCMapKey << stdair::DEFAULT_SEGMENT_CABIN_VALUE_TYPE
147 << iSegmentCabin.describeKey();
148 const stdair::ClassIndex_T& lCabinIdx =
149 iSegmentSnapshotTable.getClassIndex (lSCMapKey.str());
152 const stdair::ConstSegmentCabinDTDRangeSnapshotView_T lBookingView =
153 iSegmentSnapshotTable.getConstSegmentCabinDTDRangePriceOrientedGrossBookingSnapshotView (iSegmentBegin, iSegmentEnd, iDCPEnd, iDCPBegin);
154 const stdair::ConstSegmentCabinDTDRangeSnapshotView_T lAvlView =
155 iSegmentSnapshotTable.getConstSegmentCabinDTDRangeAvailabilitySnapshotView (iSegmentBegin, iSegmentEnd, iDCPEnd, iDCPBegin);
158 const stdair::ClassIndexMap_T& lVTIdxMap =
159 iSegmentSnapshotTable.getClassIndexMap();
160 const stdair::NbOfClasses_T lNbOfClasses = lVTIdxMap.size();
162 for (
short i = 0; i <= iSegmentEnd-iSegmentBegin; ++i) {
163 stdair::Flag_T lCensorshipFlag =
false;
164 const short lNbOfDTDs = iDCPBegin - iDCPEnd + 1;
165 const stdair::UnsignedIndex_T lIdx = i*lNbOfClasses + lCabinIdx;
168 for (
short j = 0; j < lNbOfDTDs; ++j) {
172 if (lAvlView[lIdx][j] < 1.0) {
173 lCensorshipFlag =
true;
179 stdair::NbOfBookings_T lNbOfHistoricalBkgs = 0.0;
180 for (stdair::BookingClassSellUpCurveMap_T::const_iterator itBCSUC =
181 iBCSellUpCurveMap.begin();
182 itBCSUC != iBCSellUpCurveMap.end(); ++itBCSUC) {
183 const stdair::BookingClass* lBookingClass_ptr = itBCSUC->first;
184 assert (lBookingClass_ptr != NULL);
185 const stdair::SellUpCurve_T& lSellUpCurve = itBCSUC->second;
186 stdair::SellUpCurve_T::const_iterator itSellUp =
187 lSellUpCurve.find (iDCPBegin);
188 assert (itSellUp != lSellUpCurve.end());
189 const stdair::SellupProbability_T& lSellUp = itSellUp->second;
190 assert (lSellUp != 0);
193 const stdair::ClassIndex_T& lClassIdx =
194 iSegmentSnapshotTable.getClassIndex(lBookingClass_ptr->describeKey());
195 stdair::NbOfBookings_T lNbOfBookings = 0.0;
196 for (
short j = 0; j < lNbOfDTDs; ++j) {
197 lNbOfBookings += lBookingView[i*lNbOfClasses + lClassIdx][j];
200 const stdair::NbOfBookings_T lNbOfQEquivalentBkgs=lNbOfBookings/lSellUp;
201 lNbOfHistoricalBkgs += lNbOfQEquivalentBkgs;