RMOL Logo  1.00.0
C++ library of Revenue Management and Optimisation classes and functions
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
RMOL_Service.hpp
Go to the documentation of this file.
1 #ifndef __RMOL_SVC_RMOL_SERVICE_HPP
2 #define __RMOL_SVC_RMOL_SERVICE_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // STL
8 #include <string>
9 // StdAir
10 #include <stdair/stdair_basic_types.hpp>
11 #include <stdair/stdair_inventory_types.hpp>
12 #include <stdair/stdair_service_types.hpp>
13 #include <stdair/stdair_maths_types.hpp>
14 #include <stdair/basic/UnconstrainingMethod.hpp>
15 #include <stdair/basic/ForecastingMethod.hpp>
16 #include <stdair/basic/PreOptimisationMethod.hpp>
17 #include <stdair/basic/OptimisationMethod.hpp>
18 #include <stdair/basic/PartnershipTechnique.hpp>
19 // RMOL
20 #include <rmol/RMOL_Types.hpp>
21 
23 namespace stdair {
24  class FlightDate;
25  struct BasLogParams;
26  struct BasDBParams;
27  class BomRoot;
28  class AirlineClassList;
29  class YieldFeatures;
30  class Inventory;
31  class OnDDate;
32  class SegmentCabin;
33 }
34 
35 namespace RMOL {
36 
38  class RMOL_ServiceContext;
39 
43  class RMOL_Service {
44  public:
45  // ////////// Constructors and destructors //////////
61  RMOL_Service (const stdair::BasLogParams&, const stdair::BasDBParams&);
62 
74  RMOL_Service (const stdair::BasLogParams&);
75 
91  RMOL_Service (stdair::STDAIR_ServicePtr_T);
92 
116  void parseAndLoad (const stdair::CabinCapacity_T& iCabinCapacity,
117  const stdair::Filename_T& iDemandAndClassDataFile);
118 
122  void setUpStudyStatManager();
123 
127  ~RMOL_Service();
128 
129 
130  public:
131  // /////////////// Business Methods /////////////////
137  void buildSampleBom();
138 
142  void clonePersistentBom ();
143 
148  void buildComplementaryLinks (stdair::BomRoot&);
149 
153  void optimalOptimisationByMCIntegration (const int K);
154 
159 
164 
169 
174 
179 
184 
188  void MRTForNewQFF();
189 
197  const stdair::SegmentCabin&
198  retrieveDummySegmentCabin(const bool isForFareFamilies = false);
199 
203  bool optimise (stdair::FlightDate&, const stdair::DateTime_T&,
204  const stdair::UnconstrainingMethod&,
205  const stdair::ForecastingMethod&,
206  const stdair::PreOptimisationMethod&,
207  const stdair::OptimisationMethod&,
208  const stdair::PartnershipTechnique&);
209 
214  // O&D based forecast
215  void forecastOnD (const stdair::DateTime_T&);
216 
217  stdair::YieldFeatures* getYieldFeatures(const stdair::OnDDate&, const stdair::CabinCode_T&,
218  stdair::BomRoot&);
219 
220  void forecastOnD (const stdair::YieldFeatures&, stdair::OnDDate&,
221  const stdair::CabinCode_T&, const stdair::DTD_T&,
222  stdair::BomRoot&);
223 
224  void setOnDForecast (const stdair::AirlineClassList&, const stdair::MeanValue_T&,
225  const stdair::StdDevValue_T&, stdair::OnDDate&, const stdair::CabinCode_T&,
226  stdair::BomRoot&);
227 
228  // Single segment O&D
229  void setOnDForecast (const stdair::AirlineCode_T&, const stdair::Date_T&, const stdair::AirportCode_T&,
230  const stdair::AirportCode_T&, const stdair::CabinCode_T&, const stdair::ClassCode_T&,
231  const stdair::MeanValue_T&, const stdair::StdDevValue_T&, const stdair::Yield_T&, stdair::BomRoot&);
232 
233  // Multiple segment O&D
234  void setOnDForecast (const stdair::AirlineCodeList_T&, const stdair::AirlineCode_T&,const stdair::Date_T&,
235  const stdair::AirportCode_T&, const stdair::AirportCode_T&, const stdair::CabinCode_T&,
236  const stdair::ClassCodeList_T&, const stdair::MeanValue_T&, const stdair::StdDevValue_T&,
237  const stdair::Yield_T&, stdair::BomRoot&);
238 
239  // Initialise (or re-initialise) the demand projections in all leg cabins
240  void resetDemandInformation (const stdair::DateTime_T&);
241 
242  void resetDemandInformation (const stdair::DateTime_T&, const stdair::Inventory&);
243 
244  /* Projection of demand */
245 
246  // Aggregated demand at booking class level.
247  void projectAggregatedDemandOnLegCabins(const stdair::DateTime_T&);
248 
249  // Static rule prorated yield
250  void projectOnDDemandOnLegCabinsUsingYP(const stdair::DateTime_T&);
251 
252  // Displacement-adjusted yield
253  void projectOnDDemandOnLegCabinsUsingDA(const stdair::DateTime_T&);
254 
255  // Dynamic yield proration (PF = BP_i/BP_{total}, where BP_{total} = sum(BP_i))
256  void projectOnDDemandOnLegCabinsUsingDYP(const stdair::DateTime_T&);
257 
258  void projectOnDDemandOnLegCabinsUsingDYP(const stdair::DateTime_T&, const stdair::Inventory&);
259 
261  // O&D-based optimisation (using demand aggregation or demand aggregation).
262  void optimiseOnD (const stdair::DateTime_T&);
263 
264  // O&D-based optimisation using displacement-adjusted yield.
265  void optimiseOnDUsingRMCooperation (const stdair::DateTime_T&);
266 
267  // Advanced version of O&D-based optimisation using displacement-adjusted yield.
268  // Network optimisation instead of separate inventory optimisation.
269  void optimiseOnDUsingAdvancedRMCooperation (const stdair::DateTime_T&);
270 
271  // Update bid priceand send to partners
272  void updateBidPrice (const stdair::DateTime_T&);
273  void updateBidPrice (const stdair::FlightDate&, stdair::BomRoot&);
274 
275  public:
276  // //////////////// Export support methods /////////////////
287  std::string jsonExport (const stdair::AirlineCode_T&,
288  const stdair::FlightNumber_T&,
289  const stdair::Date_T& iDepartureDate) const;
290 
291 
292  public:
293  // //////////////// Display support methods /////////////////
301  std::string csvDisplay() const;
302 
303 
304  private:
305  // /////// Construction and Destruction helper methods ///////
309  RMOL_Service();
310 
314  RMOL_Service (const RMOL_Service&);
315 
325  stdair::STDAIR_ServicePtr_T initStdAirService (const stdair::BasLogParams&,
326  const stdair::BasDBParams&);
327 
336  stdair::STDAIR_ServicePtr_T initStdAirService (const stdair::BasLogParams&);
337 
346  void addStdAirService (stdair::STDAIR_ServicePtr_T,
347  const bool iOwnStdairService);
348 
353  void initServiceContext();
354 
361  void initRmolService();
362 
366  void finalise();
367 
368 
369  private:
370  // ////////// Service Context //////////
374  RMOL_ServiceContext* _rmolServiceContext;
375 
377  stdair::Date_T _previousForecastDate;
378  };
379 }
380 #endif // __RMOL_SVC_RMOL_SERVICE_HPP