StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
BookingClass.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
12 
13 namespace stdair {
14 
15  // ////////////////////////////////////////////////////////////////////
16  BookingClass::BookingClass() : _key (DEFAULT_CLASS_CODE), _parent (NULL) {
17  assert (false);
18  }
19 
20  // ////////////////////////////////////////////////////////////////////
21  BookingClass::BookingClass (const BookingClass& iBookingClass)
22  : _key (iBookingClass._key),
23  _parent (NULL),
24  _subclassCode (iBookingClass._subclassCode),
25  _cumulatedProtection (iBookingClass._cumulatedProtection),
26  _protection (iBookingClass._protection),
27  _cumulatedBookingLimit (iBookingClass._cumulatedBookingLimit),
28  _au (iBookingClass._au),
29  _nego (iBookingClass._nego),
30  _noShowPercentage (iBookingClass._noShowPercentage),
31  _cancellationPercentage (iBookingClass._cancellationPercentage),
32  _nbOfBookings (iBookingClass._nbOfBookings),
33  _groupNbOfBookings (iBookingClass._groupNbOfBookings),
34  _groupPendingNbOfBookings (iBookingClass._groupPendingNbOfBookings),
35  _staffNbOfBookings (iBookingClass._staffNbOfBookings),
36  _wlNbOfBookings (iBookingClass._wlNbOfBookings),
37  _nbOfCancellations (iBookingClass._nbOfCancellations),
38  _etb (iBookingClass._etb),
39  _netClassAvailability (iBookingClass._netClassAvailability),
40  _segmentAvailability (iBookingClass._segmentAvailability),
41  _netRevenueAvailability (iBookingClass._netRevenueAvailability),
42  _yield (iBookingClass._yield),
43  _adjustedYield (iBookingClass._adjustedYield),
44  _mean (iBookingClass._mean),
45  _stdDev (iBookingClass._stdDev) {
46  }
47 
48  // ////////////////////////////////////////////////////////////////////
49  BookingClass::BookingClass (const Key_T& iKey)
50  : _key (iKey), _parent (NULL), _subclassCode(0), _cumulatedProtection (0.0),
51  _protection (0.0), _cumulatedBookingLimit (0.0), _au (0.0), _nego (0.0),
52  _noShowPercentage (0.0), _cancellationPercentage (0.0),
53  _nbOfBookings (0.0), _groupNbOfBookings (0.0),
54  _groupPendingNbOfBookings (0.0), _staffNbOfBookings (0.0),
55  _wlNbOfBookings (0.0), _nbOfCancellations (0.), _etb (0.0),
56  _netClassAvailability (0.0), _segmentAvailability (0.0),
57  _netRevenueAvailability (0.0), _yield (0.0), _mean (0.0), _stdDev (0.0) {
58  }
59 
60  // ////////////////////////////////////////////////////////////////////
62  }
63 
64  // ////////////////////////////////////////////////////////////////////
65  std::string BookingClass::toString() const {
66  std::ostringstream oStr;
67  oStr << describeKey();
68  return oStr.str();
69  }
70 
71  // ////////////////////////////////////////////////////////////////////
72  void BookingClass::sell (const NbOfBookings_T& iNbOfBookings) {
73  _nbOfBookings += iNbOfBookings;
74  }
75 
76  // ////////////////////////////////////////////////////////////////////
77  void BookingClass::cancel (const NbOfBookings_T& iNbOfCancellations) {
78  _nbOfBookings -= iNbOfCancellations;
79  _nbOfCancellations += iNbOfCancellations;
80  }
81 
82  // ////////////////////////////////////////////////////////////////////
84  _generatedDemandVector.clear();
85  if (_stdDev > 0) {
87  for (unsigned int i = 0; i < K; ++i) {
88  RealNumber_T lDemandSample = lGenerator.generateNormal (_mean, _stdDev);
89  _generatedDemandVector.push_back (lDemandSample);
90  }
91  }
92  }
93 
94  // ////////////////////////////////////////////////////////////////////
96  const RandomSeed_T& iSeed) {
97  _generatedDemandVector.clear();
98  if (_stdDev > 0) {
99  RandomGeneration lGenerator (iSeed);
100  for (unsigned int i = 0; i < K; ++i) {
101  RealNumber_T lDemandSample = lGenerator.generateNormal (_mean, _stdDev);
102  _generatedDemandVector.push_back (lDemandSample);
103  }
104  }
105  }
106 
107 }
108 
void cancel(const NbOfBookings_T &)
std::string toString() const
Handle on the StdAir library context.
GeneratedDemandVector_T _generatedDemandVector
NbOfRequests_T NbOfBookings_T
RealNumber_T generateNormal(const RealNumber_T &, const RealNumber_T &)
const ClassCode_T DEFAULT_CLASS_CODE
double RealNumber_T
StdDevValue_T _stdDev
unsigned int NbOfSamples_T
const std::string describeKey() const
void generateDemandSamples(const NbOfSamples_T &)
unsigned long int RandomSeed_T
NbOfCancellations_T _nbOfCancellations
Class holding a random generator.
const RandomSeed_T DEFAULT_RANDOM_SEED
void sell(const NbOfBookings_T &)
NbOfBookings_T _nbOfBookings