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>
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) {
38 const stdair::SegmentSnapshotTable& lSegmentSnapshotTable =
39 ioSegmentCabin.getSegmentSnapshotTable();
42 const stdair::BookingClassList_T& lBCList =
43 stdair::BomManager::getList<stdair::BookingClass>(ioSegmentCabin);
47 const stdair::DCPList_T lWholeDCPList = stdair::DEFAULT_DCP_LIST;
48 stdair::DCPList_T::const_iterator itDCP = lWholeDCPList.begin();
49 stdair::DCPList_T::const_iterator itNextDCP = itDCP; ++itNextDCP;
50 for (; itNextDCP != lWholeDCPList.end(); ++itDCP, ++itNextDCP) {
51 const stdair::DCP_T& lCurrentDCP = *itDCP;
52 const stdair::DCP_T& lNextDCP = *itNextDCP;
55 if (lNextDCP < iCurrentDTD) {
58 const stdair::NbOfSegments_T& lNbOfUsableSegments =
63 stdair::NbOfSegments_T lSegmentBegin = 0;
64 const stdair::NbOfSegments_T lSegmentEnd = lNbOfUsableSegments-1;
65 if (iNbOfDepartedSegments > 52) {
66 lSegmentBegin = iNbOfDepartedSegments - 52;
71 for (stdair::BookingClassList_T::const_iterator itBC = lBCList.begin();
72 itBC != lBCList.end(); ++itBC) {
73 stdair::BookingClass* lBC_ptr = *itBC;
74 assert (lBC_ptr != NULL);
80 lSegmentSnapshotTable,
82 lCurrentDCP, lNextDCP,
83 lSegmentBegin, lSegmentEnd);
90 stdair::UncDemVector_T lUncDemVector;
92 for (
short i = 0; i < lNbOfHistoricalFlights; ++i) {
93 const stdair::NbOfBookings_T& lUncDemand =
95 lUncDemVector.push_back (lUncDemand);
97 stdair::MeanValue_T lMean = 0.0;
98 stdair::StdDevValue_T lStdDev = 0.0;
103 const stdair::MeanValue_T& lCurrentMean = lBC_ptr->getProductDemMean();
104 const stdair::StdDevValue_T& lCurrentStdDev =
105 lBC_ptr->getProductDemStdDev();
107 const stdair::MeanValue_T lNewMean = lCurrentMean + lMean;
108 const stdair::StdDevValue_T lNewStdDev =
109 std::sqrt (lCurrentStdDev * lCurrentStdDev + lStdDev * lStdDev);
111 lBC_ptr->setProductDemMean (lNewMean);
112 lBC_ptr->setProductDemStdDev (lNewStdDev);
121 (
const stdair::SegmentCabin& iSegmentCabin,
122 const stdair::BookingClass& iBookingClass,
123 const stdair::SegmentSnapshotTable& iSegmentSnapshotTable,
125 const stdair::DCP_T& iDCPBegin,
const stdair::DCP_T& iDCPEnd,
126 const stdair::NbOfSegments_T& iSegmentBegin,
127 const stdair::NbOfSegments_T& iSegmentEnd) {
130 const stdair::ClassIndex_T& lClassIdx =
131 iSegmentSnapshotTable.getClassIndex (iBookingClass.describeKey());
134 const stdair::ConstSegmentCabinDTDRangeSnapshotView_T lPriceBookingView =
135 iSegmentSnapshotTable.getConstSegmentCabinDTDRangePriceOrientedGrossBookingSnapshotView (iSegmentBegin, iSegmentEnd, iDCPEnd, iDCPBegin);
136 const stdair::ConstSegmentCabinDTDRangeSnapshotView_T lProductBookingView =
137 iSegmentSnapshotTable.getConstSegmentCabinDTDRangeProductOrientedGrossBookingSnapshotView (iSegmentBegin, iSegmentEnd, iDCPEnd, iDCPBegin);
138 const stdair::ConstSegmentCabinDTDRangeSnapshotView_T lAvlView =
139 iSegmentSnapshotTable.getConstSegmentCabinDTDRangeAvailabilitySnapshotView (iSegmentBegin, iSegmentEnd, iDCPEnd, iDCPBegin);
142 const stdair::ClassIndexMap_T& lVTIdxMap =
143 iSegmentSnapshotTable.getClassIndexMap();
144 const stdair::NbOfClasses_T lNbOfClasses = lVTIdxMap.size();
146 for (
short i = 0; i <= iSegmentEnd-iSegmentBegin; ++i) {
147 stdair::Flag_T lCensorshipFlag =
false;
148 const short lNbOfDTDs = iDCPBegin - iDCPEnd + 1;
149 const stdair::UnsignedIndex_T lIdx = i*lNbOfClasses + lClassIdx;
152 for (
short j = 0; j < lNbOfDTDs; ++j) {
156 if (lAvlView[lIdx][j] < 1.0) {
157 lCensorshipFlag =
true;
163 stdair::NbOfBookings_T lNbOfHistoricalBkgs = 0.0;
164 for (
short j = 0; j < lNbOfDTDs; ++j) {
165 lNbOfHistoricalBkgs +=
166 lPriceBookingView[lIdx][j] + lProductBookingView[lIdx][j];