Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006 #include <sstream>
00007
00008 #include <stdair/basic/BasConst_Inventory.hpp>
00009 #include <stdair/basic/BasConst_Period_BOM.hpp>
00010 #include <stdair/service/Logger.hpp>
00011
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 idx = 0;
00114 for (PreferredDepartureTimeContinuousDistribution_T::const_iterator it =
00115 _prefDepTimeProbDist.begin();
00116 it != _prefDepTimeProbDist.end(); ++it, ++idx) {
00117 const stdair::IntDuration_T& lPrefDepTime = it->first;
00118 const stdair::Probability_T& lPrefDepTimeProbMass = it->second;
00119 if (idx != 0) {
00120 ostr << ", ";
00121 }
00122 ostr << lPrefDepTime << ":" << lPrefDepTimeProbMass;
00123 }
00124 ostr << "; ";
00125
00126 ostr << _minWTP << "; ";
00127
00128 idx = 0;
00129 for (ValueOfTimeContinuousDistribution_T::const_iterator it =
00130 _timeValueProbDist.begin();
00131 it != _timeValueProbDist.end(); ++it, ++idx) {
00132 const stdair::PriceValue_T& lTimeValue = it->first;
00133 const stdair::Probability_T& lTimeValueProbMass = it->second;
00134 if (idx != 0) {
00135 ostr << ", ";
00136 }
00137 ostr << lTimeValue << ":" << lTimeValueProbMass;
00138 }
00139 ostr << "; ";
00140
00141 idx = 0;
00142 for (ArrivalPatternCumulativeDistribution_T::const_iterator it =
00143 _dtdProbDist.begin(); it != _dtdProbDist.end(); ++it, ++idx) {
00144 const stdair::FloatDuration_T& lDTD = it->first;
00145 const stdair::Probability_T& lDTDProbMass = it->second;
00146 if (idx != 0) {
00147 ostr << ", ";
00148 }
00149 ostr << lDTD << ":" << lDTDProbMass;
00150 }
00151 ostr << "; ";
00152
00153 return ostr.str();
00154 }
00155
00156 }