TraDemGen Logo  0.2.2
C++ Simulated Travel Demand Generation Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
DemandStruct.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/basic/BasConst_Inventory.hpp>
9 #include <stdair/basic/BasConst_Period_BOM.hpp>
10 #include <stdair/service/Logger.hpp>
11 // TRADEMGEN
14 
15 namespace TRADEMGEN {
16 
17  // ////////////////////////////////////////////////////////////////////
19  : _dateRange (stdair::BOOST_DEFAULT_DATE_PERIOD),
20  _dow (stdair::DEFAULT_DOW_STRING),
21  _prefCabin (stdair::DEFAULT_CABIN_CODE),
22  _itHours (0), _itMinutes (0), _itSeconds (0), _itFFCode ("") {
23  }
24 
25  // ////////////////////////////////////////////////////////////////////
27  }
28 
29  // ////////////////////////////////////////////////////////////////////
30  stdair::Date_T DemandStruct::getDate() const {
31  return stdair::Date_T (_itYear, _itMonth, _itDay);
32  }
33 
34  // ////////////////////////////////////////////////////////////////////
35  stdair::Duration_T DemandStruct::getTime() const {
36  return boost::posix_time::hours (_itHours)
37  + boost::posix_time::minutes (_itMinutes)
38  + boost::posix_time::seconds (_itSeconds);
39  }
40 
41  // ////////////////////////////////////////////////////////////////////
42  const std::string DemandStruct::describe() const {
43  std::ostringstream ostr;
44  ostr << _dateRange << " - " << _dow
45  << " " << _origin << "-" << _destination
46  << " " << _prefCabin
47  << ", N(" << _demandMean << ", " << _demandStdDev << "); ";
48 
49  unsigned short idx = 0;
50  for (POSProbabilityMassFunction_T::const_iterator it = _posProbDist.begin();
51  it != _posProbDist.end(); ++it, ++idx) {
52  const stdair::AirportCode_T& lPosCode = it->first;
53  const stdair::Probability_T& lPosProbMass = it->second;
54  if (idx != 0) {
55  ostr << ", ";
56  }
57  ostr << lPosCode << ":" << lPosProbMass;
58  }
59  ostr << "; ";
60 
61  idx = 0;
62  for (ChannelProbabilityMassFunction_T::const_iterator it =
63  _channelProbDist.begin();
64  it != _channelProbDist.end(); ++it, ++idx) {
65  const stdair::ChannelLabel_T lChannelCode = it->first;
66  const stdair::Probability_T& lChannelProbMass = it->second;
67  if (idx != 0) {
68  ostr << ", ";
69  }
70  ostr << lChannelCode << ":" << lChannelProbMass;
71  }
72  ostr << "; ";
73 
74  idx = 0;
75  for (TripTypeProbabilityMassFunction_T::const_iterator it =
76  _tripProbDist.begin();
77  it != _tripProbDist.end(); ++it, ++idx) {
78  const stdair::TripType_T lTripCode = it->first;
79  const stdair::Probability_T& lTripProbMass = it->second;
80  if (idx != 0) {
81  ostr << ", ";
82  }
83  ostr << lTripCode << ":" << lTripProbMass;
84  }
85  ostr << "; ";
86 
87  idx = 0;
88  for (StayDurationProbabilityMassFunction_T::const_iterator it =
89  _stayProbDist.begin();
90  it != _stayProbDist.end(); ++it, ++idx) {
91  const stdair::DayDuration_T& lStayDuration = it->first;
92  const stdair::Probability_T& lStayProbMass = it->second;
93  if (idx != 0) {
94  ostr << ", ";
95  }
96  ostr << lStayDuration << ":" << lStayProbMass;
97  }
98  ostr << "; ";
99 
100  idx = 0;
101  for (FrequentFlyerProbabilityMassFunction_T::const_iterator it =
102  _ffProbDist.begin();
103  it != _ffProbDist.end(); ++it, ++idx) {
104  const stdair::FrequentFlyer_T lFFCode = it->first;
105  const stdair::Probability_T& lFFProbMass = it->second;
106  if (idx != 0) {
107  ostr << ", ";
108  }
109  ostr << lFFCode << ":" << lFFProbMass;
110  }
111  ostr << "; ";
112 
113  idx = 0;
114  for (PreferredDepartureTimeContinuousDistribution_T::const_iterator it =
115  _prefDepTimeProbDist.begin();
116  it != _prefDepTimeProbDist.end(); ++it, ++idx) {
117  const stdair::IntDuration_T& lPrefDepTime = it->first;
118  const stdair::Probability_T& lPrefDepTimeProbMass = it->second;
119  if (idx != 0) {
120  ostr << ", ";
121  }
122  ostr << lPrefDepTime << ":" << lPrefDepTimeProbMass;
123  }
124  ostr << "; ";
125 
126  ostr << _minWTP << "; ";
127 
128  idx = 0;
129  for (ValueOfTimeContinuousDistribution_T::const_iterator it =
130  _timeValueProbDist.begin();
131  it != _timeValueProbDist.end(); ++it, ++idx) {
132  const stdair::PriceValue_T& lTimeValue = it->first;
133  const stdair::Probability_T& lTimeValueProbMass = it->second;
134  if (idx != 0) {
135  ostr << ", ";
136  }
137  ostr << lTimeValue << ":" << lTimeValueProbMass;
138  }
139  ostr << "; ";
140 
141  idx = 0;
142  for (ArrivalPatternCumulativeDistribution_T::const_iterator it =
143  _dtdProbDist.begin(); it != _dtdProbDist.end(); ++it, ++idx) {
144  const stdair::FloatDuration_T& lDTD = it->first;
145  const stdair::Probability_T& lDTDProbMass = it->second;
146  if (idx != 0) {
147  ostr << ", ";
148  }
149  ostr << lDTD << ":" << lDTDProbMass;
150  }
151  ostr << "; ";
152 
153  return ostr.str();
154  }
155 
156 }