StdAir Logo  0.43.0
C++ Standard Airline IT Library
BookingClass.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // StdAir
00008 #include <stdair/basic/BasConst_General.hpp>
00009 #include <stdair/basic/BasConst_Inventory.hpp>
00010 #include <stdair/basic/RandomGeneration.hpp>
00011 #include <stdair/bom/BookingClass.hpp>
00012 
00013 namespace stdair {
00014 
00015   // ////////////////////////////////////////////////////////////////////
00016   BookingClass::BookingClass() : _key (DEFAULT_CLASS_CODE), _parent (NULL) {
00017     assert (false);
00018   }
00019 
00020   // ////////////////////////////////////////////////////////////////////
00021   BookingClass::BookingClass (const BookingClass&)
00022     : _key (DEFAULT_CLASS_CODE), _parent (NULL) {
00023     assert (false);
00024   }
00025 
00026   // ////////////////////////////////////////////////////////////////////
00027   BookingClass::BookingClass (const Key_T& iKey)
00028     : _key (iKey), _parent (NULL), _cumulatedProtection (0.0),
00029       _protection (0.0), _cumulatedBookingLimit (0.0), _au (0.0), _nego (0.0),
00030       _noShowPercentage (0.0), _cancellationPercentage (0.0),
00031       _nbOfBookings (0.0), _groupNbOfBookings (0.0),
00032       _groupPendingNbOfBookings (0.0), _staffNbOfBookings (0.0),
00033       _wlNbOfBookings (0.0), _nbOfCancellations (0.), _etb (0.0),
00034       _netClassAvailability (0.0), _segmentAvailability (0.0),
00035       _netRevenueAvailability (0.0), _yield (0.0), _mean (0.0), _stdDev (0.0) {
00036   }
00037 
00038   // ////////////////////////////////////////////////////////////////////
00039   BookingClass::~BookingClass() {
00040   }
00041 
00042   // ////////////////////////////////////////////////////////////////////
00043   std::string BookingClass::toString() const {
00044     std::ostringstream oStr;
00045     oStr << describeKey();
00046     return oStr.str();
00047   }
00048 
00049   // ////////////////////////////////////////////////////////////////////
00050   void BookingClass::sell (const NbOfBookings_T& iNbOfBookings) {
00051     _nbOfBookings += iNbOfBookings;
00052   }
00053 
00054   // ////////////////////////////////////////////////////////////////////
00055   void BookingClass::cancel (const NbOfBookings_T& iNbOfCancellations) {
00056     _nbOfBookings -= iNbOfCancellations;
00057     _nbOfCancellations += iNbOfCancellations;
00058   }
00059 
00060   // ////////////////////////////////////////////////////////////////////
00061   void BookingClass::generateDemandSamples (const int& K) {
00062     _generatedDemandVector.clear();
00063     if (_stdDev > 0) {
00064       RandomGeneration lGenerator (DEFAULT_RANDOM_SEED);
00065       for (int i = 0; i < K; ++i) {
00066         RealNumber_T lDemandSample = lGenerator.generateNormal (_mean, _stdDev);
00067         _generatedDemandVector.push_back (lDemandSample);
00068       }
00069     }
00070   }
00071 
00072   // ////////////////////////////////////////////////////////////////////
00073   void BookingClass::generateDemandSamples (const int& K,
00074                                             const RandomSeed_T& iSeed) {
00075     _generatedDemandVector.clear();
00076     if (_stdDev > 0) {
00077       RandomGeneration lGenerator (iSeed);
00078       for (int i = 0; i < K; ++i) {
00079         RealNumber_T lDemandSample = lGenerator.generateNormal (_mean, _stdDev);
00080         _generatedDemandVector.push_back (lDemandSample);
00081       }
00082     }
00083   }
00084   
00085 }
00086