$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_Inventory.hpp> 00009 #include <stdair/basic/BasConst_Period_BOM.hpp> 00010 #include <stdair/service/Logger.hpp> 00011 // TRADEMGEN 00012 #include <trademgen/TRADEMGEN_Types.hpp> 00013 #include <trademgen/bom/DemandStruct.hpp> 00014 00015 namespace TRADEMGEN { 00016 00017 // //////////////////////////////////////////////////////////////////// 00018 DemandStruct::DemandStruct() 00019 : _dateRange (stdair::BOOST_DEFAULT_DATE_PERIOD), 00020 _dow (stdair::DEFAULT_DOW_STRING), 00021 _prefCabin (stdair::DEFAULT_CABIN_CODE), 00022 _itHours (0), _itMinutes (0), _itSeconds (0), _itFFCode ("") { 00023 } 00024 00025 // //////////////////////////////////////////////////////////////////// 00026 DemandStruct::~DemandStruct() { 00027 } 00028 00029 // //////////////////////////////////////////////////////////////////// 00030 stdair::Date_T DemandStruct::getDate() const { 00031 return stdair::Date_T (_itYear, _itMonth, _itDay); 00032 } 00033 00034 // //////////////////////////////////////////////////////////////////// 00035 stdair::Duration_T DemandStruct::getTime() const { 00036 return boost::posix_time::hours (_itHours) 00037 + boost::posix_time::minutes (_itMinutes) 00038 + boost::posix_time::seconds (_itSeconds); 00039 } 00040 00041 // //////////////////////////////////////////////////////////////////// 00042 const std::string DemandStruct::describe() const { 00043 std::ostringstream ostr; 00044 ostr << _dateRange << " - " << _dow 00045 << " " << _origin << "-" << _destination 00046 << " " << _prefCabin 00047 << ", N(" << _demandMean << ", " << _demandStdDev << "); "; 00048 00049 unsigned short idx = 0; 00050 for (POSProbabilityMassFunction_T::const_iterator it = _posProbDist.begin(); 00051 it != _posProbDist.end(); ++it, ++idx) { 00052 const stdair::AirportCode_T& lPosCode = it->first; 00053 const stdair::Probability_T& lPosProbMass = it->second; 00054 if (idx != 0) { 00055 ostr << ", "; 00056 } 00057 ostr << lPosCode << ":" << lPosProbMass; 00058 } 00059 ostr << "; "; 00060 00061 idx = 0; 00062 for (ChannelProbabilityMassFunction_T::const_iterator it = 00063 _channelProbDist.begin(); 00064 it != _channelProbDist.end(); ++it, ++idx) { 00065 const stdair::ChannelLabel_T lChannelCode = it->first; 00066 const stdair::Probability_T& lChannelProbMass = it->second; 00067 if (idx != 0) { 00068 ostr << ", "; 00069 } 00070 ostr << lChannelCode << ":" << lChannelProbMass; 00071 } 00072 ostr << "; "; 00073 00074 idx = 0; 00075 for (TripTypeProbabilityMassFunction_T::const_iterator it = 00076 _tripProbDist.begin(); 00077 it != _tripProbDist.end(); ++it, ++idx) { 00078 const stdair::TripType_T lTripCode = it->first; 00079 const stdair::Probability_T& lTripProbMass = it->second; 00080 if (idx != 0) { 00081 ostr << ", "; 00082 } 00083 ostr << lTripCode << ":" << lTripProbMass; 00084 } 00085 ostr << "; "; 00086 00087 idx = 0; 00088 for (StayDurationProbabilityMassFunction_T::const_iterator it = 00089 _stayProbDist.begin(); 00090 it != _stayProbDist.end(); ++it, ++idx) { 00091 const stdair::DayDuration_T& lStayDuration = it->first; 00092 const stdair::Probability_T& lStayProbMass = it->second; 00093 if (idx != 0) { 00094 ostr << ", "; 00095 } 00096 ostr << lStayDuration << ":" << lStayProbMass; 00097 } 00098 ostr << "; "; 00099 00100 idx = 0; 00101 for (FrequentFlyerProbabilityMassFunction_T::const_iterator it = 00102 _ffProbDist.begin(); 00103 it != _ffProbDist.end(); ++it, ++idx) { 00104 const stdair::FrequentFlyer_T lFFCode = it->first; 00105 const stdair::Probability_T& lFFProbMass = it->second; 00106 if (idx != 0) { 00107 ostr << ", "; 00108 } 00109 ostr << lFFCode << ":" << lFFProbMass; 00110 } 00111 ostr << "; "; 00112 00113 ostr << _changeFeeProb << "; "; 00114 00115 ostr << "; "; 00116 00117 ostr << _nonRefundableProb << "; "; 00118 00119 idx = 0; 00120 for (PreferredDepartureTimeContinuousDistribution_T::const_iterator it = 00121 _prefDepTimeProbDist.begin(); 00122 it != _prefDepTimeProbDist.end(); ++it, ++idx) { 00123 const stdair::IntDuration_T& lPrefDepTime = it->first; 00124 const stdair::Probability_T& lPrefDepTimeProbMass = it->second; 00125 if (idx != 0) { 00126 ostr << ", "; 00127 } 00128 ostr << lPrefDepTime << ":" << lPrefDepTimeProbMass; 00129 } 00130 ostr << "; "; 00131 00132 ostr << _minWTP << "; "; 00133 00134 idx = 0; 00135 for (ValueOfTimeContinuousDistribution_T::const_iterator it = 00136 _timeValueProbDist.begin(); 00137 it != _timeValueProbDist.end(); ++it, ++idx) { 00138 const stdair::PriceValue_T& lTimeValue = it->first; 00139 const stdair::Probability_T& lTimeValueProbMass = it->second; 00140 if (idx != 0) { 00141 ostr << ", "; 00142 } 00143 ostr << lTimeValue << ":" << lTimeValueProbMass; 00144 } 00145 ostr << "; "; 00146 00147 idx = 0; 00148 for (ArrivalPatternCumulativeDistribution_T::const_iterator it = 00149 _dtdProbDist.begin(); it != _dtdProbDist.end(); ++it, ++idx) { 00150 const stdair::FloatDuration_T& lDTD = it->first; 00151 const stdair::Probability_T& lDTDProbMass = it->second; 00152 if (idx != 0) { 00153 ostr << ", "; 00154 } 00155 ostr << lDTD << ":" << lDTDProbMass; 00156 } 00157 ostr << "; "; 00158 00159 return ostr.str(); 00160 } 00161 00162 }