TraDemGen Logo  1.00.0
C++ Simulated Travel Demand Generation Library
 All Classes Namespaces Files Functions Variables Typedefs Friends 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  ostr << _changeFeeProb << "; ";
114 
115  ostr << "; ";
116 
117  ostr << _nonRefundableProb << "; ";
118 
119  idx = 0;
120  for (PreferredDepartureTimeContinuousDistribution_T::const_iterator it =
121  _prefDepTimeProbDist.begin();
122  it != _prefDepTimeProbDist.end(); ++it, ++idx) {
123  const stdair::IntDuration_T& lPrefDepTime = it->first;
124  const stdair::Probability_T& lPrefDepTimeProbMass = it->second;
125  if (idx != 0) {
126  ostr << ", ";
127  }
128  ostr << lPrefDepTime << ":" << lPrefDepTimeProbMass;
129  }
130  ostr << "; ";
131 
132  ostr << _minWTP << "; ";
133 
134  idx = 0;
135  for (ValueOfTimeContinuousDistribution_T::const_iterator it =
136  _timeValueProbDist.begin();
137  it != _timeValueProbDist.end(); ++it, ++idx) {
138  const stdair::PriceValue_T& lTimeValue = it->first;
139  const stdair::Probability_T& lTimeValueProbMass = it->second;
140  if (idx != 0) {
141  ostr << ", ";
142  }
143  ostr << lTimeValue << ":" << lTimeValueProbMass;
144  }
145  ostr << "; ";
146 
147  idx = 0;
148  for (ArrivalPatternCumulativeDistribution_T::const_iterator it =
149  _dtdProbDist.begin(); it != _dtdProbDist.end(); ++it, ++idx) {
150  const stdair::FloatDuration_T& lDTD = it->first;
151  const stdair::Probability_T& lDTDProbMass = it->second;
152  if (idx != 0) {
153  ostr << ", ";
154  }
155  ostr << lDTD << ":" << lDTDProbMass;
156  }
157  ostr << "; ";
158 
159  return ostr.str();
160  }
161 
162 }