$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_BookingClass.hpp> 00009 #include <stdair/basic/BasConst_Inventory.hpp> 00010 #include <stdair/basic/BasConst_BomDisplay.hpp> 00011 #include <stdair/bom/BomManager.hpp> 00012 #include <stdair/bom/LegDate.hpp> 00013 #include <stdair/bom/LegCabin.hpp> 00014 00015 00016 namespace stdair { 00017 00018 // //////////////////////////////////////////////////////////////////// 00019 LegCabin::LegCabin() : _key (DEFAULT_CABIN_CODE), _parent (NULL) { 00020 assert (false); 00021 } 00022 00023 // //////////////////////////////////////////////////////////////////// 00024 LegCabin::LegCabin (const LegCabin& iLegCabin) 00025 : _key (iLegCabin._key), _parent (NULL), 00026 _offeredCapacity (iLegCabin._offeredCapacity), 00027 _physicalCapacity (iLegCabin._physicalCapacity), 00028 _soldSeat (iLegCabin._soldSeat), 00029 _committedSpace (iLegCabin._committedSpace), 00030 _availabilityPool (iLegCabin._availabilityPool), 00031 _availability (iLegCabin._availability), 00032 _currentBidPrice (iLegCabin._currentBidPrice), 00033 _dcsRegrade (iLegCabin._dcsRegrade), 00034 _au (iLegCabin._au), 00035 _upr (iLegCabin._upr), 00036 _nav (iLegCabin._nav), 00037 _gav (iLegCabin._gav), 00038 _acp (iLegCabin._acp), 00039 _etb (iLegCabin._etb), 00040 _staffNbOfBookings (iLegCabin._staffNbOfBookings), 00041 _wlNbOfBookings (iLegCabin._wlNbOfBookings), 00042 _groupNbOfBookings (iLegCabin._groupNbOfBookings) { 00043 } 00044 00045 // //////////////////////////////////////////////////////////////////// 00046 LegCabin::LegCabin (const Key_T& iKey) 00047 : _key (iKey), _parent (NULL), 00048 _offeredCapacity (DEFAULT_CABIN_CAPACITY), 00049 _physicalCapacity (DEFAULT_CABIN_CAPACITY), 00050 _soldSeat (DEFAULT_CLASS_NB_OF_BOOKINGS), 00051 _committedSpace (DEFAULT_COMMITTED_SPACE), 00052 _availabilityPool (DEFAULT_AVAILABILITY), 00053 _availability (DEFAULT_AVAILABILITY), 00054 _currentBidPrice (DEFAULT_BID_PRICE), 00055 _bidPriceVector (DEFAULT_BID_PRICE_VECTOR), 00056 _dcsRegrade (DEFAULT_NULL_CAPACITY_ADJUSTMENT), 00057 _au (DEFAULT_CLASS_AUTHORIZATION_LEVEL), 00058 _upr (DEFAULT_NULL_UPR), 00059 _nav (DEFAULT_AVAILABILITY), 00060 _gav (DEFAULT_AVAILABILITY), 00061 _acp (DEFAULT_CLASS_OVERBOOKING_RATE), 00062 _etb (DEFAULT_NULL_BOOKING_NUMBER), 00063 _staffNbOfBookings (DEFAULT_NULL_BOOKING_NUMBER), 00064 _wlNbOfBookings (DEFAULT_NULL_BOOKING_NUMBER), 00065 _groupNbOfBookings (DEFAULT_NULL_BOOKING_NUMBER) { 00066 } 00067 00068 // //////////////////////////////////////////////////////////////////// 00069 LegCabin::~LegCabin() { 00070 } 00071 00072 // //////////////////////////////////////////////////////////////////// 00073 void LegCabin::setCapacities (const CabinCapacity_T& iCapacity) { 00074 _offeredCapacity = iCapacity; 00075 _physicalCapacity = iCapacity; 00076 setAvailabilityPool (iCapacity - _committedSpace); 00077 } 00078 00079 // //////////////////////////////////////////////////////////////////// 00080 const MapKey_T LegCabin::getFullerKey() const { 00081 const LegDate& lLegDate = BomManager::getParent<LegDate> (*this); 00082 00083 const MapKey_T oFullKey = 00084 lLegDate.describeKey() + DEFAULT_KEY_FLD_DELIMITER + getCabinCode(); 00085 return oFullKey; 00086 } 00087 00088 // //////////////////////////////////////////////////////////////////// 00089 std::string LegCabin::toString() const { 00090 std::ostringstream oStr; 00091 oStr << describeKey(); 00092 return oStr.str(); 00093 } 00094 00095 // //////////////////////////////////////////////////////////////////// 00096 const std::string LegCabin::displayVirtualClassList () const { 00097 std::ostringstream oStr; 00098 00099 for (VirtualClassList_T::const_iterator itVC = _virtualClassList.begin(); 00100 itVC != _virtualClassList.end(); ++itVC) { 00101 const VirtualClassStruct& lVC = *itVC; 00102 oStr << std::endl << "Yield: " << std::fixed << std::setprecision (2) 00103 << lVC.getYield() 00104 << ", Protection: " << std::fixed << std::setprecision (2) 00105 << lVC.getCumulatedProtection() 00106 << ", Booking limit: " << std::fixed << std::setprecision (2) 00107 << lVC.getCumulatedBookingLimit(); 00108 } 00109 00110 return oStr.str(); 00111 } 00112 00113 // //////////////////////////////////////////////////////////////////// 00114 void LegCabin::updateFromReservation (const NbOfBookings_T& iNbOfBookings) { 00115 _committedSpace += iNbOfBookings; 00116 _availabilityPool = _offeredCapacity - _committedSpace; 00117 } 00118 00119 // //////////////////////////////////////////////////////////////////// 00120 void LegCabin::updateCurrentBidPrice() { 00121 const unsigned short lAvailabilityPool = 00122 static_cast<unsigned short> (std::floor (_availabilityPool)); 00123 00124 if (lAvailabilityPool >= 1) { 00125 const unsigned short lBidPriceVectorSize = _bidPriceVector.size(); 00126 if (lBidPriceVectorSize >= lAvailabilityPool) { 00127 _currentBidPrice = _bidPriceVector.at (lAvailabilityPool - 1); 00128 } 00129 } 00130 } 00131 00132 // //////////////////////////////////////////////////////////////////// 00133 void LegCabin::addDemandInformation (const YieldValue_T& iYield, 00134 const MeanValue_T& iMeanValue, 00135 const StdDevValue_T& iStdDevValue) { 00136 // 00137 const int lYieldLevel = 00138 static_cast<int> (std::floor (iYield + 0.5)); 00139 00140 // 00141 YieldLevelDemandMap_T::iterator itDemand = 00142 _yieldLevelDemandMap.find (lYieldLevel); 00143 00144 if (itDemand == _yieldLevelDemandMap.end()) { 00145 MeanStdDevPair_T lMeanStdDevPair (iMeanValue,iStdDevValue); 00146 const bool hasInsertBeenSuccessful = _yieldLevelDemandMap. 00147 insert (YieldLevelDemandMap_T::value_type (lYieldLevel, 00148 lMeanStdDevPair)).second; 00149 assert (hasInsertBeenSuccessful == true); 00150 00151 } else { 00152 // 00153 MeanStdDevPair_T& lMeanStdDevPair = itDemand->second; 00154 MeanValue_T lMeanValue = iMeanValue + lMeanStdDevPair.first; 00155 StdDevValue_T lStdDevValue = iStdDevValue * iStdDevValue + lMeanStdDevPair.second * lMeanStdDevPair.second; 00156 lStdDevValue = std::sqrt (lStdDevValue); 00157 00158 // 00159 lMeanStdDevPair = MeanStdDevPair_T (lMeanValue, lStdDevValue); 00160 } 00161 } 00162 00163 } 00164