$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 #include <cmath> 00008 // StdAir 00009 #include <stdair/basic/BasConst_General.hpp> 00010 #include <stdair/basic/BasConst_Inventory.hpp> 00011 #include <stdair/basic/RandomGeneration.hpp> 00012 #include <stdair/bom/BomManager.hpp> 00013 #include <stdair/bom/FlightDate.hpp> 00014 #include <stdair/bom/SegmentDate.hpp> 00015 #include <stdair/bom/SegmentCabin.hpp> 00016 #include <stdair/bom/SegmentSnapshotTable.hpp> 00017 #include <stdair/bom/BookingClass.hpp> 00018 #include <stdair/service/Logger.hpp> 00019 // RMOL 00020 #include <rmol/bom/Utilities.hpp> 00021 #include <rmol/command/PreOptimiser.hpp> 00022 #include <rmol/command/DemandInputPreparation.hpp> 00023 #include <rmol/command/FareAdjustment.hpp> 00024 #include <rmol/command/MarginalRevenueTransformation.hpp> 00025 00026 namespace RMOL { 00027 00028 // //////////////////////////////////////////////////////////////////// 00029 bool PreOptimiser:: 00030 preOptimise (stdair::FlightDate& ioFlightDate, 00031 const stdair::PreOptimisationMethod& iPreOptimisationMethod) { 00032 bool isSucceeded = true; 00033 const stdair::SegmentDateList_T& lSDList = 00034 stdair::BomManager::getList<stdair::SegmentDate> (ioFlightDate); 00035 for (stdair::SegmentDateList_T::const_iterator itSD = lSDList.begin(); 00036 itSD != lSDList.end(); ++itSD) { 00037 stdair::SegmentDate* lSD_ptr = *itSD; 00038 assert (lSD_ptr != NULL); 00039 00040 // 00041 const stdair::SegmentCabinList_T& lSCList = 00042 stdair::BomManager::getList<stdair::SegmentCabin> (*lSD_ptr); 00043 for (stdair::SegmentCabinList_T::const_iterator itSC = lSCList.begin(); 00044 itSC != lSCList.end(); ++itSC) { 00045 stdair::SegmentCabin* lSC_ptr = *itSC; 00046 assert (lSC_ptr != NULL); 00047 00048 // 00049 // STDAIR_LOG_NOTIFICATION (ioFlightDate.getDepartureDate() 00050 // << ";" << lSegmentDTD); 00051 bool isPreOptimised = preOptimise (*lSC_ptr, iPreOptimisationMethod); 00052 if (isPreOptimised == false) { 00053 isSucceeded = false; 00054 } 00055 } 00056 } 00057 00058 return isSucceeded; 00059 } 00060 00061 // //////////////////////////////////////////////////////////////////// 00062 bool PreOptimiser:: 00063 preOptimise (stdair::SegmentCabin& ioSegmentCabin, 00064 const stdair::PreOptimisationMethod& iPreOptimisationMethod) { 00065 const stdair::PreOptimisationMethod::EN_PreOptimisationMethod& lPreOptimisationMethod = 00066 iPreOptimisationMethod.getMethod(); 00067 switch (lPreOptimisationMethod) { 00068 case stdair::PreOptimisationMethod::NONE: { 00069 return DemandInputPreparation::prepareDemandInput (ioSegmentCabin); 00070 } 00071 case stdair::PreOptimisationMethod::FA: { 00072 return FareAdjustment::adjustYield (ioSegmentCabin); 00073 } 00074 case stdair::PreOptimisationMethod::MRT: { 00075 if (ioSegmentCabin.getFareFamilyStatus()==false) { 00076 return FareAdjustment::adjustYield (ioSegmentCabin); 00077 } else { 00078 return MarginalRevenueTransformation:: 00079 prepareDemandInput (ioSegmentCabin); 00080 } 00081 } 00082 default:{ 00083 assert (false); 00084 break; 00085 } 00086 } 00087 return false; 00088 } 00089 00090 // //////////////////////////////////////////////////////////////////// 00091 // void PreOptimiser:: 00092 // setDemandForecastsToZero(const stdair::SegmentCabin& iSegmentCabin) { 00093 // } 00094 }