RMOL Logo  1.00.0
C++ library of Revenue Management and Optimisation classes and functions
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
DemandInputPreparation.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 #include <cmath>
8 // StdAir
9 #include <stdair/basic/BasConst_General.hpp>
10 #include <stdair/basic/BasConst_Inventory.hpp>
11 #include <stdair/bom/BomManager.hpp>
12 #include <stdair/bom/SegmentCabin.hpp>
13 #include <stdair/bom/BookingClass.hpp>
14 #include <stdair/service/Logger.hpp>
15 // RMOL
16 #include <rmol/bom/Utilities.hpp>
18 
19 namespace RMOL {
20 
21  // ////////////////////////////////////////////////////////////////////
23  prepareDemandInput (const stdair::SegmentCabin& iSegmentCabin) {
24  bool isSucceeded = true;
25 
26  // Browse the list of booking classes and sum the price-oriented
27  // demand foreast and the product-oriented demand forecast.
28  const stdair::BookingClassList_T& lBCList =
29  stdair::BomManager::getList<stdair::BookingClass> (iSegmentCabin);
30  for (stdair::BookingClassList_T::const_iterator itBC = lBCList.begin();
31  itBC != lBCList.end(); ++itBC) {
32  stdair::BookingClass* lBC_ptr = *itBC;
33  assert (lBC_ptr != NULL);
34 
35  const stdair::MeanValue_T& lPriceDemMean = lBC_ptr->getPriceDemMean();
36  const stdair::StdDevValue_T& lPriceStdDev = lBC_ptr->getPriceDemStdDev();
37  const stdair::MeanValue_T& lProductDemMean = lBC_ptr->getProductDemMean();
38  const stdair::StdDevValue_T& lProductStdDev =
39  lBC_ptr->getProductDemStdDev();
40 
41  const stdair::MeanValue_T lNewMeanValue = lPriceDemMean + lProductDemMean;
42  const stdair::StdDevValue_T lNewStdDev =
43  std::sqrt(lPriceStdDev*lPriceStdDev + lProductStdDev*lProductStdDev);
44 
45  lBC_ptr->setMean (lNewMeanValue);
46  lBC_ptr->setStdDev (lNewStdDev);
47  }
48 
49  return isSucceeded;
50  }
51 
52 }