9 #include <stdair/basic/BasConst_General.hpp>
10 #include <stdair/basic/BasConst_Inventory.hpp>
11 #include <stdair/basic/RandomGeneration.hpp>
12 #include <stdair/bom/BomManager.hpp>
13 #include <stdair/bom/LegDate.hpp>
14 #include <stdair/bom/SegmentDate.hpp>
15 #include <stdair/bom/LegCabin.hpp>
16 #include <stdair/bom/SegmentCabin.hpp>
17 #include <stdair/bom/SegmentSnapshotTable.hpp>
18 #include <stdair/bom/BookingClass.hpp>
19 #include <stdair/service/Logger.hpp>
32 forecast (stdair::SegmentCabin& ioSegmentCabin,
33 const stdair::Date_T& iCurrentDate,
34 const stdair::DTD_T& iCurrentDTD,
35 const stdair::UnconstrainingMethod& iUnconstrainingMethod,
36 const stdair::NbOfSegments_T& iNbOfDepartedSegments) {
39 iUnconstrainingMethod, iNbOfDepartedSegments);
42 const stdair::SegmentSnapshotTable& lSegmentSnapshotTable =
43 ioSegmentCabin.getSegmentSnapshotTable();
46 const stdair::BookingClassList_T& lBCList =
47 stdair::BomManager::getList<stdair::BookingClass>(ioSegmentCabin);
51 const stdair::DCPList_T lWholeDCPList = stdair::DEFAULT_DCP_LIST;
52 stdair::DCPList_T::const_iterator itDCP = lWholeDCPList.begin();
53 stdair::DCPList_T::const_iterator itNextDCP = itDCP; ++itNextDCP;
54 for (; itNextDCP != lWholeDCPList.end(); ++itDCP, ++itNextDCP) {
55 const stdair::DCP_T& lCurrentDCP = *itDCP;
56 const stdair::DCP_T& lNextDCP = *itNextDCP;
59 if (lNextDCP < iCurrentDTD) {
62 const stdair::NbOfSegments_T& lNbOfUsableSegments =
67 stdair::NbOfSegments_T lSegmentBegin = 0;
68 const stdair::NbOfSegments_T lSegmentEnd = lNbOfUsableSegments-1;
69 if (iNbOfDepartedSegments > 52) {
70 lSegmentBegin = iNbOfDepartedSegments - 52;
75 for (stdair::BookingClassList_T::const_iterator itBC = lBCList.begin();
76 itBC != lBCList.end(); ++itBC) {
77 stdair::BookingClass* lBC_ptr = *itBC;
78 assert (lBC_ptr != NULL);
84 lSegmentSnapshotTable,
86 lCurrentDCP, lNextDCP,
87 lSegmentBegin, lSegmentEnd);
94 stdair::UncDemVector_T lUncDemVector;
96 for (
short i = 0; i < lNbOfHistoricalFlights; ++i) {
97 const stdair::NbOfBookings_T& lUncDemand =
99 lUncDemVector.push_back (lUncDemand);
101 stdair::MeanValue_T lMean = 0.0;
102 stdair::StdDevValue_T lStdDev = 0.0;
107 const stdair::MeanValue_T& lCurrentMean = lBC_ptr->getProductDemMean();
108 const stdair::StdDevValue_T& lCurrentStdDev =
109 lBC_ptr->getProductDemStdDev();
111 const stdair::MeanValue_T lNewMean = lCurrentMean + lMean;
112 const stdair::StdDevValue_T lNewStdDev =
113 std::sqrt (lCurrentStdDev * lCurrentStdDev + lStdDev * lStdDev);
115 lBC_ptr->setProductDemMean (lNewMean);
116 lBC_ptr->setProductDemStdDev (lNewStdDev);
125 (
const stdair::SegmentCabin& iSegmentCabin,
126 const stdair::BookingClass& iBookingClass,
127 const stdair::SegmentSnapshotTable& iSegmentSnapshotTable,
129 const stdair::DCP_T& iDCPBegin,
const stdair::DCP_T& iDCPEnd,
130 const stdair::NbOfSegments_T& iSegmentBegin,
131 const stdair::NbOfSegments_T& iSegmentEnd) {
134 const stdair::ClassIndex_T& lClassIdx =
135 iSegmentSnapshotTable.getClassIndex (iBookingClass.describeKey());
138 const stdair::ConstSegmentCabinDTDRangeSnapshotView_T lBookingView =
139 iSegmentSnapshotTable.getConstSegmentCabinDTDRangeProductOrientedGrossBookingSnapshotView (iSegmentBegin, iSegmentEnd, iDCPEnd, iDCPBegin);
140 const stdair::ConstSegmentCabinDTDRangeSnapshotView_T lAvlView =
141 iSegmentSnapshotTable.getConstSegmentCabinDTDRangeAvailabilitySnapshotView (iSegmentBegin, iSegmentEnd, iDCPEnd, iDCPBegin);
144 const stdair::ClassIndexMap_T& lVTIdxMap =
145 iSegmentSnapshotTable.getClassIndexMap();
146 const stdair::NbOfClasses_T lNbOfClasses = lVTIdxMap.size();
148 for (
short i = 0; i <= iSegmentEnd-iSegmentBegin; ++i) {
149 stdair::Flag_T lCensorshipFlag =
false;
150 const short lNbOfDTDs = iDCPBegin - iDCPEnd + 1;
151 const stdair::UnsignedIndex_T lIdx = i*lNbOfClasses + lClassIdx;
154 for (
short j = 0; j < lNbOfDTDs; ++j) {
158 if (lAvlView[lIdx][j] < 1.0) {
159 lCensorshipFlag =
true;
165 stdair::NbOfBookings_T lNbOfHistoricalBkgs = 0.0;
166 for (
short j = 0; j < lNbOfDTDs; ++j) {
167 lNbOfHistoricalBkgs += lBookingView[lIdx][j];