RMOL Logo  1.00.0
C++ library of Revenue Management and Optimisation classes and functions
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
PreOptimiser.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/basic/RandomGeneration.hpp>
12 #include <stdair/bom/BomManager.hpp>
13 #include <stdair/bom/FlightDate.hpp>
14 #include <stdair/bom/SegmentDate.hpp>
15 #include <stdair/bom/SegmentCabin.hpp>
16 #include <stdair/bom/SegmentSnapshotTable.hpp>
17 #include <stdair/bom/BookingClass.hpp>
18 #include <stdair/service/Logger.hpp>
19 // RMOL
20 #include <rmol/bom/Utilities.hpp>
25 
26 namespace RMOL {
27 
28  // ////////////////////////////////////////////////////////////////////
29  bool PreOptimiser::
30  preOptimise (stdair::FlightDate& ioFlightDate,
31  const stdair::PreOptimisationMethod& iPreOptimisationMethod) {
32  bool isSucceeded = true;
33  const stdair::SegmentDateList_T& lSDList =
34  stdair::BomManager::getList<stdair::SegmentDate> (ioFlightDate);
35  for (stdair::SegmentDateList_T::const_iterator itSD = lSDList.begin();
36  itSD != lSDList.end(); ++itSD) {
37  stdair::SegmentDate* lSD_ptr = *itSD;
38  assert (lSD_ptr != NULL);
39 
40  //
41  const stdair::SegmentCabinList_T& lSCList =
42  stdair::BomManager::getList<stdair::SegmentCabin> (*lSD_ptr);
43  for (stdair::SegmentCabinList_T::const_iterator itSC = lSCList.begin();
44  itSC != lSCList.end(); ++itSC) {
45  stdair::SegmentCabin* lSC_ptr = *itSC;
46  assert (lSC_ptr != NULL);
47 
48  //
49  // STDAIR_LOG_NOTIFICATION (ioFlightDate.getDepartureDate()
50  // << ";" << lSegmentDTD);
51  bool isPreOptimised = preOptimise (*lSC_ptr, iPreOptimisationMethod);
52  if (isPreOptimised == false) {
53  isSucceeded = false;
54  }
55  }
56  }
57 
58  return isSucceeded;
59  }
60 
61  // ////////////////////////////////////////////////////////////////////
62  bool PreOptimiser::
63  preOptimise (stdair::SegmentCabin& ioSegmentCabin,
64  const stdair::PreOptimisationMethod& iPreOptimisationMethod) {
65  const stdair::PreOptimisationMethod::EN_PreOptimisationMethod& lPreOptimisationMethod =
66  iPreOptimisationMethod.getMethod();
67  switch (lPreOptimisationMethod) {
68  case stdair::PreOptimisationMethod::NONE: {
69  return DemandInputPreparation::prepareDemandInput (ioSegmentCabin);
70  }
71  case stdair::PreOptimisationMethod::FA: {
72  return FareAdjustment::adjustYield (ioSegmentCabin);
73  }
74  case stdair::PreOptimisationMethod::MRT: {
75  if (ioSegmentCabin.getFareFamilyStatus()==false) {
76  return FareAdjustment::adjustYield (ioSegmentCabin);
77  } else {
79  prepareDemandInput (ioSegmentCabin);
80  }
81  }
82  default:{
83  assert (false);
84  break;
85  }
86  }
87  return false;
88  }
89 
90  // ////////////////////////////////////////////////////////////////////
91  // void PreOptimiser::
92  // setDemandForecastsToZero(const stdair::SegmentCabin& iSegmentCabin) {
93  // }
94 }