$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/bom/BomKeyManager.hpp> 00009 #include <stdair/bom/BookingClassKey.hpp> 00010 #include <stdair/bom/BookingRequestStruct.hpp> 00011 #include <stdair/bom/TravelSolutionStruct.hpp> 00012 #include <stdair/bom/FareOptionStruct.hpp> 00013 #include <stdair/service/Logger.hpp> 00014 // TravelCCM 00015 #include <travelccm/bom/HardRestrictionModel.hpp> 00016 00017 namespace TRAVELCCM { 00018 00019 // //////////////////////////////////////////////////////////////////// 00020 const stdair::TravelSolutionStruct* HardRestrictionModel:: 00021 chooseTravelSolution (stdair::TravelSolutionList_T& ioTSList, 00022 const stdair::BookingRequestStruct& iBookingRequest) { 00023 stdair::TravelSolutionStruct* oChosenTS_ptr = NULL; 00024 00025 // Retrieve the number of passengers 00026 const stdair::NbOfSeats_T& lPartySize = iBookingRequest.getPartySize(); 00027 00028 // Retrieve the Willingness-to-Pay (WTP) of the customer 00029 const stdair::WTP_T& lWTP = iBookingRequest.getWTP(); 00030 00031 // Browse the travel solution list and choose the cheapest one 00032 stdair::Fare_T lLowestFare = std::numeric_limits<stdair::Fare_T>::max(); 00033 for (stdair::TravelSolutionList_T::iterator itTS = ioTSList.begin(); 00034 itTS != ioTSList.end(); ++itTS) { 00035 stdair::TravelSolutionStruct& lTS = *itTS; 00036 00037 // Browse the fare options 00038 const stdair::FareOptionList_T& lFOList = lTS.getFareOptionList(); 00039 for (stdair::FareOptionList_T::const_iterator itFO = lFOList.begin(); 00040 itFO != lFOList.end(); ++itFO) { 00041 const stdair::FareOptionStruct& lFO = *itFO; 00042 00043 // Check if the hard restrictions (change fees, non refundable) are 00044 // satisfied 00045 bool lHardRestrictionsSatisfied = true; 00046 if (lFO.getChangeFees() == true 00047 && iBookingRequest.getChangeFees() == false) { 00048 lHardRestrictionsSatisfied = false; 00049 } else if (lFO.getNonRefundable() == true 00050 && iBookingRequest.getNonRefundable() == false) { 00051 lHardRestrictionsSatisfied = false; 00052 } 00053 00054 if (lHardRestrictionsSatisfied == true) { 00055 // Choose the current fare option and the current solution 00056 // if the current fare is lower than the current lowest fare. 00057 const stdair::Fare_T& lFOFare = lFO.getFare(); 00058 const stdair::Availability_T& lFOAvl = lFO.getAvailability(); 00059 00060 if (lFOFare < lLowestFare && lFOFare <= lWTP 00061 && lFOAvl >= lPartySize) { 00062 00063 // DEBUG 00064 /* 00065 STDAIR_LOG_DEBUG ("The travel solution (TS) '" << lTS 00066 << "' is chosen because its fare (" << lFOFare 00067 << ") is lower than the lowest fare (" << lLowestFare 00068 << ") and than the WTP (" << lWTP 00069 << "), and because the party size (" << lPartySize 00070 << ") is lower than the availability (" << lFOAvl 00071 << ")"); 00072 */ 00073 00074 lLowestFare = lFOFare; 00075 oChosenTS_ptr = &lTS; 00076 oChosenTS_ptr->setChosenFareOption (lFO); 00077 00078 } else { 00079 // DEBUG 00080 /* 00081 STDAIR_LOG_DEBUG ("The travel solution (TS) '" << lTS 00082 << "' is not chosen because either its fare (" 00083 << lFOFare << ") is greater than the lowest fare (" 00084 << lLowestFare << ") or than the WTP (" << lWTP 00085 << "), or because the party size (" << lPartySize 00086 << ") is greater than the availability (" << lFOAvl 00087 << ")"); 00088 */ 00089 } 00090 } 00091 } 00092 } 00093 00094 return oChosenTS_ptr; 00095 } 00096 00097 }