TravelCCM Logo  1.00.3
C++ Travel Customer Choice Model Library
PriceOrientedModel.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
8 #include <stdair/bom/BomKeyManager.hpp>
9 #include <stdair/bom/BookingClassKey.hpp>
10 #include <stdair/bom/BookingRequestStruct.hpp>
11 #include <stdair/bom/TravelSolutionStruct.hpp>
12 #include <stdair/bom/FareOptionStruct.hpp>
13 #include <stdair/service/Logger.hpp>
14 // TravelCCM
16 
17 namespace TRAVELCCM {
18 
19  // ////////////////////////////////////////////////////////////////////
20  // Initialization of the static member
21  const PriceOrientedModel PriceOrientedModel::_priceOrientedModel;
22 
23  // ////////////////////////////////////////////////////////////////////
25  CustomerChoiceModel(stdair::PassengerChoiceModel::PRICE_ORIENTED) {
26  }
27 
28  // ////////////////////////////////////////////////////////////////////
30  }
31 
32  // ////////////////////////////////////////////////////////////////////
33  const stdair::TravelSolutionStruct* PriceOrientedModel::
34  chooseTravelSolution (stdair::TravelSolutionList_T& ioTSList,
35  const stdair::BookingRequestStruct& iBookingRequest) const {
36  stdair::TravelSolutionStruct* oChosenTS_ptr = NULL;
37 
38  // Retrieve the number of passengers
39  const stdair::NbOfSeats_T& lPartySize = iBookingRequest.getPartySize();
40 
41  // Retrieve the Willingness-to-Pay (WTP) of the customer
42  const stdair::WTP_T& lWTP = iBookingRequest.getWTP();
43 
44  // Browse the travel solution list and choose the cheapest one
45  stdair::Fare_T lLowestFare = std::numeric_limits<stdair::Fare_T>::max();
46  for (stdair::TravelSolutionList_T::iterator itTS = ioTSList.begin();
47  itTS != ioTSList.end(); ++itTS) {
48  stdair::TravelSolutionStruct& lTS = *itTS;
49 
50  // Browse the fare options
51  const stdair::FareOptionList_T& lFOList = lTS.getFareOptionList();
52  for (stdair::FareOptionList_T::const_iterator itFO = lFOList.begin();
53  itFO != lFOList.end(); ++itFO) {
54  const stdair::FareOptionStruct& lFO = *itFO;
55 
56  // Choose the current fare option and the current solution
57  // if the current fare is lower than the current lowest fare.
58  const stdair::Fare_T& lFOFare = lFO.getFare();
59  const stdair::Availability_T& lFOAvl = lFO.getAvailability();
60 
61  if (lFOFare < lLowestFare && lFOFare <= lWTP && lFOAvl >= lPartySize) {
62 
63  // DEBUG
64  /*
65  STDAIR_LOG_DEBUG ("The travel solution (TS) '" << lTS
66  << "' is chosen because its fare (" << lFOFare
67  << ") is lower than the lowest fare (" << lLowestFare
68  << ") and than the WTP (" << lWTP
69  << "), and because the party size (" << lPartySize
70  << ") is lower than the availability (" << lFOAvl
71  << ")");
72  */
73 
74  lLowestFare = lFOFare;
75  oChosenTS_ptr = &lTS;
76  oChosenTS_ptr->setChosenFareOption (lFO);
77 
78  } else {
79  // DEBUG
80  /*
81  STDAIR_LOG_DEBUG ("The travel solution (TS) '" << lTS
82  << "' is not chosen because either its fare ("
83  << lFOFare << ") is greater than the lowest fare ("
84  << lLowestFare << ") or than the WTP (" << lWTP
85  << "), or because the party size (" << lPartySize
86  << ") is greater than the availability (" << lFOAvl
87  << ")");
88  */
89  }
90  }
91  }
92 
93  return oChosenTS_ptr;
94  }
95 
96 }
Forward declarations.
const stdair::TravelSolutionStruct * chooseTravelSolution(stdair::TravelSolutionList_T &, const stdair::BookingRequestStruct &) const