$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/HybridModel.hpp> 00016 00017 namespace TRAVELCCM { 00018 00019 // //////////////////////////////////////////////////////////////////// 00020 const stdair::TravelSolutionStruct* HybridModel:: 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 // Retrieve the restrictions of the customer 00032 // Retrieve the Change Fees of the customer 00033 const stdair::ChangeFees_T& lCustomerChangeFees = 00034 iBookingRequest.getChangeFees(); 00035 00036 //Retrieve the Non Refundable of the customer 00037 const stdair::NonRefundable_T& lCustomerNonRefundable = 00038 iBookingRequest.getNonRefundable(); 00039 00040 // Retrieve the Disutility of the customer 00041 const stdair::Fare_T& lChangeFeesDisutility = 00042 iBookingRequest.getChangeFeeDisutility(); 00043 const stdair::Fare_T& lNonRefundableDisutility = 00044 iBookingRequest.getNonRefundableDisutility(); 00045 00046 // Browse the travel solution list and choose the cheapest one 00047 stdair::Fare_T lLowestFare = std::numeric_limits<stdair::Fare_T>::max(); 00048 for (stdair::TravelSolutionList_T::iterator itTS = ioTSList.begin(); 00049 itTS != ioTSList.end(); ++itTS) { 00050 stdair::TravelSolutionStruct& lTS = *itTS; 00051 00052 // Browse the fare options 00053 const stdair::FareOptionList_T& lFOList = lTS.getFareOptionList(); 00054 for (stdair::FareOptionList_T::const_iterator itFO = lFOList.begin(); 00055 itFO != lFOList.end(); ++itFO) { 00056 const stdair::FareOptionStruct& lFO = *itFO; 00057 const stdair::Fare_T& lFOFare = lFO.getFare(); 00058 00059 // Check the value of the disutility of the fare option 00060 stdair::Fare_T lFODisutility = 0; 00061 00062 // Check the change fees restriction 00063 if (lCustomerChangeFees == false) { 00064 const bool lFOChangeFees = lFO.getChangeFees(); 00065 if (lFOChangeFees == true){ 00066 lFODisutility += lChangeFeesDisutility; 00067 } 00068 } 00069 00070 // Check the non refundable restriction 00071 if (lCustomerNonRefundable == false) { 00072 const bool lFONonRefundable = lFO.getNonRefundable(); 00073 if (lFONonRefundable == true){ 00074 lFODisutility += lNonRefundableDisutility; 00075 } 00076 } 00077 00078 00079 // Choose the current fare option and the current solution 00080 // if the current fare with penalities is lower than the current 00081 // lowest fare. 00082 00083 const stdair::Availability_T& lFOAvl = lFO.getAvailability(); 00084 const stdair::Fare_T lFOFareWithinDisutility = lFOFare + lFODisutility; 00085 00086 if (lFOFareWithinDisutility < lLowestFare 00087 && lFOFare <= lWTP 00088 && lFOAvl >= lPartySize) { 00089 00090 // DEBUG 00091 00092 // STDAIR_LOG_DEBUG ("The travel solution (TS) '" << lTS 00093 // << "' is chosen because its fare with disutility (" 00094 // << lFOFare + lFODisutility 00095 // << ") is lower than the lowest fare (" << lLowestFare 00096 // << ") and because its fare ("<< lFOFare 00097 // << ") is lower than the WTP (" << lWTP 00098 // << "), and because the party size (" << lPartySize 00099 // << ") is lower than the availability (" << lFOAvl 00100 // << ")"); 00101 00102 00103 lLowestFare = lFOFare + lFODisutility; 00104 oChosenTS_ptr = &lTS; 00105 oChosenTS_ptr->setChosenFareOption (lFO); 00106 00107 } else { 00108 // DEBUG 00109 00110 // STDAIR_LOG_DEBUG ("The travel solution (TS) '" << lTS 00111 // << "' is not chosen because either its fare with disutility (" 00112 // << lFOFare + lFODisutility << ") is greater than the " 00113 // << "lowest fare (" << lLowestFare << "), or because its fare (" 00114 // << lFOFare << ") " << "is greater than the WTP (" << lWTP 00115 // << "), or because the party size (" << lPartySize 00116 // << ") is greater than the availability (" << lFOAvl 00117 // << ")"); 00118 00119 } 00120 } 00121 } 00122 00123 return oChosenTS_ptr; 00124 } 00125 00126 }