7 #include <boost/make_shared.hpp>
9 #include <stdair/stdair_inventory_types.hpp>
10 #include <stdair/basic/BasChronometer.hpp>
11 #include <stdair/basic/ContinuousAttributeLite.hpp>
12 #include <stdair/bom/BomManager.hpp>
13 #include <stdair/bom/BomRetriever.hpp>
14 #include <stdair/bom/BomRoot.hpp>
15 #include <stdair/bom/Inventory.hpp>
16 #include <stdair/bom/FlightDate.hpp>
17 #include <stdair/bom/LegCabin.hpp>
18 #include <stdair/bom/LegDate.hpp>
19 #include <stdair/bom/YieldFeatures.hpp>
20 #include <stdair/bom/AirportPair.hpp>
21 #include <stdair/bom/PosChannel.hpp>
22 #include <stdair/bom/DatePeriod.hpp>
23 #include <stdair/bom/TimePeriod.hpp>
24 #include <stdair/bom/AirlineClassList.hpp>
25 #include <stdair/basic/BasConst_Request.hpp>
26 #include <stdair/basic/BasConst_Inventory.hpp>
27 #include <stdair/bom/Inventory.hpp>
28 #include <stdair/bom/FlightDate.hpp>
29 #include <stdair/bom/SegmentDate.hpp>
30 #include <stdair/bom/SegmentCabin.hpp>
31 #include <stdair/bom/BookingClass.hpp>
32 #include <stdair/bom/OnDDate.hpp>
33 #include <stdair/bom/OnDDateTypes.hpp>
34 #include <stdair/command/CmdBomManager.hpp>
35 #include <stdair/service/Logger.hpp>
36 #include <stdair/STDAIR_Service.hpp>
50 RMOL_Service::RMOL_Service()
51 : _rmolServiceContext (NULL),
52 _previousForecastDate (stdair::Date_T (2000, 1, 1)) {
57 RMOL_Service::RMOL_Service (
const RMOL_Service& iService) :
58 _rmolServiceContext (NULL),
59 _previousForecastDate (stdair::Date_T (2000, 1, 1)) {
64 RMOL_Service::RMOL_Service (
const stdair::BasLogParams& iLogParams) :
65 _rmolServiceContext (NULL),
66 _previousForecastDate (stdair::Date_T (2000, 1, 1)) {
69 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
70 initStdAirService (iLogParams);
77 const bool ownStdairService =
true;
78 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
85 RMOL_Service::RMOL_Service (
const stdair::BasLogParams& iLogParams,
86 const stdair::BasDBParams& iDBParams) :
87 _rmolServiceContext (NULL),
88 _previousForecastDate (stdair::Date_T (2000, 1, 1)) {
91 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
92 initStdAirService (iLogParams, iDBParams);
99 const bool ownStdairService =
true;
100 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
107 RMOL_Service::RMOL_Service (stdair::STDAIR_ServicePtr_T ioSTDAIRServicePtr)
108 : _rmolServiceContext (NULL),
109 _previousForecastDate (stdair::Date_T (2000, 1, 1)) {
112 initServiceContext();
116 const bool doesNotOwnStdairService =
false;
117 addStdAirService (ioSTDAIRServicePtr, doesNotOwnStdairService);
130 void RMOL_Service::finalise() {
131 assert (_rmolServiceContext != NULL);
133 _rmolServiceContext->reset();
137 void RMOL_Service::initServiceContext() {
139 RMOL_ServiceContext& lRMOL_ServiceContext =
141 _rmolServiceContext = &lRMOL_ServiceContext;
146 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
147 const bool iOwnStdairService) {
150 assert (_rmolServiceContext != NULL);
151 RMOL_ServiceContext& lRMOL_ServiceContext = *_rmolServiceContext;
154 lRMOL_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
159 stdair::STDAIR_ServicePtr_T RMOL_Service::
160 initStdAirService (
const stdair::BasLogParams& iLogParams) {
169 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
170 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
172 return lSTDAIR_Service_ptr;
176 stdair::STDAIR_ServicePtr_T RMOL_Service::
177 initStdAirService (
const stdair::BasLogParams& iLogParams,
178 const stdair::BasDBParams& iDBParams) {
187 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
188 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
190 return lSTDAIR_Service_ptr;
194 void RMOL_Service::initRmolService() {
202 const stdair::Filename_T& iInputFileName) {
205 if (_rmolServiceContext == NULL) {
206 throw stdair::NonInitialisedServiceException (
"The RMOL service has not"
207 " been initialised");
209 assert (_rmolServiceContext != NULL);
211 const bool doesOwnStdairService =
212 lRMOL_ServiceContext.getOwnStdairServiceFlag();
215 stdair::STDAIR_Service& lSTDAIR_Service =
216 lRMOL_ServiceContext.getSTDAIR_Service();
217 stdair::BomRoot& lPersistentBomRoot =
218 lSTDAIR_Service.getPersistentBomRoot();
223 lSTDAIR_Service.buildDummyInventory (iCabinCapacity);
252 if (doesOwnStdairService ==
true) {
263 if (_rmolServiceContext == NULL) {
264 throw stdair::NonInitialisedServiceException (
"The RMOL service has not"
265 " been initialised");
267 assert (_rmolServiceContext != NULL);
272 const bool doesOwnStdairService =
273 lRMOL_ServiceContext.getOwnStdairServiceFlag();
276 stdair::STDAIR_Service& lSTDAIR_Service =
277 lRMOL_ServiceContext.getSTDAIR_Service();
278 stdair::BomRoot& lPersistentBomRoot =
279 lSTDAIR_Service.getPersistentBomRoot();
285 if (doesOwnStdairService ==
true) {
287 lSTDAIR_Service.buildSampleBom();
311 if (doesOwnStdairService ==
true) {
322 if (_rmolServiceContext == NULL) {
323 throw stdair::NonInitialisedServiceException(
"The RMOL service has not "
326 assert (_rmolServiceContext != NULL);
331 const bool doesOwnStdairService =
332 lRMOL_ServiceContext.getOwnStdairServiceFlag();
335 stdair::STDAIR_Service& lSTDAIR_Service =
336 lRMOL_ServiceContext.getSTDAIR_Service();
342 if (doesOwnStdairService ==
true) {
345 lSTDAIR_Service.clonePersistentBom ();
351 stdair::BomRoot& lBomRoot =
352 lSTDAIR_Service.getBomRoot();
360 if (_rmolServiceContext == NULL) {
361 throw stdair::NonInitialisedServiceException(
"The RMOL service has not "
364 assert (_rmolServiceContext != NULL);
371 stdair::STDAIR_Service& lSTDAIR_Service =
372 lRMOL_ServiceContext.getSTDAIR_Service();
378 lSTDAIR_Service.buildDummyLegSegmentAccesses (ioBomRoot);
383 assert (_rmolServiceContext != NULL);
387 stdair::STDAIR_Service& lSTDAIR_Service =
388 lRMOL_ServiceContext.getSTDAIR_Service();
393 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getPersistentBomRoot();
396 stdair::LegCabin& lLegCabin =
397 stdair::BomRetriever::retrieveDummyLegCabin (lBomRoot);
399 stdair::BasChronometer lOptimisationChronometer;
400 lOptimisationChronometer.start();
404 const double lOptimisationMeasure = lOptimisationChronometer.elapsed();
407 STDAIR_LOG_DEBUG (
"Optimisation by Monte-Carlo performed in "
408 << lOptimisationMeasure);
409 STDAIR_LOG_DEBUG (
"Result: " << lLegCabin.displayVirtualClassList());
411 std::ostringstream logStream;
412 stdair::BidPriceVector_T lBidPriceVector = lLegCabin.getBidPriceVector();
413 logStream <<
"Bid-Price Vector (BPV): ";
414 const unsigned int size = lBidPriceVector.size();
416 for (
unsigned int i = 0; i < size - 1; ++i) {
417 const double bidPrice = lBidPriceVector.at(i);
418 logStream << std::fixed << std::setprecision (2) << bidPrice <<
", ";
420 const double bidPrice = lBidPriceVector.at(size -1);
421 logStream << std::fixed << std::setprecision (2) << bidPrice;
422 STDAIR_LOG_DEBUG (logStream.str());
431 assert (_rmolServiceContext != NULL);
435 stdair::STDAIR_Service& lSTDAIR_Service =
436 lRMOL_ServiceContext.getSTDAIR_Service();
441 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getPersistentBomRoot();
444 stdair::LegCabin& lLegCabin =
445 stdair::BomRetriever::retrieveDummyLegCabin (lBomRoot);
447 stdair::BasChronometer lOptimisationChronometer;
448 lOptimisationChronometer.start();
452 const double lOptimisationMeasure = lOptimisationChronometer.elapsed();
454 STDAIR_LOG_DEBUG (
"Optimisation EMSR performed in "
455 << lOptimisationMeasure);
456 STDAIR_LOG_DEBUG (
"Result: " << lLegCabin.displayVirtualClassList());
458 stdair::BidPriceVector_T lBidPriceVector = lLegCabin.getBidPriceVector();
459 std::ostringstream logStream;
460 logStream <<
"Bid-Price Vector (BPV): ";
461 stdair::UnsignedIndex_T idx = 0;
462 for (stdair::BidPriceVector_T::const_iterator itBP = lBidPriceVector.begin();
463 itBP != lBidPriceVector.end(); ++itBP) {
467 const stdair::BidPrice_T& lBidPrice = *itBP;
468 logStream << std::fixed << std::setprecision (2) << lBidPrice;
471 STDAIR_LOG_DEBUG (logStream.str());
476 assert (_rmolServiceContext != NULL);
480 stdair::STDAIR_Service& lSTDAIR_Service =
481 lRMOL_ServiceContext.getSTDAIR_Service();
486 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getPersistentBomRoot();
489 stdair::LegCabin& lLegCabin =
490 stdair::BomRetriever::retrieveDummyLegCabin (lBomRoot);
495 STDAIR_LOG_DEBUG (
"Result: " << lLegCabin.displayVirtualClassList());
501 assert (_rmolServiceContext != NULL);
505 stdair::STDAIR_Service& lSTDAIR_Service =
506 lRMOL_ServiceContext.getSTDAIR_Service();
511 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getPersistentBomRoot();
514 stdair::LegCabin& lLegCabin =
515 stdair::BomRetriever::retrieveDummyLegCabin (lBomRoot);
520 STDAIR_LOG_DEBUG (
"Result: " << lLegCabin.displayVirtualClassList());
526 assert (_rmolServiceContext != NULL);
530 stdair::STDAIR_Service& lSTDAIR_Service =
531 lRMOL_ServiceContext.getSTDAIR_Service();
536 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getPersistentBomRoot();
538 const stdair::SegmentCabin& lSegmentCabin =
541 return lSegmentCabin;
548 const stdair::DateTime_T& iRMEventTime,
549 const stdair::UnconstrainingMethod& iUnconstrainingMethod,
550 const stdair::ForecastingMethod& iForecastingMethod,
551 const stdair::PreOptimisationMethod& iPreOptimisationMethod,
552 const stdair::OptimisationMethod& iOptimisationMethod,
553 const stdair::PartnershipTechnique& iPartnershipTechnique) {
556 STDAIR_LOG_DEBUG (
"Forecast & Optimisation");
558 const stdair::PartnershipTechnique::EN_PartnershipTechnique& lPartnershipTechnique =
559 iPartnershipTechnique.getTechnique();
561 switch (lPartnershipTechnique) {
562 case stdair::PartnershipTechnique::NONE:{
564 STDAIR_LOG_DEBUG (
"Forecast");
569 iUnconstrainingMethod,
572 STDAIR_LOG_DEBUG (
"Forecast successful: " << isForecasted);
574 if (isForecasted ==
true) {
577 STDAIR_LOG_DEBUG (
"Pre-optimise");
579 const bool isPreOptimised =
583 STDAIR_LOG_DEBUG (
"Pre-Optimise successful: " << isPreOptimised);
585 if (isPreOptimised ==
true) {
588 STDAIR_LOG_DEBUG (
"Optimise");
589 const bool optimiseSucceeded =
592 STDAIR_LOG_DEBUG (
"Optimise successful: " << optimiseSucceeded);
593 return optimiseSucceeded ;
598 case stdair::PartnershipTechnique::RAE_DA:
599 case stdair::PartnershipTechnique::IBP_DA:{
600 if (_previousForecastDate < iRMEventTime.date()) {
608 case stdair::PartnershipTechnique::RAE_YP:
609 case stdair::PartnershipTechnique::IBP_YP:
610 case stdair::PartnershipTechnique::IBP_YP_U:{
611 if (_previousForecastDate < iRMEventTime.date()) {
619 case stdair::PartnershipTechnique::RMC:{
620 if (_previousForecastDate < iRMEventTime.date()) {
629 case stdair::PartnershipTechnique::A_RMC:{
630 if (_previousForecastDate < iRMEventTime.date()) {
650 if (_rmolServiceContext == NULL) {
651 throw stdair::NonInitialisedServiceException (
"The Rmol service "
652 "has not been initialised");
654 assert (_rmolServiceContext != NULL);
658 stdair::STDAIR_Service& lSTDAIR_Service =
659 lRMOL_ServiceContext.getSTDAIR_Service();
660 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
663 const stdair::Date_T lDate = iRMEventTime.date();
665 _previousForecastDate = lDate;
667 const stdair::InventoryList_T& lInventoryList =
668 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
669 assert (!lInventoryList.empty());
670 for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
671 itInv != lInventoryList.end(); ++itInv) {
672 const stdair::Inventory* lInventory_ptr = *itInv;
673 assert (lInventory_ptr != NULL);
674 const bool hasOnDDateList =
675 stdair::BomManager::hasList<stdair::OnDDate> (*lInventory_ptr);
676 if (hasOnDDateList ==
true) {
677 const stdair::OnDDateList_T lOnDDateList =
678 stdair::BomManager::getList<stdair::OnDDate> (*lInventory_ptr);
680 for (stdair::OnDDateList_T::const_iterator itOD = lOnDDateList.begin();
681 itOD != lOnDDateList.end(); ++itOD) {
682 stdair::OnDDate* lOnDDate_ptr = *itOD;
683 assert (lOnDDate_ptr != NULL);
685 const stdair::Date_T& lDepartureDate = lOnDDate_ptr->getDate();
686 stdair::DateOffset_T lDateOffset = lDepartureDate - lDate;
687 stdair::DTD_T lDTD = short (lDateOffset.days());
689 stdair::DCPList_T::const_iterator itDCP =
690 std::find (stdair::DEFAULT_DCP_LIST.begin(),
691 stdair::DEFAULT_DCP_LIST.end(), lDTD);
693 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
695 const stdair::CabinForecastMap_T& lTotalForecastMap =
696 lOnDDate_ptr->getTotalForecastMap();
699 for (stdair::CabinForecastMap_T::const_iterator itCF =
700 lTotalForecastMap.begin();
701 itCF != lTotalForecastMap.end(); ++itCF) {
702 const stdair::CabinCode_T lCabinCode = itCF->first;
703 stdair::YieldFeatures* lYieldFeatures_ptr =
705 if (lYieldFeatures_ptr == NULL) {
706 STDAIR_LOG_ERROR (
"Cannot find yield corresponding to "
708 << lOnDDate_ptr->toString()
709 <<
" Cabin " << lCabinCode);
712 forecastOnD (*lYieldFeatures_ptr, *lOnDDate_ptr, lCabinCode, lDTD,
724 const stdair::CabinCode_T& iCabinCode,
725 stdair::BomRoot& iBomRoot) {
727 const stdair::AirportCode_T& lOrigin = iOnDDate.getOrigin();
728 const stdair::AirportCode_T& lDestination = iOnDDate.getDestination();
730 const stdair::Date_T& lDepartureDate = iOnDDate.getDate();
733 const stdair::AirportPairKey lAirportPairKey(lOrigin, lDestination);
734 stdair::AirportPair* lAirportPair_ptr = stdair::BomManager::
735 getObjectPtr<stdair::AirportPair> (iBomRoot,
736 lAirportPairKey.toString());
737 if (lAirportPair_ptr == NULL) {
738 STDAIR_LOG_ERROR (
"Cannot find yield corresponding to the airport "
739 <<
"pair: " << lAirportPairKey.toString());
744 const stdair::DatePeriodList_T lDatePeriodList =
745 stdair::BomManager::getList<stdair::DatePeriod> (*lAirportPair_ptr);
746 for (stdair::DatePeriodList_T::const_iterator itDatePeriod =
747 lDatePeriodList.begin();
748 itDatePeriod != lDatePeriodList.end(); ++itDatePeriod) {
749 const stdair::DatePeriod* lDatePeriod_ptr = *itDatePeriod;
750 assert (lDatePeriod_ptr != NULL);
752 const bool isDepartureDateValid =
753 lDatePeriod_ptr->isDepartureDateValid (lDepartureDate);
755 if (isDepartureDateValid ==
true) {
758 const stdair::PosChannelKey lPosChannelKey (stdair::DEFAULT_POS,
759 stdair::DEFAULT_CHANNEL);
760 stdair::PosChannel* lPosChannel_ptr = stdair::BomManager::
761 getObjectPtr<stdair::PosChannel> (*lDatePeriod_ptr,
762 lPosChannelKey.toString());
763 if (lPosChannel_ptr == NULL) {
764 STDAIR_LOG_ERROR (
"Cannot find yield corresponding to the PoS-"
765 <<
"Channel: " << lPosChannelKey.toString());
769 const stdair::TimePeriodList_T lTimePeriodList = stdair::
770 BomManager::getList<stdair::TimePeriod> (*lPosChannel_ptr);
771 for (stdair::TimePeriodList_T::const_iterator itTimePeriod =
772 lTimePeriodList.begin();
773 itTimePeriod != lTimePeriodList.end(); ++itTimePeriod) {
774 const stdair::TimePeriod* lTimePeriod_ptr = *itTimePeriod;
775 assert (lTimePeriod_ptr != NULL);
778 const stdair::YieldFeaturesKey lYieldFeaturesKey (stdair::TRIP_TYPE_ONE_WAY,
780 stdair::YieldFeatures* oYieldFeatures_ptr = stdair::BomManager::
781 getObjectPtr<stdair::YieldFeatures>(*lTimePeriod_ptr,
782 lYieldFeaturesKey.toString());
783 if (oYieldFeatures_ptr != NULL) {
784 return oYieldFeatures_ptr;
797 stdair::OnDDate& iOnDDate,
798 const stdair::CabinCode_T& iCabinCode,
799 const stdair::DTD_T& iDTD,
800 stdair::BomRoot& iBomRoot) {
802 const stdair::AirlineClassListList_T lAirlineClassListList =
803 stdair::BomManager::getList<stdair::AirlineClassList> (iYieldFeatures);
804 assert (lAirlineClassListList.begin() != lAirlineClassListList.end());
807 stdair::AirlineClassListList_T::const_iterator itACL =
808 lAirlineClassListList.begin();
809 stdair::Yield_T lPreviousYield((*itACL)->getYield());
811 for (; itACL != lAirlineClassListList.end(); ++itACL) {
812 const stdair::AirlineClassList* lAirlineClassList = *itACL;
813 const stdair::Yield_T& lYield = lAirlineClassList->getYield();
814 if (lYield <= lPreviousYield) {
815 lPreviousYield = lYield;
818 STDAIR_LOG_ERROR (
"Yields should be given in a descendant order"
819 <<
" in the yield input file") ;
825 stdair::ProportionFactorList_T lProportionFactorList;
826 stdair::ProportionFactor_T lPreviousProportionFactor = 0;
829 const stdair::WTPDemandPair_T& lTotalForecast =
830 iOnDDate.getTotalForecast (iCabinCode);
831 const stdair::WTP_T& lMinWTP = lTotalForecast.first;
834 const stdair::ContinuousAttributeLite<stdair::FloatDuration_T>
835 lArrivalPattern (stdair::DEFAULT_DTD_PROB_MAP);
837 STDAIR_LOG_DEBUG (lArrivalPattern.displayCumulativeDistribution());
838 const stdair::Probability_T lRemainingProportion =
839 lArrivalPattern.getRemainingProportion(-
float(iDTD));
843 const stdair::MeanStdDevPair_T lForecatsMeanStdDevPair =
844 lTotalForecast.second;
845 const stdair::MeanValue_T& lMeanValue =
846 lForecatsMeanStdDevPair.first;
847 const stdair::MeanValue_T& lRemainingMeanValue =
848 lRemainingProportion*lMeanValue;
849 const stdair::StdDevValue_T& lStdDevValue =
850 lForecatsMeanStdDevPair.second;
851 const stdair::StdDevValue_T& lRemainingStdDevValue =
852 lRemainingProportion*lStdDevValue;
855 stdair::DTDFratMap_T::const_iterator itDFC =
856 stdair::DEFAULT_DTD_FRAT5COEF_MAP.find(iDTD);
857 if (itDFC == stdair::DEFAULT_DTD_FRAT5COEF_MAP.end()) {
858 STDAIR_LOG_ERROR (
"Cannot find frat5 coef for DTD = " << iDTD );
861 stdair::RealNumber_T lFrat5Coef =
862 stdair::DEFAULT_DTD_FRAT5COEF_MAP.at(iDTD);
864 STDAIR_LOG_DEBUG (
"Remaining proportion " << lRemainingProportion
865 <<
" Total " << lMeanValue
866 <<
" StdDev " << lStdDevValue
867 <<
"Frat5 Coef " << lFrat5Coef);
869 std::ostringstream oStr;
871 itACL = lAirlineClassListList.begin();
872 for (; itACL != lAirlineClassListList.end(); ++itACL) {
873 const stdair::AirlineClassList* lAirlineClassList_ptr = *itACL;
874 const stdair::Yield_T& lYield = lAirlineClassList_ptr->getYield();
875 stdair::ProportionFactor_T lProportionFactor =
876 exp ((lYield - lMinWTP)*log(0.5)/(lMinWTP*(lFrat5Coef-1.0)));
879 lProportionFactor = std::min (lProportionFactor, 1.0);
880 lProportionFactorList.push_back(lProportionFactor - lPreviousProportionFactor);
881 lPreviousProportionFactor = lProportionFactor;
882 oStr << lAirlineClassList_ptr->toString() << lProportionFactor <<
" ";
885 STDAIR_LOG_DEBUG (oStr.str());
888 assert (lAirlineClassListList.size() == lProportionFactorList.size());
890 STDAIR_LOG_DEBUG (
"Forecast for " << iOnDDate.describeKey()
891 <<
" " << iDTD <<
" days to departure");
894 stdair::ProportionFactorList_T::const_iterator itPF =
895 lProportionFactorList.begin();
896 itACL = lAirlineClassListList.begin();
897 for (; itACL != lAirlineClassListList.end(); ++itACL, ++itPF) {
898 const stdair::AirlineClassList* lAirlineClassList_ptr = *itACL;
899 const stdair::ProportionFactor_T& lProportionFactor = *itPF;
900 stdair::MeanValue_T lMeanValue = lProportionFactor*lRemainingMeanValue;
901 stdair::StdDevValue_T lStdDevValue =
902 lProportionFactor*lRemainingStdDevValue;
904 iOnDDate, iCabinCode, iBomRoot);
912 const stdair::MeanValue_T& iMeanValue,
913 const stdair::StdDevValue_T& iStdDevValue,
914 stdair::OnDDate& iOnDDate,
915 const stdair::CabinCode_T& iCabinCode,
916 stdair::BomRoot& iBomRoot) {
918 const stdair::AirportCode_T& lOrigin = iOnDDate.getOrigin();
919 const stdair::AirportCode_T& lDestination = iOnDDate.getDestination();
921 const stdair::Date_T& lDepartureDate = iOnDDate.getDate();
923 const stdair::AirlineCodeList_T& lAirlineCodeList =
924 iAirlineClassList.getAirlineCodeList();
927 const stdair::ClassList_StringList_T& lClassList_StringList =
928 iAirlineClassList.getClassCodeList();
929 assert (!lClassList_StringList.empty());
930 stdair::ClassCodeList_T lClassCodeList;
931 for (stdair::ClassList_StringList_T::const_iterator itCL =
932 lClassList_StringList.begin();
933 itCL != lClassList_StringList.end(); ++itCL){
934 const stdair::ClassList_String_T& lClassList_String = *itCL;
935 assert (lClassList_String.size() > 0);
936 stdair::ClassCode_T lFirstClass;
937 lFirstClass.append (lClassList_String, 0, 1);
938 lClassCodeList.push_back(lFirstClass);
942 assert (lAirlineCodeList.size() == lClassCodeList.size());
943 assert (!lAirlineCodeList.empty());
945 if (lAirlineCodeList.size() == 1) {
947 stdair::AirlineCode_T lAirlineCode = lAirlineCodeList.front();
948 stdair::ClassCode_T lClassCode = lClassCodeList.front();
949 stdair::Yield_T lYield = iAirlineClassList.getYield();
951 lDestination, iCabinCode, lClassCode,
952 iMeanValue, iStdDevValue, lYield, iBomRoot);
956 stdair::Yield_T lYield = iAirlineClassList.getYield();
957 for (stdair::AirlineCodeList_T::const_iterator itAC =
958 lAirlineCodeList.begin();
959 itAC != lAirlineCodeList.end(); ++itAC) {
960 const stdair::AirlineCode_T& lAirlineCode = *itAC;
961 setOnDForecast(lAirlineCodeList, lAirlineCode, lDepartureDate, lOrigin,
962 lDestination, iCabinCode, lClassCodeList,
963 iMeanValue, iStdDevValue, lYield, iBomRoot);
971 const stdair::Date_T& iDepartureDate,
972 const stdair::AirportCode_T& iOrigin,
973 const stdair::AirportCode_T& iDestination,
974 const stdair::CabinCode_T& iCabinCode,
975 const stdair::ClassCode_T& iClassCode,
976 const stdair::MeanValue_T& iMeanValue,
977 const stdair::StdDevValue_T& iStdDevValue,
978 const stdair::Yield_T& iYield,
979 stdair::BomRoot& iBomRoot) {
980 stdair::Inventory* lInventory_ptr = iBomRoot.getInventory(iAirlineCode);
981 if (lInventory_ptr == NULL) {
982 STDAIR_LOG_ERROR (
"Cannot find the inventory corresponding"
983 <<
" to the airline" << iAirlineCode) ;
986 const stdair::OnDDateList_T lOnDDateList =
987 stdair::BomManager::getList<stdair::OnDDate> (*lInventory_ptr);
988 assert (!lOnDDateList.empty());
989 bool lFoundOnDDate =
false;
990 for (stdair::OnDDateList_T::const_iterator itOD = lOnDDateList.begin();
991 itOD != lOnDDateList.end(); ++itOD) {
992 stdair::OnDDate* lOnDDate_ptr = *itOD;
993 assert (lOnDDate_ptr != NULL);
994 const stdair::Date_T& lDepartureDate = lOnDDate_ptr->getDate();
995 const stdair::AirportCode_T& lOrigin = lOnDDate_ptr->getOrigin();
996 const stdair::AirportCode_T& lDestination = lOnDDate_ptr->getDestination();
997 const bool hasSegmentDateList =
998 stdair::BomManager::hasList<stdair::SegmentDate> (*lOnDDate_ptr);
999 if (hasSegmentDateList ==
false) {
1000 STDAIR_LOG_ERROR (
"The O&D date " << lOnDDate_ptr->describeKey()
1001 <<
"has not been correctly initialized : SegmentDate list is missing");
1004 const stdair::SegmentDateList_T& lSegmentDateList =
1005 stdair::BomManager::getList<stdair::SegmentDate> (*lOnDDate_ptr);
1007 if (lDepartureDate == iDepartureDate && lOrigin == iOrigin &&
1008 lDestination == iDestination && lSegmentDateList.size() == 1) {
1009 stdair::CabinClassPair_T lCabinClassPair (iCabinCode, iClassCode);
1010 stdair::CabinClassPairList_T lCabinClassPairList;
1011 lCabinClassPairList.push_back(lCabinClassPair);
1012 const stdair::MeanStdDevPair_T lMeanStdDevPair (iMeanValue, iStdDevValue);
1013 const stdair::WTPDemandPair_T lWTPDemandPair (iYield, lMeanStdDevPair);
1014 lOnDDate_ptr->setDemandInformation(lCabinClassPairList, lWTPDemandPair);
1015 lFoundOnDDate =
true;
1016 STDAIR_LOG_DEBUG (iAirlineCode <<
" Class " << iClassCode
1017 <<
" Mean " << iMeanValue
1018 <<
" Std Dev " << iStdDevValue);
1023 if (!lFoundOnDDate) {
1024 STDAIR_LOG_ERROR (
"Cannot find class " << iClassCode <<
" in cabin "
1025 << iCabinCode <<
" for the segment "
1026 << iOrigin <<
"-" << iDestination <<
" with"
1027 <<
" the airline " << iAirlineCode);
1035 const stdair::AirlineCode_T& iAirlineCode,
1036 const stdair::Date_T& iDepartureDate,
1037 const stdair::AirportCode_T& iOrigin,
1038 const stdair::AirportCode_T& iDestination,
1039 const stdair::CabinCode_T& iCabinCode,
1040 const stdair::ClassCodeList_T& iClassCodeList,
1041 const stdair::MeanValue_T& iMeanValue,
1042 const stdair::StdDevValue_T& iStdDevValue,
1043 const stdair::Yield_T& iYield,
1044 stdair::BomRoot& iBomRoot) {
1045 stdair::Inventory* lInventory_ptr = iBomRoot.getInventory(iAirlineCode);
1046 if (lInventory_ptr == NULL) {
1047 STDAIR_LOG_ERROR (
"Cannot find the inventory corresponding"
1048 <<
" to the airline" << iAirlineCode) ;
1051 const stdair::OnDDateList_T lOnDDateList =
1052 stdair::BomManager::getList<stdair::OnDDate> (*lInventory_ptr);
1053 assert (!lOnDDateList.empty());
1054 bool lFoundOnDDate =
false;
1055 for (stdair::OnDDateList_T::const_iterator itOD = lOnDDateList.begin();
1056 itOD != lOnDDateList.end(); ++itOD) {
1057 stdair::OnDDate* lOnDDate_ptr = *itOD;
1058 assert (lOnDDate_ptr != NULL);
1059 const stdair::Date_T& lDepartureDate = lOnDDate_ptr->getDate();
1060 const stdair::AirportCode_T& lOrigin = lOnDDate_ptr->getOrigin();
1061 const stdair::AirportCode_T& lDestination = lOnDDate_ptr->getDestination();
1062 const bool hasSegmentDateList =
1063 stdair::BomManager::hasList<stdair::SegmentDate> (*lOnDDate_ptr);
1064 if (hasSegmentDateList ==
false) {
1065 STDAIR_LOG_ERROR (
"The O&D date " << lOnDDate_ptr->describeKey()
1066 <<
"has not been correctly initialized : SegmentDate list is missing");
1069 const stdair::SegmentDateList_T& lSegmentDateList =
1070 stdair::BomManager::getList<stdair::SegmentDate> (*lOnDDate_ptr);
1073 if (lDepartureDate == iDepartureDate && lOrigin == iOrigin &&
1074 lDestination == iDestination && lSegmentDateList.size() == iAirlineCodeList.size()) {
1075 const stdair::SegmentDateList_T& lSegmentDateList =
1076 stdair::BomManager::getList<stdair::SegmentDate> (*lOnDDate_ptr);
1077 stdair::AirlineCodeList_T::const_iterator itAC = iAirlineCodeList.begin();
1078 stdair::SegmentDateList_T::const_iterator itSD = lSegmentDateList.begin();
1079 for (;itAC != iAirlineCodeList.end(); ++itAC, ++itSD) {
1080 const stdair::AirlineCode_T lForecastAirlineCode = *itAC;
1081 const stdair::SegmentDate* lSegmentDate_ptr = *itSD;
1084 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
1085 lSegmentDate_ptr->getOperatingSegmentDate ();
1086 if (lOperatingSegmentDate_ptr != NULL) {
1087 const stdair::FlightDate* lOperatingFD_ptr =
1088 stdair::BomManager::getParentPtr<stdair::FlightDate>(*lOperatingSegmentDate_ptr);
1089 const stdair::AirlineCode_T lOperatingAirlineCode =
1090 lOperatingFD_ptr->getAirlineCode();
1091 if (lOperatingAirlineCode != lForecastAirlineCode) {
1095 const stdair::AirlineCode_T lOperatingAirlineCode =
1096 lOnDDate_ptr->getAirlineCode();
1097 if (lOperatingAirlineCode != lForecastAirlineCode) {
1102 if (itAC == iAirlineCodeList.end()) {lFoundOnDDate =
true;}
1104 if (lFoundOnDDate) {
1105 stdair::CabinClassPairList_T lCabinClassPairList;
1106 for (stdair::ClassCodeList_T::const_iterator itCC = iClassCodeList.begin();
1107 itCC != iClassCodeList.end(); ++itCC) {
1108 const stdair::ClassCode_T lClassCode = *itCC;
1109 stdair::CabinClassPair_T lCabinClassPair (iCabinCode, lClassCode);
1110 lCabinClassPairList.push_back(lCabinClassPair);
1112 const stdair::MeanStdDevPair_T lMeanStdDevPair (iMeanValue, iStdDevValue);
1113 const stdair::YieldDemandPair_T lYieldDemandPair (iYield, lMeanStdDevPair);
1114 lOnDDate_ptr->setDemandInformation(lCabinClassPairList, lYieldDemandPair);
1115 lFoundOnDDate =
true;
1116 std::ostringstream oACStr;
1117 for (stdair::AirlineCodeList_T::const_iterator itAC = iAirlineCodeList.begin();
1118 itAC != iAirlineCodeList.end(); ++itAC) {
1119 if (itAC == iAirlineCodeList.begin()) {
1123 oACStr <<
"-" << *itAC;
1126 std::ostringstream oCCStr;
1127 for (stdair::ClassCodeList_T::const_iterator itCC = iClassCodeList.begin();
1128 itCC != iClassCodeList.end(); ++itCC) {
1129 if (itCC == iClassCodeList.begin()) {
1133 oCCStr <<
"-" << *itCC;
1137 STDAIR_LOG_DEBUG (oACStr.str() <<
" Classes " << oCCStr.str()
1138 <<
" Mean " << iMeanValue <<
" Std Dev " << iStdDevValue);
1142 if (!lFoundOnDDate) {
1143 STDAIR_LOG_ERROR (
"Cannot find the required multi-segment O&D date: "
1144 << iOrigin <<
"-" << iDestination <<
" " << iDepartureDate);
1152 if (_rmolServiceContext == NULL) {
1153 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1154 "has not been initialised");
1156 assert (_rmolServiceContext != NULL);
1160 stdair::STDAIR_Service& lSTDAIR_Service =
1161 lRMOL_ServiceContext.getSTDAIR_Service();
1162 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1164 const stdair::InventoryList_T lInventoryList =
1165 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1166 assert (!lInventoryList.empty());
1167 for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
1168 itInv != lInventoryList.end(); ++itInv) {
1169 const stdair::Inventory* lInventory_ptr = *itInv;
1170 assert (lInventory_ptr != NULL);
1178 const stdair::Inventory& iInventory) {
1180 const stdair::FlightDateList_T lFlightDateList =
1181 stdair::BomManager::getList<stdair::FlightDate> (iInventory);
1182 assert (!lFlightDateList.empty());
1183 for (stdair::FlightDateList_T::const_iterator itFD = lFlightDateList.begin();
1184 itFD != lFlightDateList.end(); ++itFD) {
1185 const stdair::FlightDate* lFlightDate_ptr = *itFD;
1186 assert (lFlightDate_ptr != NULL);
1189 const stdair::Date_T lDate = iRMEventTime.date();
1191 const stdair::Date_T& lDepartureDate = lFlightDate_ptr->getDepartureDate();
1192 stdair::DateOffset_T lDateOffset = lDepartureDate - lDate;
1193 stdair::DTD_T lDTD = short (lDateOffset.days());
1195 stdair::DCPList_T::const_iterator itDCP =
1196 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1198 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1201 const bool hasLegDateList =
1202 stdair::BomManager::hasList<stdair::LegDate> (*lFlightDate_ptr);
1203 if (hasLegDateList ==
true) {
1204 const stdair::LegDateList_T lLegDateList =
1205 stdair::BomManager::getList<stdair::LegDate> (*lFlightDate_ptr);
1206 assert (!lLegDateList.empty());
1207 for (stdair::LegDateList_T::const_iterator itLD = lLegDateList.begin();
1208 itLD != lLegDateList.end(); ++itLD) {
1209 const stdair::LegDate* lLegDate_ptr = *itLD;
1210 assert (lLegDate_ptr != NULL);
1211 const stdair::LegCabinList_T lLegCabinList =
1212 stdair::BomManager::getList<stdair::LegCabin> (*lLegDate_ptr);
1213 assert (!lLegCabinList.empty());
1214 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
1215 itLC != lLegCabinList.end(); ++itLC) {
1216 stdair::LegCabin* lLegCabin_ptr = *itLC;
1217 assert (lLegCabin_ptr != NULL);
1218 lLegCabin_ptr->emptyYieldLevelDemandMap();
1229 if (_rmolServiceContext == NULL) {
1230 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1231 "has not been initialised");
1233 assert (_rmolServiceContext != NULL);
1237 stdair::STDAIR_Service& lSTDAIR_Service =
1238 lRMOL_ServiceContext.getSTDAIR_Service();
1239 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1242 const stdair::Date_T lDate = iRMEventTime.date();
1244 const stdair::InventoryList_T lInventoryList =
1245 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1246 assert (!lInventoryList.empty());
1247 for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
1248 itInv != lInventoryList.end(); ++itInv) {
1249 const stdair::Inventory* lInventory_ptr = *itInv;
1250 assert (lInventory_ptr != NULL);
1251 const stdair::OnDDateList_T lOnDDateList =
1252 stdair::BomManager::getList<stdair::OnDDate> (*lInventory_ptr);
1253 assert (!lOnDDateList.empty());
1254 for (stdair::OnDDateList_T::const_iterator itOD = lOnDDateList.begin();
1255 itOD != lOnDDateList.end(); ++itOD) {
1256 stdair::OnDDate* lOnDDate_ptr = *itOD;
1257 assert (lOnDDate_ptr != NULL);
1259 const stdair::Date_T& lDepartureDate = lOnDDate_ptr->getDate();
1260 stdair::DateOffset_T lDateOffset = lDepartureDate - lDate;
1261 stdair::DTD_T lDTD = short (lDateOffset.days());
1263 stdair::DCPList_T::const_iterator itDCP =
1264 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1266 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1269 const stdair::StringDemandStructMap_T& lStringDemandStructMap =
1270 lOnDDate_ptr->getDemandInfoMap ();
1271 for (stdair::StringDemandStructMap_T::const_iterator itStrDS = lStringDemandStructMap.begin();
1272 itStrDS != lStringDemandStructMap.end(); ++itStrDS) {
1273 std::string lCabinClassPath = itStrDS->first;
1274 const stdair::YieldDemandPair_T& lYieldDemandPair =
1276 const stdair::CabinClassPairList_T& lCabinClassPairList =
1277 lOnDDate_ptr->getCabinClassPairList(lCabinClassPath);
1278 const stdair::NbOfSegments_T& lNbOfSegments = lOnDDate_ptr->getNbOfSegments();
1280 assert (lCabinClassPairList.size() == lNbOfSegments);
1282 const stdair::SegmentDateList_T lOnDSegmentDateList =
1283 stdair::BomManager::getList<stdair::SegmentDate> (*lOnDDate_ptr);
1285 assert (lOnDSegmentDateList.size() == lNbOfSegments);
1286 stdair::CabinClassPairList_T::const_iterator itCCP = lCabinClassPairList.begin();
1287 stdair::SegmentDateList_T::const_iterator itSD = lOnDSegmentDateList.begin();
1288 for (; itSD != lOnDSegmentDateList.end(); ++itCCP, ++itSD) {
1289 const stdair::SegmentDate* lSegmentDate_ptr = *itSD;
1290 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
1291 lSegmentDate_ptr->getOperatingSegmentDate ();
1292 assert (lSegmentDate_ptr != NULL);
1294 if (lOperatingSegmentDate_ptr == NULL) {
1295 const stdair::CabinCode_T lCabinCode = itCCP->first;
1296 const stdair::ClassCode_T lClassCode = itCCP->second;
1297 const stdair::SegmentCabin* lSegmentCabin_ptr =
1298 stdair::BomManager::getObjectPtr<stdair::SegmentCabin> (*lSegmentDate_ptr,
1300 assert (lSegmentCabin_ptr != NULL);
1303 const stdair::BookingClass* lBookingClass_ptr =
1304 stdair::BomManager::getObjectPtr<stdair::BookingClass> (*lSegmentCabin_ptr,
1306 assert (lBookingClass_ptr != NULL);
1307 const stdair::LegCabinList_T lLegCabinList =
1308 stdair::BomManager::getList<stdair::LegCabin> (*lSegmentCabin_ptr);
1309 assert (!lLegCabinList.empty());
1310 const int lNbOfLegs = lLegCabinList.size();
1312 const stdair::Yield_T& lYield = lBookingClass_ptr->getYield()/lNbOfLegs;
1313 const stdair::MeanStdDevPair_T& lMeanStdDevPair =
1314 lYieldDemandPair.second;
1315 const stdair::MeanValue_T& lMeanValue = lMeanStdDevPair.first;
1316 const stdair::StdDevValue_T& lStdDevValue = lMeanStdDevPair.second;
1317 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
1318 itLC != lLegCabinList.end(); ++itLC) {
1319 stdair::LegCabin* lLegCabin_ptr = *itLC;
1320 assert (lLegCabin_ptr != NULL);
1321 lLegCabin_ptr->addDemandInformation (lYield, lMeanValue, lStdDevValue);
1334 if (_rmolServiceContext == NULL) {
1335 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1336 "has not been initialised");
1338 assert (_rmolServiceContext != NULL);
1342 stdair::STDAIR_Service& lSTDAIR_Service =
1343 lRMOL_ServiceContext.getSTDAIR_Service();
1344 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1347 const stdair::Date_T lDate = iRMEventTime.date();
1349 const stdair::InventoryList_T lInventoryList =
1350 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1351 assert (!lInventoryList.empty());
1352 for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
1353 itInv != lInventoryList.end(); ++itInv) {
1354 const stdair::Inventory* lInventory_ptr = *itInv;
1355 assert (lInventory_ptr != NULL);
1356 const stdair::OnDDateList_T lOnDDateList =
1357 stdair::BomManager::getList<stdair::OnDDate> (*lInventory_ptr);
1358 assert (!lOnDDateList.empty());
1359 for (stdair::OnDDateList_T::const_iterator itOD = lOnDDateList.begin();
1360 itOD != lOnDDateList.end(); ++itOD) {
1361 stdair::OnDDate* lOnDDate_ptr = *itOD;
1362 assert (lOnDDate_ptr != NULL);
1364 const stdair::Date_T& lDepartureDate = lOnDDate_ptr->getDate();
1365 stdair::DateOffset_T lDateOffset = lDepartureDate - lDate;
1366 stdair::DTD_T lDTD = short (lDateOffset.days());
1368 stdair::DCPList_T::const_iterator itDCP =
1369 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1371 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1374 const stdair::StringDemandStructMap_T& lStringDemandStructMap =
1375 lOnDDate_ptr->getDemandInfoMap ();
1376 for (stdair::StringDemandStructMap_T::const_iterator itStrDS = lStringDemandStructMap.begin();
1377 itStrDS != lStringDemandStructMap.end(); ++itStrDS) {
1378 std::string lCabinClassPath = itStrDS->first;
1379 const stdair::YieldDemandPair_T& lYieldDemandPair =
1381 const stdair::CabinClassPairList_T& lCabinClassPairList =
1382 lOnDDate_ptr->getCabinClassPairList(lCabinClassPath);
1383 const stdair::NbOfSegments_T& lNbOfSegments = lOnDDate_ptr->getNbOfSegments();
1385 assert (lCabinClassPairList.size() == lNbOfSegments);
1387 const stdair::SegmentDateList_T lOnDSegmentDateList =
1388 stdair::BomManager::getList<stdair::SegmentDate> (*lOnDDate_ptr);
1390 assert (lOnDSegmentDateList.size() == lNbOfSegments);
1391 stdair::CabinClassPairList_T::const_iterator itCCP = lCabinClassPairList.begin();
1392 stdair::SegmentDateList_T::const_iterator itSD = lOnDSegmentDateList.begin();
1393 for (; itSD != lOnDSegmentDateList.end(); ++itCCP, ++itSD) {
1394 const stdair::SegmentDate* lSegmentDate_ptr = *itSD;
1395 assert (lSegmentDate_ptr != NULL);
1396 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
1397 lSegmentDate_ptr->getOperatingSegmentDate ();
1399 if (lOperatingSegmentDate_ptr == NULL) {
1400 const stdair::CabinCode_T lCabinCode = itCCP->first;
1401 const stdair::ClassCode_T lClassCode = itCCP->second;
1402 const stdair::SegmentCabin* lSegmentCabin_ptr =
1403 stdair::BomManager::getObjectPtr<stdair::SegmentCabin> (*lSegmentDate_ptr,
1405 assert (lSegmentCabin_ptr != NULL);
1406 const stdair::LegCabinList_T lLegCabinList =
1407 stdair::BomManager::getList<stdair::LegCabin> (*lSegmentCabin_ptr);
1408 assert (!lLegCabinList.empty());
1409 const int lNbOfLegs = lLegCabinList.size();
1411 const stdair::MeanStdDevPair_T& lMeanStdDevPair =
1412 lYieldDemandPair.second;
1413 const stdair::Yield_T& lYield = lYieldDemandPair.first/(lNbOfLegs*lNbOfSegments);
1414 const stdair::MeanValue_T& lMeanValue = lMeanStdDevPair.first;
1415 const stdair::StdDevValue_T& lStdDevValue = lMeanStdDevPair.second;
1416 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
1417 itLC != lLegCabinList.end(); ++itLC) {
1418 stdair::LegCabin* lLegCabin_ptr = *itLC;
1419 assert (lLegCabin_ptr != NULL);
1420 lLegCabin_ptr->addDemandInformation (lYield, lMeanValue, lStdDevValue);
1433 if (_rmolServiceContext == NULL) {
1434 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1435 "has not been initialised");
1437 assert (_rmolServiceContext != NULL);
1441 stdair::STDAIR_Service& lSTDAIR_Service =
1442 lRMOL_ServiceContext.getSTDAIR_Service();
1443 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1446 const stdair::Date_T lDate = iRMEventTime.date();
1448 const stdair::InventoryList_T& lInvList =
1449 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1450 for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
1451 itInv != lInvList.end(); ++itInv) {
1452 stdair::Inventory* lCurrentInv_ptr = *itInv;
1453 assert (lCurrentInv_ptr != NULL);
1455 const stdair::FlightDateList_T& lFlightDateList =
1456 stdair::BomManager::getList<stdair::FlightDate> (*lCurrentInv_ptr);
1457 for (stdair::FlightDateList_T::const_iterator itFlightDate =
1458 lFlightDateList.begin();
1459 itFlightDate != lFlightDateList.end(); ++itFlightDate) {
1460 stdair::FlightDate* lCurrentFlightDate_ptr = *itFlightDate;
1461 assert (lCurrentFlightDate_ptr != NULL);
1463 const stdair::Date_T& lCurrentDepartureDate = lCurrentFlightDate_ptr->getDepartureDate();
1464 stdair::DateOffset_T lDateOffset = lCurrentDepartureDate - lDate;
1465 stdair::DTD_T lDTD = short (lDateOffset.days());
1467 stdair::DCPList_T::const_iterator itDCP =
1468 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1470 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1471 STDAIR_LOG_DEBUG (
"Optimisation using O&D forecast: " << lCurrentInv_ptr->getAirlineCode()
1472 <<
" Departure " << lCurrentDepartureDate <<
" DTD " << lDTD);
1482 if (_rmolServiceContext == NULL) {
1483 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1484 "has not been initialised");
1486 assert (_rmolServiceContext != NULL);
1490 stdair::STDAIR_Service& lSTDAIR_Service =
1491 lRMOL_ServiceContext.getSTDAIR_Service();
1492 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1495 const stdair::Date_T lDate = iRMEventTime.date();
1497 const stdair::InventoryList_T& lInvList =
1498 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1500 for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
1501 itInv != lInvList.end(); ++itInv) {
1502 stdair::Inventory* lCurrentInv_ptr = *itInv;
1503 assert (lCurrentInv_ptr != NULL);
1505 const stdair::FlightDateList_T& lFlightDateList =
1506 stdair::BomManager::getList<stdair::FlightDate> (*lCurrentInv_ptr);
1507 for (stdair::FlightDateList_T::const_iterator itFlightDate =
1508 lFlightDateList.begin();
1509 itFlightDate != lFlightDateList.end(); ++itFlightDate) {
1510 stdair::FlightDate* lCurrentFlightDate_ptr = *itFlightDate;
1511 assert (lCurrentFlightDate_ptr != NULL);
1513 const stdair::Date_T& lCurrentDepartureDate = lCurrentFlightDate_ptr->getDepartureDate();
1514 stdair::DateOffset_T lDateOffset = lCurrentDepartureDate - lDate;
1515 stdair::DTD_T lDTD = short (lDateOffset.days());
1517 stdair::DCPList_T::const_iterator itDCP =
1518 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1520 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1529 stdair::BomRoot& iBomRoot) {
1530 const stdair::SegmentDateList_T& lSegmentDateList =
1531 stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate);
1532 const stdair::AirlineCode_T& lOptAC = iFlightDate.getAirlineCode();
1533 const std::string lFDKeyStr = iFlightDate.describeKey();
1535 for (stdair::SegmentDateList_T::const_iterator itSegmentDate = lSegmentDateList.begin();
1536 itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) {
1537 stdair::SegmentDate* lSegmentDate_ptr = *itSegmentDate;
1538 assert (lSegmentDate_ptr != NULL);
1539 const bool hasSegmentDateList =
1540 stdair::BomManager::hasList<stdair::SegmentDate>(*lSegmentDate_ptr);
1541 if (hasSegmentDateList ==
true) {
1542 const stdair::LegDateList_T& lLegDateList =
1543 stdair::BomManager::getList<stdair::LegDate>(*lSegmentDate_ptr);
1546 const stdair::SegmentDateList_T& lMktSegmentDateList =
1547 stdair::BomManager::getList<stdair::SegmentDate>(*lSegmentDate_ptr);
1548 for (stdair::SegmentDateList_T::const_iterator itMktSD = lMktSegmentDateList.begin();
1549 itMktSD != lMktSegmentDateList.end(); ++itMktSD) {
1551 stdair::SegmentDate* lMktSD_ptr = *itMktSD;
1552 assert (lMktSD_ptr != NULL);
1553 stdair::FlightDate* lMktFD_ptr =
1554 stdair::BomManager::getParentPtr<stdair::FlightDate>(*lMktSD_ptr);
1555 assert (lMktFD_ptr != NULL);
1556 const stdair::AirlineCode_T& lMktAC = lMktFD_ptr->getAirlineCode();
1558 const stdair::Inventory* lMktInv_ptr =
1559 stdair::BomManager::getObjectPtr<stdair::Inventory>(iBomRoot,lMktAC);
1560 assert (lMktInv_ptr != NULL);
1562 const stdair::Inventory* lOptInv_ptr =
1563 stdair::BomManager::getObjectPtr<stdair::Inventory>(*lMktInv_ptr,lOptAC);
1564 assert (lOptInv_ptr != NULL);
1566 const stdair::FlightDate* lOptFD_ptr =
1567 stdair::BomManager::getObjectPtr<stdair::FlightDate>(*lOptInv_ptr,lFDKeyStr);
1568 assert (lOptFD_ptr != NULL);
1571 for (stdair::LegDateList_T::const_iterator itLD = lLegDateList.begin();
1572 itLD != lLegDateList.end(); ++itLD) {
1573 const stdair::LegDate* lLD_ptr = *itLD;
1574 assert (lLD_ptr != NULL);
1575 const std::string lLDKeyStr = lLD_ptr->describeKey();
1576 stdair::LegDate* lOptLD_ptr =
1577 stdair::BomManager::getObjectPtr<stdair::LegDate>(*lOptFD_ptr,lLDKeyStr);
1578 assert (lOptLD_ptr != NULL);
1579 const stdair::LegCabinList_T& lLegCabinList_T =
1580 stdair::BomManager::getList<stdair::LegCabin>(*lLD_ptr);
1583 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList_T.begin();
1584 itLC != lLegCabinList_T.end(); ++itLC) {
1585 stdair::LegCabin* lLC_ptr = *itLC;
1586 assert (lLC_ptr != NULL);
1587 const std::string lLCKeyStr = lLC_ptr->describeKey();
1588 stdair::LegCabin* lOptLC_ptr =
1589 stdair::BomManager::getObjectPtr<stdair::LegCabin>(*lOptLD_ptr, lLCKeyStr);
1590 assert (lOptLC_ptr != NULL);
1592 lLC_ptr->updateCurrentBidPrice();
1594 lOptLC_ptr->updatePreviousBidPrice();
1596 lOptLC_ptr->setCurrentBidPrice (lLC_ptr->getCurrentBidPrice());
1598 STDAIR_LOG_DEBUG (
"Update bid price of " << lLC_ptr->getFullerKey()
1599 <<
" : " << lOptLC_ptr->getCurrentBidPrice()
1600 <<
" Availability pool " << lLC_ptr->getAvailabilityPool());
1611 if (_rmolServiceContext == NULL) {
1612 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1613 "has not been initialised");
1615 assert (_rmolServiceContext != NULL);
1619 stdair::STDAIR_Service& lSTDAIR_Service =
1620 lRMOL_ServiceContext.getSTDAIR_Service();
1621 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1624 const stdair::Date_T lDate = iRMEventTime.date();
1626 const stdair::InventoryList_T lInventoryList =
1627 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1628 assert (!lInventoryList.empty());
1629 for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
1630 itInv != lInventoryList.end(); ++itInv) {
1631 const stdair::Inventory* lInventory_ptr = *itInv;
1632 assert (lInventory_ptr != NULL);
1633 const stdair::OnDDateList_T lOnDDateList =
1634 stdair::BomManager::getList<stdair::OnDDate> (*lInventory_ptr);
1635 assert (!lOnDDateList.empty());
1636 for (stdair::OnDDateList_T::const_iterator itOD = lOnDDateList.begin();
1637 itOD != lOnDDateList.end(); ++itOD) {
1638 stdair::OnDDate* lOnDDate_ptr = *itOD;
1639 assert (lOnDDate_ptr != NULL);
1641 const stdair::Date_T& lDepartureDate = lOnDDate_ptr->getDate();
1642 stdair::DateOffset_T lDateOffset = lDepartureDate - lDate;
1643 stdair::DTD_T lDTD = short (lDateOffset.days());
1645 stdair::DCPList_T::const_iterator itDCP =
1646 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1648 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1651 const stdair::StringDemandStructMap_T& lStringDemandStructMap =
1652 lOnDDate_ptr->getDemandInfoMap ();
1653 for (stdair::StringDemandStructMap_T::const_iterator itStrDS = lStringDemandStructMap.begin();
1654 itStrDS != lStringDemandStructMap.end(); ++itStrDS) {
1655 std::string lCabinClassPath = itStrDS->first;
1656 const stdair::YieldDemandPair_T& lYieldDemandPair = itStrDS->second;
1657 const stdair::CabinClassPairList_T& lCabinClassPairList =
1658 lOnDDate_ptr->getCabinClassPairList(lCabinClassPath);
1659 const stdair::NbOfSegments_T& lNbOfSegments = lOnDDate_ptr->getNbOfSegments();
1661 assert (lCabinClassPairList.size() == lNbOfSegments);
1664 const stdair::SegmentDateList_T lOnDSegmentDateList =
1665 stdair::BomManager::getList<stdair::SegmentDate> (*lOnDDate_ptr);
1667 assert (lOnDSegmentDateList.size() == lNbOfSegments);
1668 stdair::CabinClassPairList_T::const_iterator itCCP = lCabinClassPairList.begin();
1669 stdair::SegmentDateList_T::const_iterator itSD = lOnDSegmentDateList.begin();
1671 std::list<stdair::BidPrice_T> lBidPriceList;
1673 stdair::BidPrice_T lTotalBidPrice = 0;
1675 for (; itSD != lOnDSegmentDateList.end(); ++itCCP, ++itSD) {
1677 const stdair::SegmentDate* lSegmentDate_ptr = *itSD;
1678 assert (lSegmentDate_ptr != NULL);
1680 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
1681 lSegmentDate_ptr->getOperatingSegmentDate ();
1682 if (lOperatingSegmentDate_ptr != NULL) {
1683 lSegmentDate_ptr = lOperatingSegmentDate_ptr;
1685 const stdair::CabinCode_T lCabinCode = itCCP->first;
1686 const stdair::SegmentCabin* lSegmentCabin_ptr =
1687 stdair::BomManager::getObjectPtr<stdair::SegmentCabin> (*lSegmentDate_ptr,
1689 assert (lSegmentCabin_ptr != NULL);
1690 stdair::BidPrice_T lBidPrice = 0;
1691 const stdair::LegCabinList_T lLegCabinList =
1692 stdair::BomManager::getList<stdair::LegCabin>(*lSegmentCabin_ptr);
1693 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
1694 itLC != lLegCabinList.end(); ++itLC) {
1695 const stdair::LegCabin* lLegCabin_ptr = *itLC;
1696 assert (lLegCabin_ptr != NULL);
1697 lBidPrice += lLegCabin_ptr->getCurrentBidPrice();
1699 lBidPriceList.push_back (lBidPrice);
1700 lTotalBidPrice += lBidPrice;
1704 itCCP = lCabinClassPairList.begin();
1705 itSD = lOnDSegmentDateList.begin();
1706 std::list<stdair::BidPrice_T>::const_iterator itBP = lBidPriceList.begin();
1707 for (; itSD != lOnDSegmentDateList.end(); ++itCCP, ++itSD, ++itBP) {
1708 stdair::BidPrice_T lBidPrice = *itBP;
1709 stdair::BidPrice_T lComplementaryBidPrice = lTotalBidPrice - lBidPrice;
1710 const stdair::SegmentDate* lSegmentDate_ptr = *itSD;
1711 assert (lSegmentDate_ptr != NULL);
1712 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
1713 lSegmentDate_ptr->getOperatingSegmentDate ();
1715 if (lOperatingSegmentDate_ptr == NULL) {
1716 const stdair::CabinCode_T lCabinCode = itCCP->first;
1717 const stdair::ClassCode_T lClassCode = itCCP->second;
1718 const stdair::SegmentCabin* lSegmentCabin_ptr =
1719 stdair::BomManager::getObjectPtr<stdair::SegmentCabin> (*lSegmentDate_ptr,
1721 assert (lSegmentCabin_ptr != NULL);
1722 const stdair::LegCabinList_T lLegCabinList =
1723 stdair::BomManager::getList<stdair::LegCabin> (*lSegmentCabin_ptr);
1724 assert (!lLegCabinList.empty());
1727 const stdair::Yield_T& lDAYield =
1728 std::max(100., lYieldDemandPair.first - lComplementaryBidPrice);
1731 stdair::Yield_T lYield = lDAYield;
1746 const stdair::MeanStdDevPair_T& lMeanStdDevPair =
1747 lYieldDemandPair.second;
1748 const stdair::MeanValue_T& lMeanValue = lMeanStdDevPair.first;
1749 const stdair::StdDevValue_T& lStdDevValue = lMeanStdDevPair.second;
1750 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
1751 itLC != lLegCabinList.end(); ++itLC) {
1752 stdair::LegCabin* lLegCabin_ptr = *itLC;
1753 assert (lLegCabin_ptr != NULL);
1754 lLegCabin_ptr->addDemandInformation (lYield, lMeanValue, lStdDevValue);
1767 if (_rmolServiceContext == NULL) {
1768 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1769 "has not been initialised");
1771 assert (_rmolServiceContext != NULL);
1775 stdair::STDAIR_Service& lSTDAIR_Service =
1776 lRMOL_ServiceContext.getSTDAIR_Service();
1777 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1779 const stdair::InventoryList_T lInventoryList =
1780 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1781 assert (!lInventoryList.empty());
1782 for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
1783 itInv != lInventoryList.end(); ++itInv) {
1784 const stdair::Inventory* lInventory_ptr = *itInv;
1785 assert (lInventory_ptr != NULL);
1792 const stdair::Inventory& iInventory) {
1794 const stdair::OnDDateList_T lOnDDateList =
1795 stdair::BomManager::getList<stdair::OnDDate> (iInventory);
1796 assert (!lOnDDateList.empty());
1797 for (stdair::OnDDateList_T::const_iterator itOD = lOnDDateList.begin();
1798 itOD != lOnDDateList.end(); ++itOD) {
1799 stdair::OnDDate* lOnDDate_ptr = *itOD;
1800 assert (lOnDDate_ptr != NULL);
1803 const stdair::Date_T lDate = iRMEventTime.date();
1805 const stdair::Date_T& lDepartureDate = lOnDDate_ptr->getDate();
1806 stdair::DateOffset_T lDateOffset = lDepartureDate - lDate;
1807 stdair::DTD_T lDTD = short (lDateOffset.days());
1809 stdair::DCPList_T::const_iterator itDCP =
1810 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1812 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1815 const stdair::StringDemandStructMap_T& lStringDemandStructMap =
1816 lOnDDate_ptr->getDemandInfoMap ();
1817 for (stdair::StringDemandStructMap_T::const_iterator itStrDS = lStringDemandStructMap.begin();
1818 itStrDS != lStringDemandStructMap.end(); ++itStrDS) {
1819 std::string lCabinClassPath = itStrDS->first;
1820 const stdair::YieldDemandPair_T& lYieldDemandPair = itStrDS->second;
1821 const stdair::CabinClassPairList_T& lCabinClassPairList =
1822 lOnDDate_ptr->getCabinClassPairList(lCabinClassPath);
1823 const stdair::NbOfSegments_T& lNbOfSegments = lOnDDate_ptr->getNbOfSegments();
1825 assert (lCabinClassPairList.size() == lNbOfSegments);
1828 const stdair::SegmentDateList_T lOnDSegmentDateList =
1829 stdair::BomManager::getList<stdair::SegmentDate> (*lOnDDate_ptr);
1831 assert (lOnDSegmentDateList.size() == lNbOfSegments);
1832 stdair::CabinClassPairList_T::const_iterator itCCP = lCabinClassPairList.begin();
1833 stdair::SegmentDateList_T::const_iterator itSD = lOnDSegmentDateList.begin();
1835 stdair::BidPrice_T lTotalBidPrice = 0;
1836 for (; itSD != lOnDSegmentDateList.end(); ++itCCP, ++itSD) {
1838 const stdair::SegmentDate* lSegmentDate_ptr = *itSD;
1839 assert (lSegmentDate_ptr != NULL);
1841 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
1842 lSegmentDate_ptr->getOperatingSegmentDate ();
1843 if (lOperatingSegmentDate_ptr != NULL) {
1844 lSegmentDate_ptr = lOperatingSegmentDate_ptr;
1846 const stdair::CabinCode_T lCabinCode = itCCP->first;
1847 const stdair::SegmentCabin* lSegmentCabin_ptr =
1848 stdair::BomManager::getObjectPtr<stdair::SegmentCabin> (*lSegmentDate_ptr,
1850 assert (lSegmentCabin_ptr != NULL);
1851 const stdair::LegCabinList_T lLegCabinList =
1852 stdair::BomManager::getList<stdair::LegCabin>(*lSegmentCabin_ptr);
1853 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
1854 itLC != lLegCabinList.end(); ++itLC) {
1855 const stdair::LegCabin* lLegCabin_ptr = *itLC;
1856 assert (lLegCabin_ptr != NULL);
1857 lTotalBidPrice += lLegCabin_ptr->getCurrentBidPrice();
1862 itCCP = lCabinClassPairList.begin();
1863 itSD = lOnDSegmentDateList.begin();
1864 for (; itSD != lOnDSegmentDateList.end(); ++itCCP, ++itSD) {
1865 const stdair::SegmentDate* lSegmentDate_ptr = *itSD;
1866 assert (lSegmentDate_ptr != NULL);
1867 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
1868 lSegmentDate_ptr->getOperatingSegmentDate ();
1870 if (lOperatingSegmentDate_ptr == NULL) {
1871 const stdair::CabinCode_T lCabinCode = itCCP->first;
1872 const stdair::ClassCode_T lClassCode = itCCP->second;
1873 const stdair::SegmentCabin* lSegmentCabin_ptr =
1874 stdair::BomManager::getObjectPtr<stdair::SegmentCabin> (*lSegmentDate_ptr,
1876 assert (lSegmentCabin_ptr != NULL);
1877 const stdair::LegCabinList_T lLegCabinList =
1878 stdair::BomManager::getList<stdair::LegCabin> (*lSegmentCabin_ptr);
1879 assert (!lLegCabinList.empty());
1880 const stdair::Yield_T& lYield = lYieldDemandPair.first;
1881 const stdair::MeanStdDevPair_T& lMeanStdDevPair =
1882 lYieldDemandPair.second;
1883 const stdair::MeanValue_T& lMeanValue = lMeanStdDevPair.first;
1884 const stdair::StdDevValue_T& lStdDevValue = lMeanStdDevPair.second;
1885 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
1886 itLC != lLegCabinList.end(); ++itLC) {
1887 stdair::LegCabin* lLegCabin_ptr = *itLC;
1888 assert (lLegCabin_ptr != NULL);
1889 const stdair::BidPrice_T& lBidPrice = lLegCabin_ptr->getCurrentBidPrice();
1890 const stdair::RealNumber_T lDynamicYieldProrationFactor = lBidPrice / lTotalBidPrice;
1891 const stdair::Yield_T lProratedYield = lDynamicYieldProrationFactor*lYield;
1892 lLegCabin_ptr->addDemandInformation (lProratedYield, lMeanValue, lStdDevValue);
1909 if (_rmolServiceContext == NULL) {
1910 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1911 "has not been initialised");
1913 assert (_rmolServiceContext != NULL);
1917 stdair::STDAIR_Service& lSTDAIR_Service =
1918 lRMOL_ServiceContext.getSTDAIR_Service();
1919 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1922 const stdair::Date_T lDate = iRMEventTime.date();
1925 const stdair::InventoryList_T& lInvList =
1926 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1927 for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
1928 itInv != lInvList.end(); ++itInv) {
1929 stdair::Inventory* lCurrentInv_ptr = *itInv;
1930 assert (lCurrentInv_ptr != NULL);
1932 double lMaxBPVariation = 1.0;
1933 short lIterationCounter = 0;
1935 while (lMaxBPVariation > 0.01 && lIterationCounter < 10) {
1936 lMaxBPVariation = 0.0;
1937 lIterationCounter++;
1938 const stdair::FlightDateList_T& lFlightDateList =
1939 stdair::BomManager::getList<stdair::FlightDate> (*lCurrentInv_ptr);
1940 for (stdair::FlightDateList_T::const_iterator itFlightDate =
1941 lFlightDateList.begin();
1942 itFlightDate != lFlightDateList.end(); ++itFlightDate) {
1943 stdair::FlightDate* lCurrentFlightDate_ptr = *itFlightDate;
1944 assert (lCurrentFlightDate_ptr != NULL);
1946 const stdair::Date_T& lCurrentDepartureDate = lCurrentFlightDate_ptr->getDepartureDate();
1947 stdair::DateOffset_T lDateOffset = lCurrentDepartureDate - lDate;
1948 stdair::DTD_T lDTD = short (lDateOffset.days());
1950 stdair::DCPList_T::const_iterator itDCP =
1951 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
1953 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
1955 lMaxBPVariation = std::max(lMaxBPVariation, lBPVariation);
1969 if (_rmolServiceContext == NULL) {
1970 throw stdair::NonInitialisedServiceException (
"The Rmol service "
1971 "has not been initialised");
1973 assert (_rmolServiceContext != NULL);
1977 stdair::STDAIR_Service& lSTDAIR_Service =
1978 lRMOL_ServiceContext.getSTDAIR_Service();
1979 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1982 const stdair::Date_T lDate = iRMEventTime.date();
1984 double lMaxBPVariation = 1.0;
1985 short lIterationCounter = 0;
1989 while (lMaxBPVariation > 0.01 && lIterationCounter < 50) {
1990 lMaxBPVariation = 0.0;
1991 lIterationCounter++;
1993 const stdair::InventoryList_T& lInvList =
1994 stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
1995 for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
1996 itInv != lInvList.end(); ++itInv) {
1997 stdair::Inventory* lCurrentInv_ptr = *itInv;
1998 assert (lCurrentInv_ptr != NULL);
1999 const stdair::FlightDateList_T& lFlightDateList =
2000 stdair::BomManager::getList<stdair::FlightDate> (*lCurrentInv_ptr);
2001 for (stdair::FlightDateList_T::const_iterator itFlightDate =
2002 lFlightDateList.begin();
2003 itFlightDate != lFlightDateList.end(); ++itFlightDate) {
2004 stdair::FlightDate* lCurrentFlightDate_ptr = *itFlightDate;
2005 assert (lCurrentFlightDate_ptr != NULL);
2007 const stdair::Date_T& lCurrentDepartureDate = lCurrentFlightDate_ptr->getDepartureDate();
2008 stdair::DateOffset_T lDateOffset = lCurrentDepartureDate - lDate;
2009 stdair::DTD_T lDTD = short (lDateOffset.days());
2011 stdair::DCPList_T::const_iterator itDCP =
2012 std::find (stdair::DEFAULT_DCP_LIST.begin(), stdair::DEFAULT_DCP_LIST.end(), lDTD);
2013 if (itDCP != stdair::DEFAULT_DCP_LIST.end()) {
2015 lMaxBPVariation = std::max(lMaxBPVariation, lBPVariation);