TraDemGen Logo  0.2.2
C++ Simulated Travel Demand Generation Library
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
DemandManager.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 // StdAir
7 #include <stdair/basic/ProgressStatusSet.hpp>
8 #include <stdair/bom/BomManager.hpp>
9 #include <stdair/bom/EventStruct.hpp>
10 #include <stdair/bom/BookingRequestStruct.hpp>
11 #include <stdair/bom/EventQueue.hpp>
12 #include <stdair/bom/TravelSolutionStruct.hpp>
13 #include <stdair/bom/CancellationStruct.hpp>
14 #include <stdair/factory/FacBom.hpp>
15 #include <stdair/factory/FacBomManager.hpp>
16 #include <stdair/service/Logger.hpp>
17 // TraDemGen
23 
24 namespace TRADEMGEN {
25 
26  // //////////////////////////////////////////////////////////////////////
27  void DemandManager::
28  buildSampleBomStd (stdair::EventQueue& ioEventQueue,
29  stdair::RandomGeneration& ioSharedGenerator,
30  const POSProbabilityMass_T& iPOSProbMass) {
31 
32  // Key of the demand stream
33  const stdair::AirportCode_T lOrigin ("SIN");
34  const stdair::AirportCode_T lDestination ("BKK");
35  const stdair::Date_T lDepDate (2011, 2, 14);
36  const stdair::CabinCode_T lCabin ("Y");
37 
38  //
39  const DemandStreamKey lDemandStreamKey (lOrigin, lDestination, lDepDate,
40  lCabin);
41 
42  // DEBUG
43  // STDAIR_LOG_DEBUG ("Demand stream key: " << lDemandStreamKey.describe());
44 
45  // Distribution for the number of requests
46  const stdair::MeanValue_T lDemandMean (10.0);
47  const stdair::StdDevValue_T lDemandStdDev (1.0);
48  const DemandDistribution lDemandDistribution (lDemandMean, lDemandStdDev);
49 
50  // Seed
51  const stdair::RandomSeed_T& lRequestDateTimeSeed =
52  generateSeed (ioSharedGenerator);
53  const stdair::RandomSeed_T& lDemandCharacteristicsSeed =
54  generateSeed (ioSharedGenerator);
55 
56  //
58  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-330,
59  0));
60  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-40,
61  0.2));
62  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-20,
63  0.6));
64  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-1,
65  1.0));
66  //
67  POSProbabilityMassFunction_T lPOSProbDist;
68  lPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("BKK", 0.3));
69  lPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("SIN", 0.7));
70  //
71  ChannelProbabilityMassFunction_T lChannelProbDist;
72  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("DF",
73  0.1));
74  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("DN",
75  0.3));
76  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("IF",
77  0.4));
78  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("IN",
79  0.2));
80  //
82  lTripProbDist.insert (TripTypeProbabilityMassFunction_T::value_type ("RO",
83  0.6));
84  lTripProbDist.insert (TripTypeProbabilityMassFunction_T::value_type ("RI",
85  0.2));
86  lTripProbDist.insert (TripTypeProbabilityMassFunction_T::value_type ("OW",
87  0.2));
88  //
90  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(0,
91  0.1));
92  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(1,
93  0.1));
94  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(2,
95  .15));
96  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(3,
97  .15));
98  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(4,
99  .15));
100  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(5,
101  .35));
102  //
104  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("P",
105  0.01));
106  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("G",
107  0.05));
108  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("S",
109  0.15));
110  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("M",
111  0.3));
112  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("N",
113  0.49));
114  //
116  lPrefDepTimeProbDist.
117  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (6, 0));
118  lPrefDepTimeProbDist.
119  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (7,
120  0.1));
121  lPrefDepTimeProbDist.
122  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (9,
123  0.3));
124  lPrefDepTimeProbDist.
125  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (17,
126  0.4));
127  lPrefDepTimeProbDist.
128  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (19,
129  0.80));
130  lPrefDepTimeProbDist.
131  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (20,
132  0.95));
133  lPrefDepTimeProbDist.
134  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (22,
135  1));
136  //
137  ValueOfTimeContinuousDistribution_T lTimeValueProbDist;
138  lTimeValueProbDist.insert(ValueOfTimeContinuousDistribution_T::value_type(15,
139  0));
140  lTimeValueProbDist.insert(ValueOfTimeContinuousDistribution_T::value_type(60,
141  1));
142 
143  //
144  const stdair::WTP_T lWTP (1000.0);
145 
146 
147  // Delegate the call to the dedicated command
148  DemandStream& lDemandStream =
149  createDemandStream (ioEventQueue, lDemandStreamKey, lDTDProbDist,
150  lPOSProbDist, lChannelProbDist, lTripProbDist,
151  lStayProbDist, lFFProbDist, lPrefDepTimeProbDist,
152  lWTP, lTimeValueProbDist, lDemandDistribution,
153  ioSharedGenerator.getBaseGenerator(),
154  lRequestDateTimeSeed,
155  lDemandCharacteristicsSeed, iPOSProbMass);
156 
157  // Calculate the expected total number of events for the current
158  // demand stream
159  const stdair::NbOfRequests_T& lExpectedTotalNbOfEvents =
160  lDemandStream.getMeanNumberOfRequests();
161 
165  ioEventQueue.addStatus (stdair::EventType::BKG_REQ,
166  lExpectedTotalNbOfEvents);
167  }
168 
169  // //////////////////////////////////////////////////////////////////////
170  DemandStream& DemandManager::createDemandStream
171  (stdair::EventQueue& ioEventQueue,
172  const DemandStreamKey& iKey,
173  const ArrivalPatternCumulativeDistribution_T& iArrivalPattern,
174  const POSProbabilityMassFunction_T& iPOSProbMass,
175  const ChannelProbabilityMassFunction_T& iChannelProbMass,
176  const TripTypeProbabilityMassFunction_T& iTripTypeProbMass,
177  const StayDurationProbabilityMassFunction_T& iStayDurationProbMass,
178  const FrequentFlyerProbabilityMassFunction_T& iFrequentFlyerProbMass,
179  const PreferredDepartureTimeContinuousDistribution_T& iPreferredDepartureTimeContinuousDistribution,
180  const stdair::WTP_T& iMinWTP,
181  const ValueOfTimeContinuousDistribution_T& iValueOfTimeContinuousDistribution,
182  const DemandDistribution& iDemandDistribution,
183  stdair::BaseGenerator_T& ioSharedGenerator,
184  const stdair::RandomSeed_T& iRequestDateTimeSeed,
185  const stdair::RandomSeed_T& iDemandCharacteristicsSeed,
186  const POSProbabilityMass_T& iDefaultPOSProbablityMass) {
187 
188  DemandStream& oDemandStream =
189  stdair::FacBom<DemandStream>::instance().create (iKey);
190 
191  oDemandStream.setAll (iArrivalPattern, iPOSProbMass,
192  iChannelProbMass, iTripTypeProbMass,
193  iStayDurationProbMass, iFrequentFlyerProbMass,
194  iPreferredDepartureTimeContinuousDistribution,
195  iMinWTP, iValueOfTimeContinuousDistribution,
196  iDemandDistribution, ioSharedGenerator,
197  iRequestDateTimeSeed, iDemandCharacteristicsSeed,
198  iDefaultPOSProbablityMass);
199 
200  // Link the DemandStream to its parent (EventQueue)
201  stdair::FacBomManager::linkWithParent (ioEventQueue, oDemandStream);
202 
203  // Add the DemandStream to the dedicated list and map
204  stdair::FacBomManager::addToListAndMap (ioEventQueue, oDemandStream);
205 
206  return oDemandStream;
207  }
208 
209  // //////////////////////////////////////////////////////////////////////
210  void DemandManager::
211  createDemandCharacteristics (stdair::EventQueue& ioEventQueue,
212  stdair::RandomGeneration& ioSharedGenerator,
213  const POSProbabilityMass_T& iPOSProbMass,
214  const DemandStruct& iDemand) {
215  stdair::BaseGenerator_T& lSharedGenerator =
216  ioSharedGenerator.getBaseGenerator();
217 
218  // Parse the date period and DoW and generate demand characteristics.
219  const stdair::DatePeriod_T lDateRange = iDemand._dateRange;
220  for (boost::gregorian::day_iterator itDate = lDateRange.begin();
221  itDate != lDateRange.end(); ++itDate) {
222  const stdair::Date_T& currentDate = *itDate;
223 
224  // Retrieve, for the current day, the Day-Of-the-Week (thanks to Boost)
225  const unsigned short currentDoW = currentDate.day_of_week().as_number();
226 
227  // The demand structure stores which Days (-Of-the-Week) are
228  // active within the week. For each day (Mon., Tue., etc.), a boolean
229  // states whether the Flight is active for that day.
230  const stdair::DoWStruct& lDoWList = iDemand._dow;
231  const bool isDoWActive = lDoWList.getStandardDayOfWeek (currentDoW);
232 
233  if (isDoWActive == true) {
234  const DemandStreamKey lDemandStreamKey (iDemand._origin,
235  iDemand._destination,
236  currentDate,
237  iDemand._prefCabin);
238  // DEBUG
239  // STDAIR_LOG_DEBUG ("Demand stream key: " << lDemandStreamKey.describe());
240 
241  //
242  const DemandDistribution lDemandDistribution (iDemand._demandMean,
243  iDemand._demandStdDev);
244 
245  // Seed
246  const stdair::RandomSeed_T& lRequestDateTimeSeed =
247  generateSeed (ioSharedGenerator);
248  const stdair::RandomSeed_T& lDemandCharacteristicsSeed =
249  generateSeed (ioSharedGenerator);
250 
251  // Delegate the call to the dedicated command
252  DemandStream& lDemandStream =
253  createDemandStream (ioEventQueue, lDemandStreamKey,
254  iDemand._dtdProbDist, iDemand._posProbDist,
255  iDemand._channelProbDist,
256  iDemand._tripProbDist,
257  iDemand._stayProbDist, iDemand._ffProbDist,
258  iDemand._prefDepTimeProbDist,
259  iDemand._minWTP,
260  iDemand._timeValueProbDist,
261  lDemandDistribution, lSharedGenerator,
262  lRequestDateTimeSeed,
263  lDemandCharacteristicsSeed,
264  iPOSProbMass);
265 
266  // Calculate the expected total number of events for the current
267  // demand stream
268  const stdair::NbOfRequests_T& lExpectedTotalNbOfEvents =
269  lDemandStream.getMeanNumberOfRequests();
270 
275  ioEventQueue.addStatus (stdair::EventType::BKG_REQ,
276  lExpectedTotalNbOfEvents);
277  }
278  }
279  }
280 
281  // ////////////////////////////////////////////////////////////////////
282  stdair::RandomSeed_T DemandManager::
283  generateSeed (stdair::RandomGeneration& ioSharedGenerator) {
284  stdair::RealNumber_T lVariateUnif = ioSharedGenerator() * 1e9;
285  stdair::RandomSeed_T oSeed = static_cast<stdair::RandomSeed_T>(lVariateUnif);
286  return oSeed;
287  }
288 
289  // ////////////////////////////////////////////////////////////////////
290  const bool DemandManager::
291  stillHavingRequestsToBeGenerated (const stdair::EventQueue& iEventQueue,
292  const stdair::DemandStreamKeyStr_T& iKey,
293  stdair::ProgressStatusSet& ioPSS,
294  const stdair::DemandGenerationMethod& iDemandGenerationMethod) {
295  // Retrieve the DemandStream which corresponds to the given key.
296  const DemandStream& lDemandStream =
297  stdair::BomManager::getObject<DemandStream> (iEventQueue, iKey);
298 
299  // Retrieve the progress status of the demand stream.
300  stdair::ProgressStatus
301  lProgressStatus (lDemandStream.getNumberOfRequestsGeneratedSoFar(),
302  lDemandStream.getMeanNumberOfRequests(),
303  lDemandStream.getTotalNumberOfRequestsToBeGenerated());
304  ioPSS.setSpecificGeneratorStatus (lProgressStatus, iKey);
305 
306  return lDemandStream.stillHavingRequestsToBeGenerated (iDemandGenerationMethod);
307  }
308 
309  // ////////////////////////////////////////////////////////////////////
310  stdair::BookingRequestPtr_T DemandManager::
311  generateNextRequest (stdair::EventQueue& ioEventQueue,
312  stdair::RandomGeneration& ioGenerator,
313  const stdair::DemandStreamKeyStr_T& iKey,
314  const stdair::DemandGenerationMethod& iDemandGenerationMethod) {
315 
316  // Retrieve the DemandStream which corresponds to the given key.
317  DemandStream& lDemandStream =
318  stdair::BomManager::getObject<DemandStream> (ioEventQueue, iKey);
319 
320  // Generate the next booking request
321  stdair::BookingRequestPtr_T lBookingRequest =
322  lDemandStream.generateNextRequest (ioGenerator,
323  iDemandGenerationMethod);
324 
325  // Create an event structure
326  stdair::EventStruct lEventStruct (stdair::EventType::BKG_REQ,
327  lBookingRequest);
328 
336  ioEventQueue.addEvent (lEventStruct);
337 
338  return lBookingRequest;
339  }
340 
341  // ////////////////////////////////////////////////////////////////////
342  stdair::Count_T DemandManager::
343  generateFirstRequests (stdair::EventQueue& ioEventQueue,
344  stdair::RandomGeneration& ioGenerator,
345  const stdair::DemandGenerationMethod& iDemandGenerationMethod) {
346 
347  // Actual total number of events to be generated
348  stdair::NbOfRequests_T lActualTotalNbOfEvents = 0.0;
349 
350  // Retrieve the DemandStream list
351  const DemandStreamList_T& lDemandStreamList =
352  stdair::BomManager::getList<DemandStream> (ioEventQueue);
353 
354  for (DemandStreamList_T::const_iterator itDemandStream =
355  lDemandStreamList.begin();
356  itDemandStream != lDemandStreamList.end(); ++itDemandStream) {
357  DemandStream* lDemandStream_ptr = *itDemandStream;
358  assert (lDemandStream_ptr != NULL);
359 
360  lDemandStream_ptr->setBoolFirstDateTimeRequest(true);
361 
362  // Calculate the expected total number of events for the current
363  // demand stream
364  const stdair::NbOfRequests_T& lActualNbOfEvents =
365  lDemandStream_ptr->getTotalNumberOfRequestsToBeGenerated();
366  lActualTotalNbOfEvents += lActualNbOfEvents;
367 
368  // Retrieve the key of the demand stream
369  const DemandStreamKey& lKey = lDemandStream_ptr->getKey();
370 
371  // Update the progress status for the given event type (i.e.,
372  // booking request)
373  ioEventQueue.updateStatus (stdair::EventType::BKG_REQ, lActualNbOfEvents);
374 
375  // Check whether there are still booking requests to be generated
376  const bool stillHavingRequestsToBeGenerated =
377  lDemandStream_ptr->stillHavingRequestsToBeGenerated (iDemandGenerationMethod);
378 
379  if (stillHavingRequestsToBeGenerated) {
380  // Generate the next event (booking request), and insert it
381  // into the event queue
382  generateNextRequest (ioEventQueue, ioGenerator, lKey.toString(),
383  iDemandGenerationMethod);
384  }
385  }
386 
387  // Update the actual total number of events to be generated
388  ioEventQueue.setActualTotalNbOfEvents (lActualTotalNbOfEvents);
389 
390  // Retrieve the actual total number of events to be generated
391  const stdair::Count_T oTotalNbOfEvents = std::floor (lActualTotalNbOfEvents);
392 
393  //
394  return oTotalNbOfEvents;
395  }
396 
397  // ////////////////////////////////////////////////////////////////////
398  void DemandManager::reset (stdair::EventQueue& ioEventQueue,
399  stdair::BaseGenerator_T& ioShareGenerator) {
400 
401  // TODO: check whether it is really necessary to destroy the
402  // objects manually. Indeed, FacSupervisor::cleanAll() should
403  // destroy any BOM object.
404 
405  // Reset all the DemandStream objects
406  const DemandStreamList_T& lDemandStreamList =
407  stdair::BomManager::getList<DemandStream> (ioEventQueue);
408  for (DemandStreamList_T::const_iterator itDS = lDemandStreamList.begin();
409  itDS != lDemandStreamList.end(); ++itDS) {
410  DemandStream* lCurrentDS_ptr = *itDS;
411  assert (lCurrentDS_ptr != NULL);
412 
413  lCurrentDS_ptr->reset (ioShareGenerator);
414  }
415 
423  ioEventQueue.reset();
424  }
425 
426 
427  // ////////////////////////////////////////////////////////////////////
428  bool DemandManager::
429  generateCancellation (stdair::EventQueue& ioEventQueue,
430  stdair::RandomGeneration& ioGenerator,
431  const stdair::TravelSolutionStruct& iTravelSolution,
432  const stdair::PartySize_T& iPartySize,
433  const stdair::DateTime_T& iRequestTime,
434  const stdair::Date_T& iDepartureDate) {
435 
436  // Draw a random number to decide if we generate a
437  // cancellation. For instance, the probability will be hardcoded.
438  // The cancellation time will be generated uniformly.
439  double lRandomNumber = ioGenerator();
440 
441  if (lRandomNumber >= 0.5) {
442  return false;
443  }
444  lRandomNumber /= 0.5;
445 
446  // Hardcode the latest cancellation time.
447  const stdair::Time_T lMidNight =
448  boost::posix_time::hours (0);
449  const stdair::DateTime_T lDepartureDateTime =
450  boost::posix_time::ptime (iDepartureDate, lMidNight);
451 
452  // Time to departure.
453  const stdair::Duration_T lTimeToDeparture = lDepartureDateTime-iRequestTime;
454 
455  // Cancellation time to departure
456  const long lTimeToDepartureInSeconds = lTimeToDeparture.total_seconds();
457  const long lCancellationTimeToDepartureInSeconds =
458  static_cast<long> (lTimeToDepartureInSeconds * lRandomNumber);
459  const stdair::Duration_T lCancellationTimeToDeparture (0, 0, lCancellationTimeToDepartureInSeconds);
460 
461  // Cancellation time
462  const stdair::DateTime_T lCancellationTime =
463  lDepartureDateTime - lCancellationTimeToDeparture;
464 
465  // Retrieve the segment path
466  const stdair::SegmentPath_T lSegmentPath = iTravelSolution.getSegmentPath();
467 
468  // Hardcoded class path
469  const stdair::FareOptionStruct& lChosenFareOption =
470  iTravelSolution.getChosenFareOption ();
471  const stdair::ClassList_StringList_T& lClassPath =
472  lChosenFareOption.getClassPath();
473  std::ostringstream oStr;
474  for (stdair::ClassList_StringList_T::const_iterator itClassList =
475  lClassPath.begin(); itClassList != lClassPath.end(); ++itClassList) {
476  const stdair::ClassList_String_T& lClassList = *itClassList;
477  assert (lClassList.size() > 0);
478  oStr << lClassList.at(0);
479  }
480  const stdair::ClassList_String_T lClassList_String = oStr.str();
481 
482  // Create the cancellation.
483  stdair::CancellationPtr_T lCancellation_ptr =
484  stdair::CancellationPtr_T
485  (new stdair::CancellationStruct (lSegmentPath, lClassList_String,
486  iPartySize, lCancellationTime));
487 
488  // Create an event structure
489  stdair::EventStruct lEventStruct (stdair::EventType::CX, lCancellation_ptr);
490 
498  ioEventQueue.addEvent (lEventStruct);
499 
500  return true;
501  }
502 
503  // //////////////////////////////////////////////////////////////////////
504  void DemandManager::
505  buildSampleBom (stdair::EventQueue& ioEventQueue,
506  stdair::RandomGeneration& ioSharedGenerator,
507  const POSProbabilityMass_T& iPOSProbMass) {
508 
509  //
511  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-330,
512  0));
513  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-150,
514  0.1));
515  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-92,
516  0.2));
517  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-55,
518  0.3));
519  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-34,
520  0.4));
521  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-21,
522  0.5));
523  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-12,
524  0.6));
525  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-6,
526  0.7));
527  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-3,
528  0.8));
529  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(-1,
530  0.9));
531  lDTDProbDist.insert(ArrivalPatternCumulativeDistribution_T::value_type(0,
532  1.0));
533 
534  //
535  ChannelProbabilityMassFunction_T lChannelProbDist;
536  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("DF",
537  0.0));
538  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("DN",
539  0.0));
540  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("IF",
541  0.0));
542  lChannelProbDist.insert (ChannelProbabilityMassFunction_T::value_type ("IN",
543  1.0));
544 
545  //
546  TripTypeProbabilityMassFunction_T lTripProbDist;
547  lTripProbDist.insert (TripTypeProbabilityMassFunction_T::value_type ("RO",
548  0.0));
549  lTripProbDist.insert (TripTypeProbabilityMassFunction_T::value_type ("RI",
550  0.0));
551  lTripProbDist.insert (TripTypeProbabilityMassFunction_T::value_type ("OW",
552  1.0));
553 
554  //
556  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(0,
557  0.1));
558  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(1,
559  0.1));
560  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(2,
561  .15));
562  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(3,
563  .15));
564  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(4,
565  .15));
566  lStayProbDist.insert(StayDurationProbabilityMassFunction_T::value_type(5,
567  .35));
568 
569  //
571  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("P",
572  0.1));
573  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("G",
574  0.01));
575  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("S",
576  0.09));
577  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("M",
578  0.4));
579  lFFProbDist.insert(FrequentFlyerProbabilityMassFunction_T::value_type("N",
580  0.4));
581 
582  //
583  ValueOfTimeContinuousDistribution_T lTimeValueProbDist;
584  lTimeValueProbDist.insert(ValueOfTimeContinuousDistribution_T::value_type(15,
585  0));
586  lTimeValueProbDist.insert(ValueOfTimeContinuousDistribution_T::value_type(60,
587  1));
588 
589  /*===================================================================================*/
590 
591  // Key of the demand stream
592  const stdair::AirportCode_T lSINOrigin ("SIN");
593  const stdair::AirportCode_T lBKKDestination ("BKK");
594  const stdair::Date_T lDepDate (2010, 2, 8);
595  const stdair::CabinCode_T lCabin ("Y");
596 
597  //
598  const DemandStreamKey lSINBKKDemandStreamKey (lSINOrigin, lBKKDestination, lDepDate,
599  lCabin);
600 
601  // DEBUG
602  // STDAIR_LOG_DEBUG ("Demand stream key: " << lDemandStreamKey.describe());
603 
604  // Distribution for the number of requests
605  const stdair::MeanValue_T lSINBKKDemandMean (60.0);
606  const stdair::StdDevValue_T lSINBKKDemandStdDev (4.0);
607  const DemandDistribution lSINBKKDemandDistribution (lSINBKKDemandMean, lSINBKKDemandStdDev);
608 
609  // Seed
610  const stdair::RandomSeed_T& lSINBKKRequestDateTimeSeed =
611  generateSeed (ioSharedGenerator);
612  const stdair::RandomSeed_T& lSINBKKDemandCharacteristicsSeed =
613  generateSeed (ioSharedGenerator);
614 
615 
616  //
617  POSProbabilityMassFunction_T lSINBKKPOSProbDist;
618  lSINBKKPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("SIN", 1.0));
619  lSINBKKPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("BKK", 0.0));
620 
621  //
622  PreferredDepartureTimeContinuousDistribution_T lSINPrefDepTimeProbDist;
623  lSINPrefDepTimeProbDist.
624  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (6, 0));
625  lSINPrefDepTimeProbDist.
626  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (8,
627  0.7));
628  lSINPrefDepTimeProbDist.
629  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (10,
630  0.8));
631  lSINPrefDepTimeProbDist.
632  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (12,
633  0.9));
634  lSINPrefDepTimeProbDist.
635  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (14,
636  1.0));
637 
638  //
639  const stdair::WTP_T lSINBKKWTP (400.0);
640 
641 
642  // Delegate the call to the dedicated command
643  DemandStream& lSINBKKDemandStream =
644  createDemandStream (ioEventQueue, lSINBKKDemandStreamKey, lDTDProbDist,
645  lSINBKKPOSProbDist, lChannelProbDist, lTripProbDist,
646  lStayProbDist, lFFProbDist, lSINPrefDepTimeProbDist,
647  lSINBKKWTP, lTimeValueProbDist, lSINBKKDemandDistribution,
648  ioSharedGenerator.getBaseGenerator(),
649  lSINBKKRequestDateTimeSeed,
650  lSINBKKDemandCharacteristicsSeed, iPOSProbMass);
651 
652  // Calculate the expected total number of events for the current
653  // demand stream
654  const stdair::NbOfRequests_T& lSINBKKExpectedNbOfEvents =
655  lSINBKKDemandStream.getMeanNumberOfRequests();
656 
657  /*===================================================================================*/
658 
659  // Key of the demand stream
660  const stdair::AirportCode_T lBKKOrigin ("BKK");
661  const stdair::AirportCode_T lHKGDestination ("HKG");
662 
663  //
664  const DemandStreamKey lBKKHKGDemandStreamKey (lBKKOrigin, lHKGDestination, lDepDate,
665  lCabin);
666 
667  // DEBUG
668  // STDAIR_LOG_DEBUG ("Demand stream key: " << lDemandStreamKey.describe());
669 
670  // Distribution for the number of requests
671  const stdair::MeanValue_T lBKKHKGDemandMean (60.0);
672  const stdair::StdDevValue_T lBKKHKGDemandStdDev (4.0);
673  const DemandDistribution lBKKHKGDemandDistribution (lBKKHKGDemandMean, lBKKHKGDemandStdDev);
674 
675  // Seed
676  const stdair::RandomSeed_T& lBKKHKGRequestDateTimeSeed =
677  generateSeed (ioSharedGenerator);
678  const stdair::RandomSeed_T& lBKKHKGDemandCharacteristicsSeed =
679  generateSeed (ioSharedGenerator);
680 
681 
682  //
683  POSProbabilityMassFunction_T lBKKHKGPOSProbDist;
684  lBKKHKGPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("BKK", 1.0));
685  lBKKHKGPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("HKG", 0.0));
686 
687  //
688  PreferredDepartureTimeContinuousDistribution_T lBKKPrefDepTimeProbDist;
689  lBKKPrefDepTimeProbDist.
690  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (8, 0));
691  lBKKPrefDepTimeProbDist.
692  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (10,
693  0.2));
694  lBKKPrefDepTimeProbDist.
695  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (1,
696  0.6));
697  lBKKPrefDepTimeProbDist.
698  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (14,
699  0.8));
700  lBKKPrefDepTimeProbDist.
701  insert (PreferredDepartureTimeContinuousDistribution_T::value_type (16,
702  1.0));
703 
704  //
705  const stdair::WTP_T lBKKHKGWTP (400.0);
706 
707 
708  // Delegate the call to the dedicated command
709  DemandStream& lBKKHKGDemandStream =
710  createDemandStream (ioEventQueue, lBKKHKGDemandStreamKey, lDTDProbDist,
711  lBKKHKGPOSProbDist, lChannelProbDist, lTripProbDist,
712  lStayProbDist, lFFProbDist, lBKKPrefDepTimeProbDist,
713  lBKKHKGWTP, lTimeValueProbDist, lBKKHKGDemandDistribution,
714  ioSharedGenerator.getBaseGenerator(),
715  lBKKHKGRequestDateTimeSeed,
716  lBKKHKGDemandCharacteristicsSeed, iPOSProbMass);
717 
718  // Calculate the expected total number of events for the current
719  // demand stream
720  const stdair::NbOfRequests_T& lBKKHKGExpectedNbOfEvents =
721  lBKKHKGDemandStream.getMeanNumberOfRequests();
722 
723  /*===================================================================================*/
724 
725  // Key of the demand stream
726 
727  //
728  const DemandStreamKey lSINHKGDemandStreamKey (lSINOrigin, lHKGDestination, lDepDate,
729  lCabin);
730 
731  // DEBUG
732  // STDAIR_LOG_DEBUG ("Demand stream key: " << lDemandStreamKey.describe());
733 
734  // Distribution for the number of requests
735  const stdair::MeanValue_T lSINHKGDemandMean (60.0);
736  const stdair::StdDevValue_T lSINHKGDemandStdDev (4.0);
737  const DemandDistribution lSINHKGDemandDistribution (lSINHKGDemandMean, lSINHKGDemandStdDev);
738 
739  // Seed
740  const stdair::RandomSeed_T& lSINHKGRequestDateTimeSeed =
741  generateSeed (ioSharedGenerator);
742  const stdair::RandomSeed_T& lSINHKGDemandCharacteristicsSeed =
743  generateSeed (ioSharedGenerator);
744 
745 
746  //
747  POSProbabilityMassFunction_T lSINHKGPOSProbDist;
748  lSINHKGPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("SIN", 1.0));
749  lSINHKGPOSProbDist.insert (POSProbabilityMassFunction_T::value_type ("HKG", 0.0));
750 
751  //
752  const stdair::WTP_T lSINHKGWTP (750.0);
753 
754 
755  // Delegate the call to the dedicated command
756  DemandStream& lSINHKGDemandStream =
757  createDemandStream (ioEventQueue, lSINHKGDemandStreamKey, lDTDProbDist,
758  lSINHKGPOSProbDist, lChannelProbDist, lTripProbDist,
759  lStayProbDist, lFFProbDist, lSINPrefDepTimeProbDist,
760  lSINHKGWTP, lTimeValueProbDist, lSINHKGDemandDistribution,
761  ioSharedGenerator.getBaseGenerator(),
762  lSINHKGRequestDateTimeSeed,
763  lSINHKGDemandCharacteristicsSeed, iPOSProbMass);
764 
765  // Calculate the expected total number of events for the current
766  // demand stream
767  const stdair::NbOfRequests_T& lSINHKGExpectedNbOfEvents =
768  lSINHKGDemandStream.getMeanNumberOfRequests();
769 
770  /*===================================================================================*/
771 
775  const stdair::NbOfRequests_T lExpectedTotalNbOfEvents =
776  lSINBKKExpectedNbOfEvents + lBKKHKGExpectedNbOfEvents + lSINHKGExpectedNbOfEvents;
777  ioEventQueue.addStatus (stdair::EventType::BKG_REQ,
778  lExpectedTotalNbOfEvents);
779  }
780 
781 }