StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
LegCabin.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
12 #include <stdair/bom/LegDate.hpp>
13 #include <stdair/bom/LegCabin.hpp>
14 
15 
16 namespace stdair {
17 
18  // ////////////////////////////////////////////////////////////////////
19  LegCabin::LegCabin() : _key (DEFAULT_CABIN_CODE), _parent (NULL) {
20  assert (false);
21  }
22 
23  // ////////////////////////////////////////////////////////////////////
24  LegCabin::LegCabin (const LegCabin& iLegCabin)
25  : _key (iLegCabin._key), _parent (NULL),
26  _offeredCapacity (iLegCabin._offeredCapacity),
27  _physicalCapacity (iLegCabin._physicalCapacity),
28  _soldSeat (iLegCabin._soldSeat),
29  _committedSpace (iLegCabin._committedSpace),
30  _availabilityPool (iLegCabin._availabilityPool),
31  _availability (iLegCabin._availability),
32  _currentBidPrice (iLegCabin._currentBidPrice),
33  _dcsRegrade (iLegCabin._dcsRegrade),
34  _au (iLegCabin._au),
35  _upr (iLegCabin._upr),
36  _nav (iLegCabin._nav),
37  _gav (iLegCabin._gav),
38  _acp (iLegCabin._acp),
39  _etb (iLegCabin._etb),
40  _staffNbOfBookings (iLegCabin._staffNbOfBookings),
41  _wlNbOfBookings (iLegCabin._wlNbOfBookings),
42  _groupNbOfBookings (iLegCabin._groupNbOfBookings) {
43  }
44 
45  // ////////////////////////////////////////////////////////////////////
46  LegCabin::LegCabin (const Key_T& iKey)
47  : _key (iKey), _parent (NULL),
48  _offeredCapacity (DEFAULT_CABIN_CAPACITY),
49  _physicalCapacity (DEFAULT_CABIN_CAPACITY),
50  _soldSeat (DEFAULT_CLASS_NB_OF_BOOKINGS),
51  _committedSpace (DEFAULT_COMMITTED_SPACE),
52  _availabilityPool (DEFAULT_AVAILABILITY),
53  _availability (DEFAULT_AVAILABILITY),
54  _currentBidPrice (DEFAULT_BID_PRICE),
55  _bidPriceVector (DEFAULT_BID_PRICE_VECTOR),
58  _upr (DEFAULT_NULL_UPR),
59  _nav (DEFAULT_AVAILABILITY),
60  _gav (DEFAULT_AVAILABILITY),
63  _staffNbOfBookings (DEFAULT_NULL_BOOKING_NUMBER),
64  _wlNbOfBookings (DEFAULT_NULL_BOOKING_NUMBER),
65  _groupNbOfBookings (DEFAULT_NULL_BOOKING_NUMBER) {
66  }
67 
68  // ////////////////////////////////////////////////////////////////////
70  }
71 
72  // ////////////////////////////////////////////////////////////////////
73  void LegCabin::setCapacities (const CabinCapacity_T& iCapacity) {
74  _offeredCapacity = iCapacity;
75  _physicalCapacity = iCapacity;
77  }
78 
79  // ////////////////////////////////////////////////////////////////////
81  const LegDate& lLegDate = BomManager::getParent<LegDate> (*this);
82 
83  const MapKey_T oFullKey =
85  return oFullKey;
86  }
87 
88  // ////////////////////////////////////////////////////////////////////
89  std::string LegCabin::toString() const {
90  std::ostringstream oStr;
91  oStr << describeKey();
92  return oStr.str();
93  }
94 
95  // ////////////////////////////////////////////////////////////////////
96  const std::string LegCabin::displayVirtualClassList () const {
97  std::ostringstream oStr;
98 
99  for (VirtualClassList_T::const_iterator itVC = _virtualClassList.begin();
100  itVC != _virtualClassList.end(); ++itVC) {
101  const VirtualClassStruct& lVC = *itVC;
102  oStr << std::endl << "Yield: " << std::fixed << std::setprecision (2)
103  << lVC.getYield()
104  << ", Protection: " << std::fixed << std::setprecision (2)
105  << lVC.getCumulatedProtection()
106  << ", Booking limit: " << std::fixed << std::setprecision (2)
107  << lVC.getCumulatedBookingLimit();
108  }
109 
110  return oStr.str();
111  }
112 
113  // ////////////////////////////////////////////////////////////////////
114  void LegCabin::updateFromReservation (const NbOfBookings_T& iNbOfBookings) {
115  _committedSpace += iNbOfBookings;
117  }
118 
119  // ////////////////////////////////////////////////////////////////////
121  const unsigned short lAvailabilityPool =
122  static_cast<unsigned short> (std::floor (_availabilityPool));
123 
124  if (lAvailabilityPool >= 1) {
125  const unsigned short lBidPriceVectorSize = _bidPriceVector.size();
126  if (lBidPriceVectorSize >= lAvailabilityPool) {
127  _currentBidPrice = _bidPriceVector.at (lAvailabilityPool - 1);
128  }
129  }
130  }
131 
132  // ////////////////////////////////////////////////////////////////////
134  const MeanValue_T& iMeanValue,
135  const StdDevValue_T& iStdDevValue) {
136  //
137  const int lYieldLevel =
138  static_cast<int> (std::floor (iYield + 0.5));
139 
140  //
141  YieldLevelDemandMap_T::iterator itDemand =
142  _yieldLevelDemandMap.find (lYieldLevel);
143 
144  if (itDemand == _yieldLevelDemandMap.end()) {
145  MeanStdDevPair_T lMeanStdDevPair (iMeanValue,iStdDevValue);
146  const bool hasInsertBeenSuccessful = _yieldLevelDemandMap.
147  insert (YieldLevelDemandMap_T::value_type (lYieldLevel,
148  lMeanStdDevPair)).second;
149  assert (hasInsertBeenSuccessful == true);
150 
151  } else {
152  //
153  MeanStdDevPair_T& lMeanStdDevPair = itDemand->second;
154  MeanValue_T lMeanValue = iMeanValue + lMeanStdDevPair.first;
155  StdDevValue_T lStdDevValue = iStdDevValue * iStdDevValue + lMeanStdDevPair.second * lMeanStdDevPair.second;
156  lStdDevValue = std::sqrt (lStdDevValue);
157 
158  //
159  lMeanStdDevPair = MeanStdDevPair_T (lMeanValue, lStdDevValue);
160  }
161  }
162 
163 }
164 
BidPrice_T _currentBidPrice
Definition: LegCabin.hpp:418
void updateFromReservation(const NbOfBookings_T &)
Definition: LegCabin.cpp:114
const BidPriceVector_T DEFAULT_BID_PRICE_VECTOR
Definition: BasConst.cpp:484
const BookingLimit_T & getCumulatedBookingLimit() const
void updateCurrentBidPrice()
Definition: LegCabin.cpp:120
BidPriceVector_T _bidPriceVector
Definition: LegCabin.hpp:424
Handle on the StdAir library context.
const CabinCapacity_T DEFAULT_CABIN_CAPACITY
const std::string describeKey() const
Definition: LegDate.hpp:207
const std::string DEFAULT_KEY_FLD_DELIMITER
const MapKey_T getFullerKey() const
Definition: LegCabin.cpp:80
YieldLevelDemandMap_T _yieldLevelDemandMap
Definition: LegCabin.hpp:430
NbOfRequests_T NbOfBookings_T
const std::string displayVirtualClassList() const
Definition: LegCabin.cpp:96
std::string MapKey_T
Definition: key_types.hpp:15
Availability_T _availabilityPool
Definition: LegCabin.hpp:412
const NbOfBookings_T DEFAULT_CLASS_NB_OF_BOOKINGS
const BidPrice_T DEFAULT_BID_PRICE
const Availability_T DEFAULT_AVAILABILITY
std::string toString() const
Definition: LegCabin.cpp:89
CabinCapacity_T _physicalCapacity
Definition: LegCabin.hpp:403
const CabinCode_T DEFAULT_CABIN_CODE
void setCapacities(const CabinCapacity_T &iCapacity)
Definition: LegCabin.cpp:73
double StdDevValue_T
double MeanValue_T
const CapacityAdjustment_T DEFAULT_NULL_CAPACITY_ADJUSTMENT
const CommittedSpace_T DEFAULT_COMMITTED_SPACE
CommittedSpace_T _committedSpace
Definition: LegCabin.hpp:409
void setAvailabilityPool(const Availability_T &iAvailabilityPool)
Definition: LegCabin.hpp:204
const ProtectionLevel_T & getCumulatedProtection() const
VirtualClassList_T _virtualClassList
Definition: LegCabin.hpp:427
const std::string describeKey() const
Definition: LegCabin.hpp:307
const NbOfSeats_T DEFAULT_NULL_BOOKING_NUMBER
void addDemandInformation(const YieldValue_T &, const MeanValue_T &, const StdDevValue_T &)
Definition: LegCabin.cpp:133
CabinCapacity_T _offeredCapacity
Definition: LegCabin.hpp:400
const CabinCode_T & getCabinCode() const
Definition: LegCabin.hpp:56
std::pair< MeanValue_T, StdDevValue_T > MeanStdDevPair_T
const AuthorizationLevel_T DEFAULT_CLASS_AUTHORIZATION_LEVEL
double YieldValue_T
const Yield_T & getYield() const
Key of a given leg-cabin, made of a cabin code (only).
Definition: LegCabinKey.hpp:26
const OverbookingRate_T DEFAULT_CLASS_OVERBOOKING_RATE
const UPR_T DEFAULT_NULL_UPR