You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(3) |
Feb
(2) |
Mar
(27) |
Apr
(8) |
May
(22) |
Jun
(10) |
Jul
(4) |
Aug
(3) |
Sep
(25) |
Oct
(12) |
Nov
|
Dec
(6) |
| 2010 |
Jan
(13) |
Feb
(3) |
Mar
(2) |
Apr
(1) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(14) |
Sep
(14) |
Oct
(4) |
Nov
(1) |
Dec
(2) |
|
From: <den...@us...> - 2009-10-09 09:27:21
|
Revision: 275
http://rmol.svn.sourceforge.net/rmol/?rev=275&view=rev
Author: denis_arnaud
Date: 2009-10-09 09:27:14 +0000 (Fri, 09 Oct 2009)
Log Message:
-----------
[Dev] Added BOM SegmentDate object. Note that it is not activated yet, as stdair needs first to be completed.
Modified Paths:
--------------
trunk/rmol/rmol/bom/SegmentDate.cpp
trunk/rmol/rmol/bom/SegmentDate.hpp
Modified: trunk/rmol/rmol/bom/SegmentDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.cpp 2009-10-09 09:22:48 UTC (rev 274)
+++ trunk/rmol/rmol/bom/SegmentDate.cpp 2009-10-09 09:27:14 UTC (rev 275)
@@ -10,10 +10,37 @@
// //////////////////////////////////////////////////////////////////////
void SegmentDate::updateCensorshipFlag () {
- updateCensorshipFlag (*self);
+
+ // //////////// BEGIN: TO BE COPIED AND REMOVED WHEN STDAIR IS READY ///////
+ bool censorshipFlag = false;
+
+ /*
+ const BookingClassDateList_T& lBookingClassDateList =
+ ioSegmentDate.getBookingClassList();
+ for (BookingClassDateList_T::const_iterator itBookingClassDateList =
+ lBookingClassDateList.begin();
+ itBookingClassDateList != lBookingClassDateList.end();
+ ++itBookingClassDateList) {
+ BookingClassDate* lBookingClassDate = *itBookingClassDateList;
+ assert (lBookingClassDate != NULL);
+
+ const bool lCensorshipFlagOfAClass= lBookingClassDate->getCensorshipFlag();
+ if (lCensorshipFlagOfAClass == true) {
+ censorshipFlag = true;
+ break;
+ }
+ }
+ */
+
+ // Store the result within the object
+ setCensorshipFlag (censorshipFlag);
+ // //////////// END: TO BE COPIED AND REMOVED WHEN STDAIR IS READY ///////
+
+ // updateCensorshipFlag (*self);
}
// //////////////////////////////////////////////////////////////////////
+ /*
void SegmentDate::updateCensorshipFlag (stdair::SegmentDate& ioSegmentDate) {
bool censorshipFlag = false;
@@ -35,5 +62,6 @@
// Store the result within the object
ioSegmentDate.setCensorshipFlag (censorshipFlag);
}
+ */
}
Modified: trunk/rmol/rmol/bom/SegmentDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.hpp 2009-10-09 09:22:48 UTC (rev 274)
+++ trunk/rmol/rmol/bom/SegmentDate.hpp 2009-10-09 09:27:14 UTC (rev 275)
@@ -10,7 +10,8 @@
namespace RMOL {
/** Class modelling an airline-related SegmentDate. */
- class SegmentDate : public stdair::SegmentDate {
+ class SegmentDate
+ //: public stdair::SegmentDate {
public:
/** Compute and update the censorship flag for all the booking classes
@@ -19,7 +20,7 @@
/** Same method, but on an object provided by a third party (e.g.,
an external library). */
- static void updateCensorshipFlag (std::SegmentDate& ioSegmentDate);
+ // static void updateCensorshipFlag (stdair::SegmentDate& ioSegmentDate);
private:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-10-09 09:22:56
|
Revision: 274
http://rmol.svn.sourceforge.net/rmol/?rev=274&view=rev
Author: denis_arnaud
Date: 2009-10-09 09:22:48 +0000 (Fri, 09 Oct 2009)
Log Message:
-----------
[Dev] Added BOM SegmentDate object. Note that it is not activated yet, as stdair needs first to be completed.
Modified Paths:
--------------
trunk/rmol/rmol/bom/MCOptimiser.cpp
Added Paths:
-----------
trunk/rmol/rmol/bom/SegmentDate.cpp
trunk/rmol/rmol/bom/SegmentDate.hpp
Modified: trunk/rmol/rmol/bom/MCOptimiser.cpp
===================================================================
--- trunk/rmol/rmol/bom/MCOptimiser.cpp 2009-10-09 09:07:59 UTC (rev 273)
+++ trunk/rmol/rmol/bom/MCOptimiser.cpp 2009-10-09 09:22:48 UTC (rev 274)
@@ -535,7 +535,7 @@
i.e., n corresponds to the number of classes/buckets.
*/
unsigned int Kj = K;
- const int cabinCapacityInt = static_cast<int> (iCabinCapacity);
+ //const int cabinCapacityInt = static_cast<int> (iCabinCapacity);
for (short j = 1 ; j <= nbOfClasses - 1; ++j, ioBucketHolder.iterate()) {
// DEBUG
std::cout << "K" << j << " = " << Kj << std::endl;
Added: trunk/rmol/rmol/bom/SegmentDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.cpp (rev 0)
+++ trunk/rmol/rmol/bom/SegmentDate.cpp 2009-10-09 09:22:48 UTC (rev 274)
@@ -0,0 +1,39 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STL
+#include <cassert>
+// RMOL
+#include <rmol/bom/SegmentDate.hpp>
+
+namespace RMOL {
+
+ // //////////////////////////////////////////////////////////////////////
+ void SegmentDate::updateCensorshipFlag () {
+ updateCensorshipFlag (*self);
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void SegmentDate::updateCensorshipFlag (stdair::SegmentDate& ioSegmentDate) {
+ bool censorshipFlag = false;
+
+ const BookingClassDateList_T& lBookingClassDateList =
+ ioSegmentDate.getBookingClassList();
+ for (BookingClassDateList_T::const_iterator itBookingClassDateList =
+ lBookingClassDateList.begin();
+ itBookingClassDateList != lBookingClassDateList.end();
+ ++itBookingClassDateList) {
+ stdair::BookingClassDate& lBookingClassDate = *itBookingClassDateList;
+
+ const bool lCensorshipFlagOfAClass= lBookingClassDate.getCensorshipFlag();
+ if (lCensorshipFlagOfAClass == true) {
+ censorshipFlag = true;
+ break;
+ }
+ }
+
+ // Store the result within the object
+ ioSegmentDate.setCensorshipFlag (censorshipFlag);
+ }
+
+}
Added: trunk/rmol/rmol/bom/SegmentDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.hpp (rev 0)
+++ trunk/rmol/rmol/bom/SegmentDate.hpp 2009-10-09 09:22:48 UTC (rev 274)
@@ -0,0 +1,29 @@
+#ifndef __RMOL_BOM_SEGMENTDATE_HPP
+#define __RMOL_BOM_SEGMENTDATE_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// StdAir
+#include <bom/SegmentDate.hpp>
+
+namespace RMOL {
+
+ /** Class modelling an airline-related SegmentDate. */
+ class SegmentDate : public stdair::SegmentDate {
+ public:
+
+ /** Compute and update the censorship flag for all the booking classes
+ of the given segment-date. */
+ void updateCensorshipFlag ();
+
+ /** Same method, but on an object provided by a third party (e.g.,
+ an external library). */
+ static void updateCensorshipFlag (std::SegmentDate& ioSegmentDate);
+
+ private:
+
+ };
+
+}
+#endif // __RMOL_BOM_SEGMENTDATE_HPP
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-10-09 09:08:10
|
Revision: 273
http://rmol.svn.sourceforge.net/rmol/?rev=273&view=rev
Author: denis_arnaud
Date: 2009-10-09 09:07:59 +0000 (Fri, 09 Oct 2009)
Log Message:
-----------
Cleaned a little bit the code.
Modified Paths:
--------------
trunk/rmol/test/bomsforforecaster.cpp
Modified: trunk/rmol/test/bomsforforecaster.cpp
===================================================================
--- trunk/rmol/test/bomsforforecaster.cpp 2009-10-09 08:08:24 UTC (rev 272)
+++ trunk/rmol/test/bomsforforecaster.cpp 2009-10-09 09:07:59 UTC (rev 273)
@@ -1,12 +1,12 @@
// //////////////////////////////////////////////////////////////////////
// Import section
// //////////////////////////////////////////////////////////////////////
-// C
-// #include <cassert>
// STL
+#include <cassert>
#include <sstream>
#include <fstream>
#include <string>
+#include <limits>
// #include <iostream>
// RMOL
#include <RMOL_Service.hpp>
@@ -24,18 +24,18 @@
bool _censorshipFlag;
// Constructer
- BookingClassData (double iBookingCount, double iFare,
- double iSellupFactor, bool iCensorshipFlag) :
- _bookingCount(iBookingCount), _fare(iFare),
+ BookingClassData (const double iBookingCount, const double iFare,
+ const double iSellupFactor, const bool iCensorshipFlag)
+ : _bookingCount(iBookingCount), _fare(iFare),
_sellupFactor(iSellupFactor), _censorshipFlag(iCensorshipFlag) {
}
// Getters
- double getFare () {
+ double getFare () const {
return _fare;
}
- bool getCensorshipFlag () {
+ bool getCensorshipFlag () const {
return _censorshipFlag;
}
@@ -71,62 +71,69 @@
}
// Add BookingClassData
- void addBookingClassData (BookingClassData* iBookingClassData) {
- _bookingClassDataList.push_back(iBookingClassData);
+ void addBookingClassData (BookingClassData& ioBookingClassData) {
+ _bookingClassDataList.push_back (&ioBookingClassData);
}
// Getters
- int getNumberOfClass () {
+ unsigned int getNumberOfClass () const {
return _bookingClassDataList.size();
}
- double getMinimumFare () {
+ double getMinimumFare () const {
return _minimumFare;
}
- bool getCensorshipFlag () {
+ bool getCensorshipFlag () const {
return _censorshipFlag;
}
// Setters
- void setMinimumFare (double iMinFare) {
+ void setMinimumFare (const double iMinFare) {
_minimumFare = iMinFare;
}
- void setCensorshipFlag (bool iCensorshipFlag) {
+ void setCensorshipFlag (const bool iCensorshipFlag) {
_censorshipFlag = iCensorshipFlag;
}
// compute minimum fare
- void calculateMinimumFare() {
- double minFare = 1000000;
+ void updateMinimumFare() {
+ double minFare = std::numeric_limits<double>::max();
BookingClassDataList_T::iterator itBookingClassDataList;
for (itBookingClassDataList = _bookingClassDataList.begin();
itBookingClassDataList != _bookingClassDataList.end();
++itBookingClassDataList) {
BookingClassData* lBookingClassData = *itBookingClassDataList;
- double lFare = lBookingClassData->getFare();
+ assert (lBookingClassData != NULL);
+
+ const double lFare = lBookingClassData->getFare();
if (lFare < minFare) {
minFare = lFare;
}
}
+ //
setMinimumFare(minFare);
}
// compute censorship flag for the data set
- void calculateCensorshipFlag () {
+ void updateCensorshipFlag () {
bool censorshipFlag = false;
BookingClassDataList_T::iterator itBookingClassDataList;
for (itBookingClassDataList = _bookingClassDataList.begin();
itBookingClassDataList != _bookingClassDataList.end();
++itBookingClassDataList) {
BookingClassData* lBookingClassData = *itBookingClassDataList;
- bool lCensorshipFlagOfAClass = lBookingClassData -> getCensorshipFlag();
+ assert (lBookingClassData != NULL);
+
+ const bool lCensorshipFlagOfAClass =
+ lBookingClassData->getCensorshipFlag();
if (lCensorshipFlagOfAClass) {
censorshipFlag = true;
break;
}
}
+ //
setCensorshipFlag(censorshipFlag);
}
@@ -201,26 +208,26 @@
RMOL_LOG_DEBUG(YClassData.toString());
// Add BookingClassData into the BCDataSet
- lBookingClassDataSet.addBookingClassData( &QClassData );
- lBookingClassDataSet.addBookingClassData( &MClassData );
- lBookingClassDataSet.addBookingClassData( &BClassData );
- lBookingClassDataSet.addBookingClassData( &YClassData );
+ lBookingClassDataSet.addBookingClassData (QClassData );
+ lBookingClassDataSet.addBookingClassData( MClassData );
+ lBookingClassDataSet.addBookingClassData( BClassData );
+ lBookingClassDataSet.addBookingClassData( YClassData );
//Display
RMOL_LOG_DEBUG( lBookingClassDataSet.toString() );
// Number of classes
- int lNoOfClass = lBookingClassDataSet.getNumberOfClass();
+ const unsigned int lNoOfClass = lBookingClassDataSet.getNumberOfClass();
RMOL_LOG_DEBUG( "Number of Classes: " << lNoOfClass );
// Minimum fare
- lBookingClassDataSet.calculateMinimumFare();
- double lMinFare = lBookingClassDataSet.getMinimumFare();
+ lBookingClassDataSet.updateMinimumFare();
+ const double lMinFare = lBookingClassDataSet.getMinimumFare();
RMOL_LOG_DEBUG( "Minimum fare: " << lMinFare );
// Censorship flag
- lBookingClassDataSet.calculateCensorshipFlag();
- double lCensorshipFlag = lBookingClassDataSet.getCensorshipFlag();
+ lBookingClassDataSet.updateCensorshipFlag();
+ const bool lCensorshipFlag = lBookingClassDataSet.getCensorshipFlag();
RMOL_LOG_DEBUG( "Censorship Flag: " << lCensorshipFlag );
// Close the log output file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-10-09 08:08:37
|
Revision: 272
http://rmol.svn.sourceforge.net/rmol/?rev=272&view=rev
Author: dkchoe
Date: 2009-10-09 08:08:24 +0000 (Fri, 09 Oct 2009)
Log Message:
-----------
Added a test for object-oriented forecaster
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_Types.hpp
trunk/rmol/test/Makefile.am
Added Paths:
-----------
trunk/rmol/test/bomsforforecaster.cpp
Property Changed:
----------------
trunk/rmol/test/
Modified: trunk/rmol/rmol/RMOL_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Types.hpp 2009-10-08 15:10:53 UTC (rev 271)
+++ trunk/rmol/rmol/RMOL_Types.hpp 2009-10-09 08:08:24 UTC (rev 272)
@@ -94,6 +94,9 @@
/** Define the holder of sellup factors (used for computing Q-eq bookings)*/
typedef std::vector<double> SellupFactorHolder_T;
+ /** Define the holder of censorship flags. */
+ typedef std::vector<double> CensorshipFlagHolder_T;
+
}
#endif // __RMOL_RMOL_TYPES_HPP
Property changes on: trunk/rmol/test
___________________________________________________________________
Modified: svn:ignore
- .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
ForecasterTestSuite
ForecasterTestSuite.log
ForecasterTestSuite_results.xml
UnconstrainerTestSuite
UnconstrainerTestSuite.log
UnconstrainerTestSuite_results.xml
valarrays
+ .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
ForecasterTestSuite
ForecasterTestSuite.log
ForecasterTestSuite_results.xml
UnconstrainerTestSuite
UnconstrainerTestSuite.log
UnconstrainerTestSuite_results.xml
valarrays
bomsforforecaster
bomsforforecaster.log
Modified: trunk/rmol/test/Makefile.am
===================================================================
--- trunk/rmol/test/Makefile.am 2009-10-08 15:10:53 UTC (rev 271)
+++ trunk/rmol/test/Makefile.am 2009-10-09 08:08:24 UTC (rev 272)
@@ -4,12 +4,12 @@
MAINTAINERCLEANFILES = Makefile.in
##
-SUBDIRS = com stdair
+SUBDIRS = com
EXTRA_DIST = testLib.sh
##
-EXTRA_TESTS = valarrays
+EXTRA_TESTS = valarrays bomsforforecaster
STD_CHECKS = OptimiseTestSuite SimulateTestSuite ForecasterTestSuite UnconstrainerTestSuite
check_PROGRAMS = $(STD_CHECKS) $(EXTRA_TESTS)
TESTS = $(STD_CHECKS)
@@ -47,3 +47,10 @@
valarrays_LDADD =
valarrays_LDFLAGS = $(BOOST_LIBS)
+bomsforforecaster_SOURCES = bomsforforecaster.cpp
+bomsforforecaster_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS)
+bomsforforecaster_LDADD =
+bomsforforecaster_LDFLAGS = $(BOOST_LIBS) \
+ $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la \
+ $(top_builddir)/@PACKAGE@/service/libsvc.la
+
Added: trunk/rmol/test/bomsforforecaster.cpp
===================================================================
--- trunk/rmol/test/bomsforforecaster.cpp (rev 0)
+++ trunk/rmol/test/bomsforforecaster.cpp 2009-10-09 08:08:24 UTC (rev 272)
@@ -0,0 +1,230 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// C
+// #include <cassert>
+// STL
+#include <sstream>
+#include <fstream>
+#include <string>
+// #include <iostream>
+// RMOL
+#include <RMOL_Service.hpp>
+#include <rmol/service/Logger.hpp>
+
+namespace RMOL {
+
+ /**-------------- BOM: Booking class/bucket data ----------------------- */
+ struct BookingClassData {
+
+ // Attributes
+ double _bookingCount;
+ double _fare;
+ double _sellupFactor;
+ bool _censorshipFlag;
+
+ // Constructer
+ BookingClassData (double iBookingCount, double iFare,
+ double iSellupFactor, bool iCensorshipFlag) :
+ _bookingCount(iBookingCount), _fare(iFare),
+ _sellupFactor(iSellupFactor), _censorshipFlag(iCensorshipFlag) {
+ }
+
+ // Getters
+ double getFare () {
+ return _fare;
+ }
+
+ bool getCensorshipFlag () {
+ return _censorshipFlag;
+ }
+
+ // Display
+ std::string toString() const {
+ std::ostringstream oStr;
+ oStr << std::endl
+ << "[Booking class data information]" << std::endl
+ << "Booking counter: " << _bookingCount << std::endl
+ << "Fare: " << _fare << std::endl
+ << "Sell-up Factor: " << _sellupFactor << std::endl
+ << "censorshipFlag: " << _censorshipFlag << std::endl;
+ return oStr.str();
+ }
+
+ };
+
+ /**-------------- BOM: Set of BookingClassData ----------------------- */
+ struct BookingClassDataSet {
+
+ typedef std::vector<BookingClassData*> BookingClassDataList_T;
+
+ // Attributes
+ int _numberOfClass;
+ double _minimumFare;
+ bool _censorshipFlag; // true if any of the classes is censored
+ BookingClassDataList_T _bookingClassDataList;
+
+ // Constructor
+ BookingClassDataSet ()
+ : _numberOfClass(0), _minimumFare(0),
+ _censorshipFlag(false), _bookingClassDataList(NULL) {
+ }
+
+ // Add BookingClassData
+ void addBookingClassData (BookingClassData* iBookingClassData) {
+ _bookingClassDataList.push_back(iBookingClassData);
+ }
+
+ // Getters
+ int getNumberOfClass () {
+ return _bookingClassDataList.size();
+ }
+
+ double getMinimumFare () {
+ return _minimumFare;
+ }
+
+ bool getCensorshipFlag () {
+ return _censorshipFlag;
+ }
+
+ // Setters
+ void setMinimumFare (double iMinFare) {
+ _minimumFare = iMinFare;
+ }
+
+ void setCensorshipFlag (bool iCensorshipFlag) {
+ _censorshipFlag = iCensorshipFlag;
+ }
+
+ // compute minimum fare
+ void calculateMinimumFare() {
+ double minFare = 1000000;
+ BookingClassDataList_T::iterator itBookingClassDataList;
+ for (itBookingClassDataList = _bookingClassDataList.begin();
+ itBookingClassDataList != _bookingClassDataList.end();
+ ++itBookingClassDataList) {
+ BookingClassData* lBookingClassData = *itBookingClassDataList;
+ double lFare = lBookingClassData->getFare();
+ if (lFare < minFare) {
+ minFare = lFare;
+ }
+ }
+ setMinimumFare(minFare);
+ }
+
+ // compute censorship flag for the data set
+ void calculateCensorshipFlag () {
+ bool censorshipFlag = false;
+ BookingClassDataList_T::iterator itBookingClassDataList;
+ for (itBookingClassDataList = _bookingClassDataList.begin();
+ itBookingClassDataList != _bookingClassDataList.end();
+ ++itBookingClassDataList) {
+ BookingClassData* lBookingClassData = *itBookingClassDataList;
+ bool lCensorshipFlagOfAClass = lBookingClassData -> getCensorshipFlag();
+ if (lCensorshipFlagOfAClass) {
+ censorshipFlag = true;
+ break;
+ }
+ }
+ setCensorshipFlag(censorshipFlag);
+ }
+
+ // Display
+ std::string toString() const {
+ std::ostringstream oStr;
+ oStr << std::endl
+ << "[Booking class data set information]" << std::endl
+ << "Number of classes: " << _numberOfClass << std::endl
+ << "Minimum fare: " << _minimumFare << std::endl
+ << "The data of the class set are sensored: " << _censorshipFlag
+ << std::endl;
+ return oStr.str();
+ }
+
+ };
+
+ // /**-------------- BOM : Q-Forecaster ----------------------- */
+ // struct QForecaster {
+
+ // // Function focused BOM
+
+ // // 1. calculate sell up probability for Q-eq
+
+ // // 2. calculate Q-Equivalent Booking
+ // double calculateQEqBooking (BookingClassDataSet& iBookingClassDataSet) {
+ // double lQEqBooking = 0.0;
+ // double lMinFare = iBookingClassDataSet.getMinimumFare();
+
+
+ // return lQEqBooking;
+ // }
+
+ // /* Calculate Q-equivalent demand
+ // [<- performed by unconstrainer if necessary (Using ExpMax BOM)]
+ // */
+
+
+ // // 3. Partition to each class
+
+ // //
+
+ // };
+
+}
+
+// ////////////// M A I N ///////////////
+int main (int argc, char* argv[]) {
+
+ // Output log File
+ std::string lLogFilename ("./bomsforforecaster.log");
+ std::ofstream logOutputFile;
+
+ // Open and clean the log outputfile
+ logOutputFile.open (lLogFilename.c_str());
+ logOutputFile.clear();
+ RMOL::RMOL_Service lRmolService(logOutputFile);
+
+ // Register BCDataSet
+ RMOL::BookingClassDataSet lBookingClassDataSet;
+
+ // Register BookingClassData
+ RMOL::BookingClassData QClassData (10, 100, 1, false );
+ RMOL::BookingClassData MClassData (5, 150, 0.8, true);
+ RMOL::BookingClassData BClassData (0, 200, 0.6, false);
+ RMOL::BookingClassData YClassData (0, 300, 0.3, false);
+
+ // Display
+ RMOL_LOG_DEBUG(QClassData.toString());
+ RMOL_LOG_DEBUG(MClassData.toString());
+ RMOL_LOG_DEBUG(BClassData.toString());
+ RMOL_LOG_DEBUG(YClassData.toString());
+
+ // Add BookingClassData into the BCDataSet
+ lBookingClassDataSet.addBookingClassData( &QClassData );
+ lBookingClassDataSet.addBookingClassData( &MClassData );
+ lBookingClassDataSet.addBookingClassData( &BClassData );
+ lBookingClassDataSet.addBookingClassData( &YClassData );
+
+ //Display
+ RMOL_LOG_DEBUG( lBookingClassDataSet.toString() );
+
+ // Number of classes
+ int lNoOfClass = lBookingClassDataSet.getNumberOfClass();
+ RMOL_LOG_DEBUG( "Number of Classes: " << lNoOfClass );
+
+ // Minimum fare
+ lBookingClassDataSet.calculateMinimumFare();
+ double lMinFare = lBookingClassDataSet.getMinimumFare();
+ RMOL_LOG_DEBUG( "Minimum fare: " << lMinFare );
+
+ // Censorship flag
+ lBookingClassDataSet.calculateCensorshipFlag();
+ double lCensorshipFlag = lBookingClassDataSet.getCensorshipFlag();
+ RMOL_LOG_DEBUG( "Censorship Flag: " << lCensorshipFlag );
+
+ // Close the log output file
+ logOutputFile.close();
+ return 0;
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-10-08 15:11:01
|
Revision: 271
http://rmol.svn.sourceforge.net/rmol/?rev=271&view=rev
Author: dkchoe
Date: 2009-10-08 15:10:53 +0000 (Thu, 08 Oct 2009)
Log Message:
-----------
[Dev] Removed objects imported from airsched (Quan).
Modified Paths:
--------------
trunk/rmol/rmol/bom/sources.mk
Removed Paths:
-------------
trunk/rmol/rmol/bom/BomRootTypes.hpp
trunk/rmol/rmol/bom/FlightDate.cpp
trunk/rmol/rmol/bom/FlightDate.hpp
trunk/rmol/rmol/bom/FlightDateTypes.hpp
trunk/rmol/rmol/bom/Inventory.cpp
trunk/rmol/rmol/bom/Inventory.hpp
trunk/rmol/rmol/bom/InventoryTypes.hpp
trunk/rmol/rmol/bom/LegDate.cpp
trunk/rmol/rmol/bom/LegDate.hpp
trunk/rmol/rmol/bom/LegDateTypes.hpp
trunk/rmol/rmol/bom/SegmentDate.cpp
trunk/rmol/rmol/bom/SegmentDate.hpp
trunk/rmol/rmol/bom/SegmentDateTypes.hpp
Deleted: trunk/rmol/rmol/bom/BomRootTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/BomRootTypes.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/BomRootTypes.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,32 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-#ifndef __RMOL_BOM_BOMROOTTYPES_HPP
-#define __RMOL_BOM_BOMROOTTYPES_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-
-// Forward declarations.
-namespace stdair {
- template <typename BOM_CONTENT> class BomStructureRoot;
- template <typename BOM_CONTENT> class BomStructureRootKey;
- template <typename BOM_CHILD> class BomContentRoot;
-}
-
-namespace RMOL {
-
- // Forward declarations.
- class Inventory;
-
- /** Define the BomContentRoot. */
- typedef stdair::BomContentRoot<Inventory> BomContentRoot_T;
-
- /** Define the BomStructureRoot. */
- typedef stdair::BomStructureRoot<BomContentRoot_T> BomStructureRoot_T;
-
- /** Define the BomStructureRootKey. */
- typedef stdair::BomStructureRootKey<BomContentRoot_T> BomStructureRootKey_T;
-
-}
-#endif // __RMOL_BOM_BOMROOTTYPES_HPP
-
Deleted: trunk/rmol/rmol/bom/FlightDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/FlightDate.cpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/FlightDate.cpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,243 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// C
-#include <cassert>
-// STL
-#include <sstream>
-#include <algorithm>
-// STDAIR
-#include <stdair/bom/FlightDate.hpp>
-// RMOL
-#include <rmol/bom/Inventory.hpp>
-#include <rmol/bom/FlightDate.hpp>
-#include <rmol/bom/SegmentDate.hpp>
-#include <rmol/bom/LegDate.hpp>
-#include <rmol/service/Logger.hpp>
-
-namespace RMOL {
-
- // ////////////////////////////////////////////////////////////////////
- FlightDate::FlightDate (BomStructure_T& ioFlightStructure)
- : _flightDateStructure (ioFlightStructure) {
- }
-
- // ////////////////////////////////////////////////////////////////////
- FlightDate::~FlightDate () {
- }
-
- // //////////////////////////////////////////////////////////////////////
- void FlightDate::toStream (std::ostream& ioOut) const {
- ioOut << toString() << std::endl;
- }
-
- // //////////////////////////////////////////////////////////////////////
- void FlightDate::fromStream (std::istream& ioIn) {
- }
-
- // //////////////////////////////////////////////////////////////////////
- std::string FlightDate::toString() const {
- std::ostringstream oStr;
-
- // First, put the key of that level
- oStr << describeShortKey() << std::endl;
-
- return oStr.str();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string FlightDate::describeKey() const {
- return _flightDateStructure.describeKey();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string FlightDate::describeShortKey() const {
- return _flightDateStructure.describeShortKey();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_list_const_iterator FlightDate::segmentDateListConstIteratorBegin () const {
- return _flightDateStructure.segmentDateListConstIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_list_const_iterator FlightDate::segmentDateListConstIteratorEnd () const {
- return _flightDateStructure.segmentDateListConstIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::segment_date_list_const_reverse_iterator FlightDate::segmentDateListConstIteratorRBegin () const {
- return _flightDateStructure.segmentDateListConstIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::segment_date_list_const_reverse_iterator FlightDate::segmentDateListConstIteratorREnd () const {
- return _flightDateStructure.segmentDateListConstIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_list_iterator FlightDate::segmentDateListIteratorBegin () const {
- return _flightDateStructure.segmentDateListIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_list_iterator FlightDate::segmentDateListIteratorEnd () const {
- return _flightDateStructure.segmentDateListIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_list_reverse_iterator FlightDate::segmentDateListIteratorRBegin () const {
- return _flightDateStructure.segmentDateListIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_list_reverse_iterator FlightDate::segmentDateListIteratorREnd () const {
- return _flightDateStructure.segmentDateListIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_map_const_iterator FlightDate::segmentDateMapConstIteratorBegin () const {
- return _flightDateStructure.segmentDateMapConstIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_map_const_iterator FlightDate::segmentDateMapConstIteratorEnd () const {
- return _flightDateStructure.segmentDateMapConstIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::segment_date_map_const_reverse_iterator FlightDate::segmentDateMapConstIteratorRBegin () const {
- return _flightDateStructure.segmentDateMapConstIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::segment_date_map_const_reverse_iterator FlightDate::segmentDateMapConstIteratorREnd () const {
- return _flightDateStructure.segmentDateMapConstIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_map_iterator FlightDate::segmentDateMapIteratorBegin () const {
- return _flightDateStructure.segmentDateMapIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_map_iterator FlightDate::segmentDateMapIteratorEnd () const {
- return _flightDateStructure.segmentDateMapIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_map_reverse_iterator FlightDate::segmentDateMapIteratorRBegin () const {
- return _flightDateStructure.segmentDateMapIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- segment_date_map_reverse_iterator FlightDate::segmentDateMapIteratorREnd () const {
- return _flightDateStructure.segmentDateMapIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_list_const_iterator FlightDate::legDateListConstIteratorBegin () const {
- return _flightDateStructure.legDateListConstIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_list_const_iterator FlightDate::legDateListConstIteratorEnd () const {
- return _flightDateStructure.legDateListConstIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::leg_date_list_const_reverse_iterator FlightDate::legDateListConstIteratorRBegin () const {
- return _flightDateStructure.legDateListConstIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::leg_date_list_const_reverse_iterator FlightDate::legDateListConstIteratorREnd () const {
- return _flightDateStructure.legDateListConstIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_list_iterator FlightDate::legDateListIteratorBegin () const {
- return _flightDateStructure.legDateListIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_list_iterator FlightDate::legDateListIteratorEnd () const {
- return _flightDateStructure.legDateListIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_list_reverse_iterator FlightDate::legDateListIteratorRBegin () const {
- return _flightDateStructure.legDateListIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_list_reverse_iterator FlightDate::legDateListIteratorREnd () const {
- return _flightDateStructure.legDateListIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_map_const_iterator FlightDate::legDateMapConstIteratorBegin () const {
- return _flightDateStructure.legDateMapConstIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_map_const_iterator FlightDate::legDateMapConstIteratorEnd () const {
- return _flightDateStructure.legDateMapConstIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::leg_date_map_const_reverse_iterator FlightDate::legDateMapConstIteratorRBegin () const {
- return _flightDateStructure.legDateMapConstIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::leg_date_map_const_reverse_iterator FlightDate::legDateMapConstIteratorREnd () const {
- return _flightDateStructure.legDateMapConstIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_map_iterator FlightDate::legDateMapIteratorBegin () const {
- return _flightDateStructure.legDateMapIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_map_iterator FlightDate::legDateMapIteratorEnd () const {
- return _flightDateStructure.legDateMapIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_map_reverse_iterator FlightDate::legDateMapIteratorRBegin () const {
- return _flightDateStructure.legDateMapIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- FlightDate::
- leg_date_map_reverse_iterator FlightDate::legDateMapIteratorREnd () const {
- return _flightDateStructure.legDateMapIteratorREnd ();
- }
-
-}
-
Deleted: trunk/rmol/rmol/bom/FlightDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/FlightDate.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/FlightDate.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,278 +0,0 @@
-#ifndef __RMOL_BOM_FLIGHTDATE_HPP
-#define __RMOL_BOM_FLIGHTDATE_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// STDAIR
-#include <stdair/bom/BomStructureList.hpp>
-#include <stdair/bom/BomContent.hpp>
-#include <stdair/bom/BomIterator.hpp>
-// RMOL
-#include <rmol/bom/FlightDateTypes.hpp>
-#include <rmol/bom/SegmentDateTypes.hpp>
-#include <rmol/bom/LegDateTypes.hpp>
-
-// Forward declarations
-namespace stdair {
- class FacBomContent;
- class BomStructure;
-}
-
-namespace RMOL {
-
- // Forward declarations
- class Inventory;
-
- /** Class representing the actual functional/business content for a
- flight-date. */
- class FlightDate : public stdair::BomContent {
- friend class stdair::FacBomContent;
-
- public:
- // Type definitions
- // /////////////////////////////////////////////////////////////////////////
- // See the explanations, within the stdair::BomContentRoot class, for all
- // the types which require to be specified below
- // /////////////////////////////////////////////////////////////////////////
- /** Definition allowing to retrieve the associated parent
- BOM content type. */
- typedef Inventory ParentBomContent_T;
-
- /** Definition allowing to retrieve the associated BOM structure type. */
- typedef FlightDateStructure_T BomStructure_T;
-
- /** Definition allowing to retrieve the associated BOM key type. */
- typedef FlightDateKey_T BomKey_T;
-
- /** Definition allowing to retrieve the associated
- BOM content child type. */
- typedef SegmentDate ContentChild_T;
-
- /** Definition allowing to retrieve the associated second
- BOM content child type. */
- typedef LegDate SecondContentChild_T;
-
- public:
- // /////////////////////////////////////////////////////////////////////////
- // See the explanations, within the stdair::BomContentRoot class, for all
- // the iterator types specified below
- // /////////////////////////////////////////////////////////////////////////
- /** Define the segment-date list iterators. */
- typedef stdair::BomConstIterator_T<SegmentDate,
- SegmentDateStructureList_T::const_iterator> segment_date_list_const_iterator;
- typedef stdair::BomConstIterator_T<SegmentDate,
- SegmentDateStructureList_T::const_reverse_iterator> segment_date_list_const_reverse_iterator;
- typedef stdair::BomIterator_T<SegmentDate,
- SegmentDateStructureList_T::const_iterator> segment_date_list_iterator;
- typedef stdair::BomIterator_T<SegmentDate,
- SegmentDateStructureList_T::const_reverse_iterator> segment_date_list_reverse_iterator;
-
- /** Define the segment-date map iterators. */
- typedef stdair::BomConstIterator_T<SegmentDate,
- SegmentDateStructureMap_T::const_iterator> segment_date_map_const_iterator;
- typedef stdair::BomConstIterator_T<SegmentDate,
- SegmentDateStructureMap_T::const_reverse_iterator> segment_date_map_const_reverse_iterator;
- typedef stdair::BomIterator_T<SegmentDate,
- SegmentDateStructureMap_T::const_iterator> segment_date_map_iterator;
- typedef stdair::BomIterator_T<SegmentDate,
- SegmentDateStructureMap_T::const_reverse_iterator> segment_date_map_reverse_iterator;
-
- /** Define the leg-date list iterators. */
- typedef stdair::BomConstIterator_T<LegDate,
- LegDateStructureList_T::const_iterator> leg_date_list_const_iterator;
- typedef stdair::BomConstIterator_T<LegDate,
- LegDateStructureList_T::const_reverse_iterator> leg_date_list_const_reverse_iterator;
- typedef stdair::BomIterator_T<LegDate,
- LegDateStructureList_T::const_iterator> leg_date_list_iterator;
- typedef stdair::BomIterator_T<LegDate,
- LegDateStructureList_T::const_reverse_iterator> leg_date_list_reverse_iterator;
-
- /** Define the leg-date map iterators. */
- typedef stdair::BomConstIterator_T<LegDate,
- LegDateStructureMap_T::const_iterator> leg_date_map_const_iterator;
- typedef stdair::BomConstIterator_T<LegDate,
- LegDateStructureMap_T::const_reverse_iterator> leg_date_map_const_reverse_iterator;
- typedef stdair::BomIterator_T<LegDate,
- LegDateStructureMap_T::const_iterator> leg_date_map_iterator;
- typedef stdair::BomIterator_T<LegDate,
- LegDateStructureMap_T::const_reverse_iterator> leg_date_map_reverse_iterator;
- // /////////////////////////////////////////////////////////////////////////
-
- public:
- // /////////// Display support methods /////////
- /** Dump a Business Object into an output stream.
- @param ostream& the output stream. */
- void toStream (std::ostream& ioOut) const;
-
- /** Read a Business Object from an input stream.
- @param istream& the input stream. */
- void fromStream (std::istream& ioIn);
-
- /** Get the serialised version of the Business Object. */
- std::string toString() const;
-
- /** Get a string describing the whole key (differentiating two objects
- at any level). */
- const std::string describeKey() const;
-
- /** Get a string describing the short key (differentiating two objects
- at the same level). */
- const std::string describeShortKey() const;
-
- private:
- /** Retrieve the BOM structure object. */
- BomStructure_T& getBomStructure () {
- return _flightDateStructure;
- }
-
- public:
- // /////////// Iteration methods //////////
- /** Initialise the internal const iterator on segment date:
- return the const iterator at the begining of the list. */
- segment_date_list_const_iterator segmentDateListConstIteratorBegin () const;
-
- /** Initialise the internal const iterator on segment date:
- return the const iterator at the end of the list. */
- segment_date_list_const_iterator segmentDateListConstIteratorEnd () const;
-
- /** Initialise the internal const reverse iterator on segment date:
- return the const reverse iterator at the rbegining of the list. */
- segment_date_list_const_reverse_iterator segmentDateListConstIteratorRBegin () const;
-
- /** Initialise the internal const reverse iterator on segment date:
- return the const reverse iterator at the end of the list. */
- segment_date_list_const_reverse_iterator segmentDateListConstIteratorREnd () const;
-
- /** Initialise the internal iterator on segment date:
- return the iterator at the begining of the list. */
- segment_date_list_iterator segmentDateListIteratorBegin () const;
-
- /** Initialise the internal iterator on segment date:
- return the iterator at the end of the list. */
- segment_date_list_iterator segmentDateListIteratorEnd () const;
-
- /** Initialise the internal reverse iterator on segment date:
- return the reverse iterator at the rbegining of the list. */
- segment_date_list_reverse_iterator segmentDateListIteratorRBegin () const;
-
- /** Initialise the internal reverse iterator on segment date:
- return the reverse iterator at the end of the list. */
- segment_date_list_reverse_iterator segmentDateListIteratorREnd () const;
-
- /** Initialise the internal const iterator on segment date:
- return the const iterator at the begining of the map. */
- segment_date_map_const_iterator segmentDateMapConstIteratorBegin () const;
-
- /** Initialise the internal const iterators on segment date:
- return the const iterator at the end of the map. */
- segment_date_map_const_iterator segmentDateMapConstIteratorEnd () const;
-
- /** Initialise the internal const reverse iterator on segment date:
- return the const reverse iterator at the rbegining of the map. */
- segment_date_map_const_reverse_iterator segmentDateMapConstIteratorRBegin () const;
-
- /** Initialise the internal const reverse iterator on segment date:
- return the const reverse iterator at the end of the map. */
- segment_date_map_const_reverse_iterator segmentDateMapConstIteratorREnd () const;
-
- /** Initialise the internal iterator on segment date:
- return the iterator at the begining of the map. */
- segment_date_map_iterator segmentDateMapIteratorBegin () const;
-
- /** Initialise the internal iterator on segment date:
- return the iterator at the end of the map. */
- segment_date_map_iterator segmentDateMapIteratorEnd () const;
-
- /** Initialise the internal reverse iterator on segment date:
- return the reverse iterator at the rbegining of the map. */
- segment_date_map_reverse_iterator segmentDateMapIteratorRBegin () const;
-
- /** Initialise the internal reverse iterator on segment date:
- return the reverse iterator at the end of the map. */
- segment_date_map_reverse_iterator segmentDateMapIteratorREnd () const;
-
- /** Initialise the internal const iterator on leg date:
- return the const iterator at the begining of the list. */
- leg_date_list_const_iterator legDateListConstIteratorBegin () const;
-
- /** Initialise the internal const iterator on leg date:
- return the const iterator at the end of the list. */
- leg_date_list_const_iterator legDateListConstIteratorEnd () const;
-
- /** Initialise the internal const reverse iterator on leg date:
- return the const reverse iterator at the rbegining of the list. */
- leg_date_list_const_reverse_iterator legDateListConstIteratorRBegin () const;
-
- /** Initialise the internal const reverse iterator on leg date:
- return the const reverse iterator at the end of the list. */
- leg_date_list_const_reverse_iterator legDateListConstIteratorREnd () const;
-
- /** Initialise the internal iterator on leg date:
- return the iterator at the begining of the list. */
- leg_date_list_iterator legDateListIteratorBegin () const;
-
- /** Initialise the internal iterator on leg date:
- return the iterator at the end of the list. */
- leg_date_list_iterator legDateListIteratorEnd () const;
-
- /** Initialise the internal reverse iterator on leg date:
- return the reverse iterator at the rbegining of the list. */
- leg_date_list_reverse_iterator legDateListIteratorRBegin () const;
-
- /** Initialise the internal reverse iterator on leg date:
- return the reverse iterator at the end of the list. */
- leg_date_list_reverse_iterator legDateListIteratorREnd () const;
-
- /** Initialise the internal const iterator on leg date:
- return the const iterator at the begining of the map. */
- leg_date_map_const_iterator legDateMapConstIteratorBegin () const;
-
- /** Initialise the internal const iterators on leg date:
- return the const iterator at the end of the map. */
- leg_date_map_const_iterator legDateMapConstIteratorEnd () const;
-
- /** Initialise the internal const reverse iterator on leg date:
- return the const reverse iterator at the rbegining of the map. */
- leg_date_map_const_reverse_iterator legDateMapConstIteratorRBegin () const;
-
- /** Initialise the internal const reverse iterator on leg date:
- return the const reverse iterator at the end of the map. */
- leg_date_map_const_reverse_iterator legDateMapConstIteratorREnd () const;
-
- /** Initialise the internal iterator on leg date:
- return the iterator at the begining of the map. */
- leg_date_map_iterator legDateMapIteratorBegin () const;
-
- /** Initialise the internal iterator on leg date:
- return the iterator at the end of the map. */
- leg_date_map_iterator legDateMapIteratorEnd () const;
-
- /** Initialise the internal reverse iterator on leg date:
- return the reverse iterator at the rbegining of the map. */
- leg_date_map_reverse_iterator legDateMapIteratorRBegin () const;
-
- /** Initialise the internal reverse iterator on leg date:
- return the reverse iterator at the end of the map. */
- leg_date_map_reverse_iterator legDateMapIteratorREnd () const;
-
- private:
- /** Constructors are private so as to force the usage of the Factory
- layer. */
- /** Default constructors. */
- FlightDate ();
- FlightDate (const FlightDate&);
- FlightDate (BomStructure_T&);
-
- /** Destructor. */
- virtual ~FlightDate();
-
- private:
- // Attributes
- /** Reference structure. */
- BomStructure_T& _flightDateStructure;
- };
-
-}
-#endif // __RMOL_BOM_FLIGHTDATE_HPP
-
Deleted: trunk/rmol/rmol/bom/FlightDateTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/FlightDateTypes.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/FlightDateTypes.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,34 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-#ifndef __RMOL_BOM_FLIGHTDATETYPES_HPP
-#define __RMOL_BOM_FLIGHTDATETYPES_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-
-// Forward declarations.
-namespace stdair {
- template <typename BOM_CONTENT> class FlightDate;
- template <typename BOM_CONTENT> class FlightDateKey;
-}
-
-namespace RMOL {
-
- // Forward declarations.
- class FlightDate;
-
- /** Define the FlightDate structure. */
- typedef stdair::FlightDate<FlightDate> FlightDateStructure_T;
-
- /** Define the FlightDate key. */
- typedef stdair::FlightDateKey<FlightDate> FlightDateKey_T;
-
- /** Define the flight-date structure list. */
- typedef std::vector<FlightDateStructure_T*> FlightDateStructureList_T;
-
- /** Define the flight-date structure map. */
- typedef std::map<const std::string, FlightDateStructure_T*> FlightDateStructureMap_T;
-
-}
-#endif // __RMOL_BOM_FLIGHTDATETYPES_HPP
-
Deleted: trunk/rmol/rmol/bom/Inventory.cpp
===================================================================
--- trunk/rmol/rmol/bom/Inventory.cpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/Inventory.cpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,147 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// STL
-#include <cassert>
-// STDAIR
-#include <stdair/bom/Inventory.hpp>
-// RMOL
-#include <rmol/bom/Inventory.hpp>
-#include <rmol/bom/FlightDate.hpp>
-#include <rmol/bom/SegmentDate.hpp>
-#include <rmol/bom/LegDate.hpp>
-#include <rmol/service/Logger.hpp>
-
-namespace RMOL {
-
- // ////////////////////////////////////////////////////////////////////
- Inventory::Inventory (BomStructure_T& ioInventoryStructure)
- : _inventoryStructure (ioInventoryStructure) {
- }
-
- // ////////////////////////////////////////////////////////////////////
- Inventory::~Inventory () {
- }
-
- // //////////////////////////////////////////////////////////////////////
- void Inventory::toStream (std::ostream& ioOut) const {
- ioOut << toString() << std::endl;
- }
-
- // //////////////////////////////////////////////////////////////////////
- void Inventory::fromStream (std::istream& ioIn) {
- }
-
- // //////////////////////////////////////////////////////////////////////
- std::string Inventory::toString() const {
- std::ostringstream oStr;
-
- _inventoryStructure.describeFull (oStr);
-
- return oStr.str();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string Inventory::describeKey() const {
- return _inventoryStructure.describeKey();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string Inventory::describeShortKey() const {
- return _inventoryStructure.describeShortKey();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- list_const_iterator Inventory::flightDateListConstIteratorBegin () const {
- return _inventoryStructure.flightDateListConstIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- list_const_iterator Inventory::flightDateListConstIteratorEnd () const {
- return _inventoryStructure.flightDateListConstIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::list_const_reverse_iterator Inventory::flightDateListConstIteratorRBegin () const {
- return _inventoryStructure.flightDateListConstIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::list_const_reverse_iterator Inventory::flightDateListConstIteratorREnd () const {
- return _inventoryStructure.flightDateListConstIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- list_iterator Inventory::flightDateListIteratorBegin () const {
- return _inventoryStructure.flightDateListIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- list_iterator Inventory::flightDateListIteratorEnd () const {
- return _inventoryStructure.flightDateListIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- list_reverse_iterator Inventory::flightDateListIteratorRBegin () const {
- return _inventoryStructure.flightDateListIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- list_reverse_iterator Inventory::flightDateListIteratorREnd () const {
- return _inventoryStructure.flightDateListIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- map_const_iterator Inventory::flightDateMapConstIteratorBegin () const {
- return _inventoryStructure.flightDateMapConstIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- map_const_iterator Inventory::flightDateMapConstIteratorEnd () const {
- return _inventoryStructure.flightDateMapConstIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::map_const_reverse_iterator Inventory::flightDateMapConstIteratorRBegin () const {
- return _inventoryStructure.flightDateMapConstIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::map_const_reverse_iterator Inventory::flightDateMapConstIteratorREnd () const {
- return _inventoryStructure.flightDateMapConstIteratorREnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- map_iterator Inventory::flightDateMapIteratorBegin () const {
- return _inventoryStructure.flightDateMapIteratorBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- map_iterator Inventory::flightDateMapIteratorEnd () const {
- return _inventoryStructure.flightDateMapIteratorEnd ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- map_reverse_iterator Inventory::flightDateMapIteratorRBegin () const {
- return _inventoryStructure.flightDateMapIteratorRBegin ();
- }
-
- // //////////////////////////////////////////////////////////////////////
- Inventory::
- map_reverse_iterator Inventory::flightDateMapIteratorREnd () const {
- return _inventoryStructure.flightDateMapIteratorREnd ();
- }
-
-}
-
Deleted: trunk/rmol/rmol/bom/Inventory.hpp
===================================================================
--- trunk/rmol/rmol/bom/Inventory.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/Inventory.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,191 +0,0 @@
-#ifndef __RMOL_BOM_INVENTORY_HPP
-#define __RMOL_BOM_INVENTORY_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// STDAIR
-#include <stdair/bom/BomContent.hpp>
-#include <stdair/bom/BomContentRoot.hpp>
-#include <stdair/bom/BomIterator.hpp>
-// RMOL
-#include <rmol/bom/BomRootTypes.hpp>
-#include <rmol/bom/InventoryTypes.hpp>
-#include <rmol/bom/FlightDateTypes.hpp>
-
-// Forward declarations
-namespace stdair {
- class FacBomContent;
- template <typename BOM_CONTENT, typename ITERATOR> struct BomConstIterator_T;
-}
-
-namespace RMOL {
-
- // Forward declarations.
- class FlightDate;
-
- /** Class representing the actual functional/business content for
- an airline inventory. */
- class Inventory : public stdair::BomContent {
- friend class stdair::FacBomContent;
-
- public:
- // /////////////////////////////////////////////////////////////////////////
- // See the explanations, within the stdair::BomContentRoot class, for all
- // the types which require to be specified below
- // /////////////////////////////////////////////////////////////////////////
- /** Definition allowing to retrieve the associated parent
- BOM content type. */
- typedef BomContentRoot_T ParentBomContent_T;
-
- /** Definition allowing to retrieve the associated BOM structure type. */
- typedef InventoryStructure_T BomStructure_T;
-
- /** Definition allowing to retrieve the associated BOM key type. */
- typedef InventoryKey_T BomKey_T;
-
- /** Definition allowing to retrieve the associated BOM content child
- type. */
- typedef FlightDate ContentChild_T;
- // /////////////////////////////////////////////////////////////////////////
-
-
- public:
- // /////////////////////////////////////////////////////////////////////////
- // See the explanations, within the stdair::BomContentRoot class, for all
- // the iterator types specified below
- // /////////////////////////////////////////////////////////////////////////
- /** Define the flight-date list iterators. */
- typedef stdair::BomConstIterator_T<FlightDate,
- FlightDateStructureList_T::const_iterator> list_const_iterator;
- typedef stdair::BomConstIterator_T<FlightDate,
- FlightDateStructureList_T::const_reverse_iterator> list_const_reverse_iterator;
- typedef stdair::BomIterator_T<FlightDate,
- FlightDateStructureList_T::const_iterator> list_iterator;
- typedef stdair::BomIterator_T<FlightDate,
- FlightDateStructureList_T::const_reverse_iterator> list_reverse_iterator;
-
- /** Define the flight-date map iterators. */
- typedef stdair::BomConstIterator_T<FlightDate,
- FlightDateStructureMap_T::const_iterator> map_const_iterator;
- typedef stdair::BomConstIterator_T<FlightDate,
- FlightDateStructureMap_T::const_reverse_iterator> map_const_reverse_iterator;
- typedef stdair::BomIterator_T<FlightDate,
- FlightDateStructureMap_T::const_iterator> map_iterator;
- typedef stdair::BomIterator_T<FlightDate,
- FlightDateStructureMap_T::const_reverse_iterator> map_reverse_iterator;
- // /////////////////////////////////////////////////////////////////////////
-
-
- public:
- // /////////// Display support methods /////////
- /** Dump a Business Object into an output stream.
- @param ostream& the output stream. */
- void toStream (std::ostream& ioOut) const;
-
- /** Read a Business Object from an input stream.
- @param istream& the input stream. */
- void fromStream (std::istream& ioIn);
-
- /** Get the serialised version of the Business Object. */
- std::string toString() const;
-
- /** Get a string describing the whole key (differentiating two objects
- at any level). */
- const std::string describeKey() const;
-
- /** Get a string describing the short key (differentiating two objects
- at the same level). */
- const std::string describeShortKey() const;
-
- // /////////// Iteration methods //////////
- /** Initialise the internal const iterator on flight date:
- return the const iterator at the begining of the list. */
- list_const_iterator flightDateListConstIteratorBegin () const;
-
- /** Initialise the internal const iterator on flight date:
- return the const iterator at the end of the list. */
- list_const_iterator flightDateListConstIteratorEnd () const;
-
- /** Initialise the internal const reverse iterator on flight date:
- return the const reverse iterator at the rbegining of the list. */
- list_const_reverse_iterator flightDateListConstIteratorRBegin () const;
-
- /** Initialise the internal const reverse iterator on flight date:
- return the const reverse iterator at the end of the list. */
- list_const_reverse_iterator flightDateListConstIteratorREnd () const;
-
- /** Initialise the internal iterator on flight date:
- return the iterator at the begining of the list. */
- list_iterator flightDateListIteratorBegin () const;
-
- /** Initialise the internal iterator on flight date:
- return the iterator at the end of the list. */
- list_iterator flightDateListIteratorEnd () const;
-
- /** Initialise the internal reverse iterator on flight date:
- return the reverse iterator at the rbegining of the list. */
- list_reverse_iterator flightDateListIteratorRBegin () const;
-
- /** Initialise the internal reverse iterator on flight date:
- return the reverse iterator at the end of the list. */
- list_reverse_iterator flightDateListIteratorREnd () const;
-
- /** Initialise the internal const iterator on flight date:
- return the const iterator at the begining of the map. */
- map_const_iterator flightDateMapConstIteratorBegin () const;
-
- /** Initialise the internal const iterators on flight date:
- return the const iterator at the end of the map. */
- map_const_iterator flightDateMapConstIteratorEnd () const;
-
- /** Initialise the internal const reverse iterator on flight date:
- return the const reverse iterator at the rbegining of the map. */
- map_const_reverse_iterator flightDateMapConstIteratorRBegin () const;
-
- /** Initialise the internal const reverse iterator on flight date:
- return the const reverse iterator at the end of the map. */
- map_const_reverse_iterator flightDateMapConstIteratorREnd () const;
-
- /** Initialise the internal iterator on flight date:
- return the iterator at the begining of the map. */
- map_iterator flightDateMapIteratorBegin () const;
-
- /** Initialise the internal iterator on flight date:
- return the iterator at the end of the map. */
- map_iterator flightDateMapIteratorEnd () const;
-
- /** Initialise the internal reverse iterator on flight date:
- return the reverse iterator at the rbegining of the map. */
- map_reverse_iterator flightDateMapIteratorRBegin () const;
-
- /** Initialise the internal reverse iterator on flight date:
- return the reverse iterator at the end of the map. */
- map_reverse_iterator flightDateMapIteratorREnd () const;
-
- private:
- /** Retrieve the BOM structure object. */
- BomStructure_T& getBomStructure () {
- return _inventoryStructure;
- }
-
- private:
- /** Constructors are private so as to force the usage of the Factory
- layer. */
- /** Default constructors. */
- Inventory ();
- Inventory (const Inventory&);
- Inventory (BomStructure_T&);
-
- /** Destructor. */
- virtual ~Inventory();
-
- private:
- // Attributes
- /** Reference structure. */
- BomStructure_T& _inventoryStructure;
- };
-
-}
-#endif // __RMOL_BOM_INVENTORY_HPP
-
Deleted: trunk/rmol/rmol/bom/InventoryTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/InventoryTypes.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/InventoryTypes.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,34 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-#ifndef __RMOL_BOM_INVENTORYTYPES_HPP
-#define __RMOL_BOM_INVENTORYTYPES_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-
-// Forward declarations.
-namespace stdair {
- template <typename BOM_CONTENT> class Inventory;
- template <typename BOM_CONTENT> class InventoryKey;
-}
-
-namespace RMOL {
-
- // Forward declarations.
- class Inventory;
-
- /** Define the Inventory structure. */
- typedef stdair::Inventory<Inventory> InventoryStructure_T;
-
- /** Define the Inventory key. */
- typedef stdair::InventoryKey<Inventory> InventoryKey_T;
-
- /** Define the flight-date structure list. */
- typedef std::vector<InventoryStructure_T*> InventoryStructureList_T;
-
- /** Define the flight-date structure map. */
- typedef std::map<const std::string, InventoryStructure_T*> InventoryStructureMap_T;
-
-}
-#endif // __RMOL_BOM_INVENTORYTYPES_HPP
-
Deleted: trunk/rmol/rmol/bom/LegDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/LegDate.cpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/LegDate.cpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,56 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// C
-#include <cassert>
-// STDAIR
-#include <stdair/bom/LegDate.hpp>
-// RMOL
-#include <rmol/bom/FlightDate.hpp>
-#include <rmol/bom/LegDate.hpp>
-
-namespace RMOL {
-
- // ////////////////////////////////////////////////////////////////////
- LegDate::LegDate (BomStructure_T& ioLegStructure)
- : _legDateStructure (ioLegStructure) {
- }
-
- // ////////////////////////////////////////////////////////////////////
- LegDate::~LegDate () {
- }
-
- // //////////////////////////////////////////////////////////////////////
- void LegDate::toStream (std::ostream& ioOut) const {
- ioOut << toString() << std::endl;
- }
-
- // //////////////////////////////////////////////////////////////////////
- void LegDate::fromStream (std::istream& ioIn) {
- }
-
- // //////////////////////////////////////////////////////////////////////
- std::string LegDate::toString() const {
- std::ostringstream oStr;
-
- // First, put the key of that level
- oStr << describeShortKey() << std::endl;
-
- // Then, browse the children
- // [...] (no child for now)
-
- return oStr.str();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string LegDate::describeKey() const {
- return _legDateStructure.describeKey();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string LegDate::describeShortKey() const {
- return _legDateStructure.describeShortKey();
- }
-
-}
-
Deleted: trunk/rmol/rmol/bom/LegDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/LegDate.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/LegDate.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,86 +0,0 @@
-#ifndef __RMOL_BOM_LEGDATE_HPP
-#define __RMOL_BOM_LEGDATE_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// STDAIR
-#include <stdair/bom/BomContent.hpp>
-// RMOL
-#include <rmol/bom/LegDateTypes.hpp>
-
-// Forward declarations
-namespace stdair {
- class FacBomContent;
-}
-
-namespace RMOL {
-
- // Forward declarations
- class FlightDate;
-
- /** Class representing the actual functional/business content for a
- leg-date. */
- class LegDate : public stdair::BomContent {
- friend class stdair::FacBomContent;
-
- public:
- // Type definitions
- /** Definition allowing to retrieve the associated parent
- BOM content type. */
- typedef FlightDate ParentBomContent_T;
-
- /** Definition allowing to retrieve the associated BOM structure type. */
- typedef LegDateStructure_T BomStructure_T;
-
- /** Definition allowing to retrieve the associated BOM key type. */
- typedef LegDateKey_T BomKey_T;
-
- public:
-
- // /////////// Display support methods /////////
- /** Dump a Business Object into an output stream.
- @param ostream& the output stream. */
- void toStream (std::ostream& ioOut) const;
-
- /** Read a Business Object from an input stream.
- @param istream& the input stream. */
- void fromStream (std::istream& ioIn);
-
- /** Get the serialised version of the Business Object. */
- std::string toString() const;
-
- /** Get a string describing the whole key (differentiating two objects
- at any level). */
- const std::string describeKey() const;
-
- /** Get a string describing the short key (differentiating two objects
- at the same level). */
- const std::string describeShortKey() const;
-
- private:
- /** Retrieve the BOM structure object. */
- BomStructure_T& getBomStructure () {
- return _legDateStructure;
- }
-
- private:
- /** Constructors are private so as to force the usage of the Factory
- layer. */
- /** Default constructors. */
- LegDate ();
- LegDate (const LegDate&);
- LegDate (BomStructure_T&);
-
- /** Destructor. */
- virtual ~LegDate();
-
- private:
- // Attributes
- /** Reference structure. */
- BomStructure_T& _legDateStructure;
- };
-
-}
-#endif // __RMOL_BOM_LEGDATE_HPP
-
Deleted: trunk/rmol/rmol/bom/LegDateTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/LegDateTypes.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/LegDateTypes.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,34 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-#ifndef __RMOL_BOM_LEGDATETYPES_HPP
-#define __RMOL_BOM_LEGDATETYPES_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-
-// Forward declarations.
-namespace stdair {
- template <typename BOM_CONTENT> class LegDate;
- template <typename BOM_CONTENT> class LegDateKey;
-}
-
-namespace RMOL {
-
- // Forward declarations.
- class LegDate;
-
- /** Define the LegDate structure. */
- typedef stdair::LegDate<LegDate> LegDateStructure_T;
-
- /** Define the LegDate key. */
- typedef stdair::LegDateKey<LegDate> LegDateKey_T;
-
- /** Define the leg-date structure list. */
- typedef std::vector<LegDateStructure_T*> LegDateStructureList_T;
-
- /** Define the leg-date structure map. */
- typedef std::map<const std::string, LegDateStructure_T*> LegDateStructureMap_T;
-
-}
-#endif // __RMOL_BOM_LEGDATETYPES_HPP
-
Deleted: trunk/rmol/rmol/bom/SegmentDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.cpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/SegmentDate.cpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,56 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// C
-#include <cassert>
-// STDAIR
-#include <stdair/bom/SegmentDate.hpp>
-// RMOL
-#include <rmol/bom/FlightDate.hpp>
-#include <rmol/bom/SegmentDate.hpp>
-
-namespace RMOL {
-
- // ////////////////////////////////////////////////////////////////////
- SegmentDate::SegmentDate (BomStructure_T& ioSegmentStructure)
- : _segmentDateStructure (ioSegmentStructure) {
- }
-
- // ////////////////////////////////////////////////////////////////////
- SegmentDate::~SegmentDate () {
- }
-
- // //////////////////////////////////////////////////////////////////////
- void SegmentDate::toStream (std::ostream& ioOut) const {
- ioOut << toString() << std::endl;
- }
-
- // //////////////////////////////////////////////////////////////////////
- void SegmentDate::fromStream (std::istream& ioIn) {
- }
-
- // //////////////////////////////////////////////////////////////////////
- std::string SegmentDate::toString() const {
- std::ostringstream oStr;
-
- // First, put the key of that level
- oStr << describeShortKey() << std::endl;
-
- // Then, browse the children
- // [...] (no child for now)
-
- return oStr.str();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string SegmentDate::describeKey() const {
- return _segmentDateStructure.describeKey();
- }
-
- // //////////////////////////////////////////////////////////////////////
- const std::string SegmentDate::describeShortKey() const {
- return _segmentDateStructure.describeShortKey();
- }
-
-}
-
Deleted: trunk/rmol/rmol/bom/SegmentDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/SegmentDate.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,86 +0,0 @@
-#ifndef __RMOL_BOM_SEGMENTDATE_HPP
-#define __RMOL_BOM_SEGMENTDATE_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-// STDAIR
-#include <stdair/bom/BomContent.hpp>
-// RMOL
-#include <rmol/bom/SegmentDateTypes.hpp>
-
-// Forward declarations
-namespace stdair {
- class FacBomContent;
-}
-
-namespace RMOL {
-
- // Forward declarations
- class FlightDate;
-
- /** Class representing the actual functional/business content for a
- segment-date. */
- class SegmentDate : public stdair::BomContent {
- friend class stdair::FacBomContent;
-
- public:
- // Type definitions
- /** Definition allowing to retrieve the associated parent
- BOM content type. */
- typedef FlightDate ParentBomContent_T;
-
- /** Definition allowing to retrieve the associated BOM structure type. */
- typedef SegmentDateStructure_T BomStructure_T;
-
- /** Definition allowing to retrieve the associated BOM key type. */
- typedef SegmentDateKey_T BomKey_T;
-
- public:
-
- // /////////// Display support methods /////////
- /** Dump a Business Object into an output stream.
- @param ostream& the output stream. */
- void toStream (std::ostream& ioOut) const;
-
- /** Read a Business Object from an input stream.
- @param istream& the input stream. */
- void fromStream (std::istream& ioIn);
-
- /** Get the serialised version of the Business Object. */
- std::string toString() const;
-
- /** Get a string describing the whole key (differentiating two objects
- at any level). */
- const std::string describeKey() const;
-
- /** Get a string describing the short key (differentiating two objects
- at the same level). */
- const std::string describeShortKey() const;
-
- private:
- /** Retrieve the BOM structure object. */
- BomStructure_T& getBomStructure () {
- return _segmentDateStructure;
- }
-
- private:
- /** Constructors are private so as to force the usage of the Factory
- layer. */
- /** Default constructors. */
- SegmentDate ();
- SegmentDate (const SegmentDate&);
- SegmentDate (BomStructure_T&);
-
- /** Destructor. */
- virtual ~SegmentDate();
-
- private:
- // Attributes
- /** Reference structure. */
- BomStructure_T& _segmentDateStructure;
- };
-
-}
-#endif // __RMOL_BOM_SEGMENTDATE_HPP
-
Deleted: trunk/rmol/rmol/bom/SegmentDateTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDateTypes.hpp 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/SegmentDateTypes.hpp 2009-10-08 15:10:53 UTC (rev 271)
@@ -1,34 +0,0 @@
-// //////////////////////////////////////////////////////////////////////
-#ifndef __RMOL_BOM_SEGMENTDATETYPES_HPP
-#define __RMOL_BOM_SEGMENTDATETYPES_HPP
-
-// //////////////////////////////////////////////////////////////////////
-// Import section
-// //////////////////////////////////////////////////////////////////////
-
-// Forward declarations.
-namespace stdair {
- template <typename BOM_CONTENT> class SegmentDate;
- template <typename BOM_CONTENT> class SegmentDateKey;
-}
-
-namespace RMOL {
-
- // Forward declarations.
- class SegmentDate;
-
- /** Define the SegmentDate structure. */
- typedef stdair::SegmentDate<SegmentDate> SegmentDateStructure_T;
-
- /** Define the SegmentDate key. */
- typedef stdair::SegmentDateKey<SegmentDate> SegmentDateKey_T;
-
- /** Define the segment-date structure list. */
- typedef std::vector<SegmentDateStructure_T*> SegmentDateStructureList_T;
-
- /** Define the segment-date structure map. */
- typedef std::map<const std::string, SegmentDateStructure_T*> SegmentDateStructureMap_T;
-
-}
-#endif // __RMOL_BOM_SEGMENTDATETYPES_HPP
-
Modified: trunk/rmol/rmol/bom/sources.mk
===================================================================
--- trunk/rmol/rmol/bom/sources.mk 2009-10-06 14:29:17 UTC (rev 270)
+++ trunk/rmol/rmol/bom/sources.mk 2009-10-08 15:10:53 UTC (rev 271)
@@ -23,16 +23,7 @@
$(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \
$(top_srcdir)/rmol/bom/StudyStatManager.hpp \
$(top_srcdir)/rmol/bom/ExpectationMaximization.hpp \
- $(top_srcdir)/rmol/bom/QForecaster.hpp \
- $(top_srcdir)/rmol/bom/BomRootTypes.hpp \
- $(top_srcdir)/rmol/bom/InventoryTypes.hpp \
- $(top_srcdir)/rmol/bom/Inventory.hpp \
- $(top_srcdir)/rmol/bom/FlightDateTypes.hpp \
- $(top_srcdir)/rmol/bom/FlightDate.hpp \
- $(top_srcdir)/rmol/bom/LegDateTypes.hpp \
- $(top_srcdir)/rmol/bom/LegDate.hpp \
- $(top_srcdir)/rmol/bom/SegmentDateTypes.hpp \
- $(top_srcdir)/rmol/bom/SegmentDate.hpp
+ $(top_srcdir)/rmol/bom/QForecaster.hpp
bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \
$(top_srcdir)/rmol/bom/Bucket.cpp \
@@ -52,8 +43,5 @@
$(top_srcdir)/rmol/bom/StatAggregatorStruct.cpp \
$(top_srcdir)/rmol/bom/StudyStatManager.cpp \
$(top_srcdir)/rmol/bom/ExpectationMaximization.cpp \
- $(top_srcdir)/rmol/bom/QForecaster.cpp \
- $(top_srcdir)/rmol/bom/Inventory.cpp \
- $(top_srcdir)/rmol/bom/FlightDate.cpp \
- $(top_srcdir)/rmol/bom/LegDate.cpp \
- $(top_srcdir)/rmol/bom/SegmentDate.cpp
+ $(top_srcdir)/rmol/bom/QForecaster.cpp
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-10-06 14:29:28
|
Revision: 270
http://rmol.svn.sourceforge.net/rmol/?rev=270&view=rev
Author: denis_arnaud
Date: 2009-10-06 14:29:17 +0000 (Tue, 06 Oct 2009)
Log Message:
-----------
[Test] Fixed the Makefile so that the stdair test can build.
Modified Paths:
--------------
trunk/rmol/test/stdair/Makefile.am
trunk/rmol/test/stdair/stdair.cpp
Property Changed:
----------------
trunk/rmol/test/stdair/
Property changes on: trunk/rmol/test/stdair
___________________________________________________________________
Modified: svn:ignore
- .deps
.libs
Makefile
Makefile.in
+ .deps
.libs
Makefile
Makefile.in
stdair
Modified: trunk/rmol/test/stdair/Makefile.am
===================================================================
--- trunk/rmol/test/stdair/Makefile.am 2009-10-06 14:22:28 UTC (rev 269)
+++ trunk/rmol/test/stdair/Makefile.am 2009-10-06 14:29:17 UTC (rev 270)
@@ -15,6 +15,6 @@
stdair_CXXFLAGS= $(BOOST_CFLAGS)
stdair_LDADD =
stdair_LDFLAGS = $(BOOST_LIBS) \
- $(top_builddir)/stdair/core/libstdair.la
+ $(top_builddir)/stdair/core/libstdair.la \
$(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la
Modified: trunk/rmol/test/stdair/stdair.cpp
===================================================================
--- trunk/rmol/test/stdair/stdair.cpp 2009-10-06 14:22:28 UTC (rev 269)
+++ trunk/rmol/test/stdair/stdair.cpp 2009-10-06 14:29:17 UTC (rev 270)
@@ -22,15 +22,12 @@
#include <rmol/bom/FlightDate.hpp>
#include <rmol/bom/LegDate.hpp>
#include <rmol/bom/SegmentDate.hpp>
+#include <rmol/service/Logger.hpp>
-// /////////////////////////////////////////////////////////////////
-#define LOG_DEBUG(iToBeLogged) \
- { std::cout << __FILE__ << ":" << __LINE__ << ": " << iToBeLogged << std::endl; }
-
// //////////////////////////////////////////////////////////////////////
RMOL::Inventory& initialise () {
// DEBUG
- LOG_DEBUG ("Welcome to Air-Schedule");
+ RMOL_LOG_DEBUG ("Welcome to Air-Schedule");
// Step 0.0: initialisation
// Create the root of the Bom tree (i.e., a BomContentRoot object)
@@ -48,7 +45,7 @@
lInventoryKey);
// Display the inventory
- LOG_DEBUG ("Inventory: " << lInventory.toString());
+ RMOL_LOG_DEBUG ("Inventory: " << lInventory.toString());
// Step 0.2: Flight-date level
// Create a FlightDate (BA15/10-JUN-2010)
@@ -61,7 +58,7 @@
lFlightDateKey);
// Display the flight-date
- LOG_DEBUG ("FlightDate: " << lFlightDate.toString());
+ RMOL_LOG_DEBUG ("FlightDate: " << lFlightDate.toString());
// Step 0.3: Segment-date level
// Create a first SegmentDate (LHR-SYD)
@@ -74,7 +71,7 @@
lSegmentDateKey);
// Display the segment-date
- LOG_DEBUG ("SegmentDate: " << lLHRSYDSegment.toString());
+ RMOL_LOG_DEBUG ("SegmentDate: " << lLHRSYDSegment.toString());
// Create a second SegmentDate (LHR-BKK)
@@ -86,7 +83,7 @@
lSegmentDateKey);
// Display the segment-date
- LOG_DEBUG ("SegmentDate: " << lLHRBKKSegment.toString());
+ RMOL_LOG_DEBUG ("SegmentDate: " << lLHRBKKSegment.toString());
// Create a third SegmentDate (BKK-SYD)
@@ -97,7 +94,7 @@
lSegmentDateKey);
// Display the segment-date
- LOG_DEBUG ("SegmentDate: " << lBKKSYDSegment.toString());
+ RMOL_LOG_DEBUG ("SegmentDate: " << lBKKSYDSegment.toString());
// Step 0.4: Leg-date level
@@ -109,7 +106,7 @@
lLegDateKey);
// Display the leg-date
- LOG_DEBUG ("LegDate: " << lLHRLeg.toString());
+ RMOL_LOG_DEBUG ("LegDate: " << lLHRLeg.toString());
// Create a second LegDate (BKK)
lLegDateKey = RMOL::LegDateKey_T (lBKK);
@@ -119,99 +116,99 @@
lLegDateKey);
// Display the leg-date
- LOG_DEBUG ("LegDate: " << lBKKLeg.toString());
+ RMOL_LOG_DEBUG ("LegDate: " << lBKKLeg.toString());
// Step 0.5: Initialisation results
// Display the full structure and content
- LOG_DEBUG ("Full Inventory: " << lInventory.toString());
+ RMOL_LOG_DEBUG ("Full Inventory: " << lInventory.toString());
return lInventory;
}
// ////////////////////////////////////////////////////////////////
void testIteratorInventory (const RMOL::Inventory& iInventory) {
- LOG_DEBUG ("Test iterator.");
+ RMOL_LOG_DEBUG ("Test iterator.");
// Browse the list with a for-loop
- LOG_DEBUG ("Browse the list");
+ RMOL_LOG_DEBUG ("Browse the list");
for (RMOL::Inventory::list_const_iterator itInv =
iInventory.flightDateListConstIteratorBegin();
itInv != iInventory.flightDateListConstIteratorEnd(); ++itInv) {
- LOG_DEBUG ("Current flight-date: " << *itInv);
+ RMOL_LOG_DEBUG ("Current flight-date: " << *itInv);
}
// Browse the map with a for-loop
- LOG_DEBUG ("Browse the map with const_iterator");
+ RMOL_LOG_DEBUG ("Browse the map with const_iterator");
for (RMOL::Inventory::map_const_iterator itInv =
iInventory.flightDateMapConstIteratorBegin();
itInv != iInventory.flightDateMapConstIteratorEnd(); ++itInv) {
const RMOL::FlightDate* lCurrentFlightDate_ptr = itInv->second;
- LOG_DEBUG ("Current flight-date: "
+ RMOL_LOG_DEBUG ("Current flight-date: "
<< lCurrentFlightDate_ptr->toString());
}
- LOG_DEBUG ("Browse the map with reverse_iterator");
+ RMOL_LOG_DEBUG ("Browse the map with reverse_iterator");
for (RMOL::Inventory::map_reverse_iterator itInv =
iInventory.flightDateMapIteratorRBegin();
itInv != iInventory.flightDateMapIteratorREnd(); ++itInv) {
RMOL::FlightDate* lCurrentFlightDate_ptr = itInv->second;
- LOG_DEBUG ("Current flight-date: "
+ RMOL_LOG_DEBUG ("Current flight-date: "
<< lCurrentFlightDate_ptr->toString());
}
- LOG_DEBUG ("Test operators: ");
+ RMOL_LOG_DEBUG ("Test operators: ");
RMOL::Inventory::list_const_iterator itBegin =
iInventory.flightDateListConstIteratorBegin();
RMOL::Inventory::list_const_iterator itEnd =
iInventory.flightDateListConstIteratorEnd();
- LOG_DEBUG ("itEnd - itBegin, should be 1: " << itEnd - itBegin);
- LOG_DEBUG ("itBegin - itEnd, should be -1: " << itBegin - itEnd);
- LOG_DEBUG ("itBegin < itEnd, should be 1: " << (itBegin < itEnd));
- LOG_DEBUG ("itEnd - (1 + itBegin), should be 0: "
+ RMOL_LOG_DEBUG ("itEnd - itBegin, should be 1: " << itEnd - itBegin);
+ RMOL_LOG_DEBUG ("itBegin - itEnd, should be -1: " << itBegin - itEnd);
+ RMOL_LOG_DEBUG ("itBegin < itEnd, should be 1: " << (itBegin < itEnd));
+ RMOL_LOG_DEBUG ("itEnd - (1 + itBegin), should be 0: "
<< (itEnd - (1 + itBegin)));
- LOG_DEBUG ( *(itEnd - 1));
- LOG_DEBUG ( *(itEnd -=1));
+ RMOL_LOG_DEBUG ( *(itEnd - 1));
+ RMOL_LOG_DEBUG ( *(itEnd -=1));
}
// ////////////////////////////////////////////////////////////////
void testIteratorFlightDate (const RMOL::FlightDate& iFlightDate) {
- LOG_DEBUG ("Test iterator.");
+ RMOL_LOG_DEBUG ("Test iterator.");
// Browse the list with a for-loop
- LOG_DEBUG ("Browse the segment-date list");
+ RMOL_LOG_DEBUG ("Browse the segment-date list");
for (RMOL::FlightDate::segment_date_list_const_iterator itSD =
iFlightDate.segmentDateListConstIteratorBegin();
itSD != iFlightDate.segmentDateListConstIteratorEnd(); ++itSD) {
- LOG_DEBUG ("Current segment-date: " << *itSD);
+ RMOL_LOG_DEBUG ("Current segment-date: " << *itSD);
}
// Browse the map with a for-loop
- LOG_DEBUG ("Browse the segment_date map with const_iterator");
+ RMOL_LOG_DEBUG ("Browse the segment_date map with const_iterator");
for (RMOL::FlightDate::segment_date_map_const_iterator itSD =
iFlightDate.segmentDateMapConstIteratorBegin();
itSD != iFlightDate.segmentDateMapConstIteratorEnd(); ++itSD) {
const RMOL::SegmentDate* lCurrentSegmentDate_ptr = itSD->second;
- LOG_DEBUG ("Current segment-date: "
+ RMOL_LOG_DEBUG ("Current segment-date: "
<< lCurrentSegmentDate_ptr->toString());
}
// Browse the list with a for-loop
- LOG_DEBUG ("Browse the leg-date list");
+ RMOL_LOG_DEBUG ("Browse the leg-date list");
for (RMOL::FlightDate::leg_date_list_const_iterator itLD =
iFlightDate.legDateListConstIteratorBegin();
itLD != iFlightDate.legDateListConstIteratorEnd(); ++itLD) {
- LOG_DEBUG ("Current leg-date: " << *itLD);
+ RMOL_LOG_DEBUG ("Current leg-date: " << *itLD);
}
// Browse the map with a for-loop
- LOG_DEBUG ("Browse the leg_date map with const_iterator");
+ RMOL_LOG_DEBUG ("Browse the leg_date map with const_iterator");
for (RMOL::FlightDate::leg_date_map_const_iterator itLD =
iFlightDate.legDateMapConstIteratorBegin();
itLD != iFlightDate.legDateMapConstIteratorEnd(); ++itLD) {
const RMOL::LegDate* lCurrentLegDate_ptr = itLD->second;
- LOG_DEBUG ("Current leg-date: "
+ RMOL_LOG_DEBUG ("Current leg-date: "
<< lCurrentLegDate_ptr->toString());
}
}
@@ -220,18 +217,20 @@
// ////////////// M A I N ///////////////
int main (int argc, char* argv[]) {
+ //
RMOL::Inventory& lInventory = initialise();
+ //
testIteratorInventory (lInventory);
// Browse the list with a for-loop
- LOG_DEBUG ("Browse the list");
+ RMOL_LOG_DEBUG ("Browse the list");
for (RMOL::Inventory::list_const_iterator itInv =
lInventory.flightDateListConstIteratorBegin();
itInv != lInventory.flightDateListConstIteratorEnd(); ++itInv) {
const RMOL::FlightDate& lFlightDate = *itInv;
- LOG_DEBUG ("Current flight-date: " << lFlightDate);
+ RMOL_LOG_DEBUG ("Current flight-date: " << lFlightDate);
testIteratorFlightDate (lFlightDate);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-10-06 14:22:38
|
Revision: 269
http://rmol.svn.sourceforge.net/rmol/?rev=269&view=rev
Author: denis_arnaud
Date: 2009-10-06 14:22:28 +0000 (Tue, 06 Oct 2009)
Log Message:
-----------
[StdAir] Imported Air-Sched (temporary) BOM, so as to alpha test that new model.
Modified Paths:
--------------
trunk/rmol/Makefile.am
trunk/rmol/configure.ac
trunk/rmol/rmol/bom/sources.mk
trunk/rmol/test/Makefile.am
Added Paths:
-----------
trunk/rmol/rmol/bom/BomRootTypes.hpp
trunk/rmol/rmol/bom/FlightDate.cpp
trunk/rmol/rmol/bom/FlightDate.hpp
trunk/rmol/rmol/bom/FlightDateTypes.hpp
trunk/rmol/rmol/bom/Inventory.cpp
trunk/rmol/rmol/bom/Inventory.hpp
trunk/rmol/rmol/bom/InventoryTypes.hpp
trunk/rmol/rmol/bom/LegDate.cpp
trunk/rmol/rmol/bom/LegDate.hpp
trunk/rmol/rmol/bom/LegDateTypes.hpp
trunk/rmol/rmol/bom/SegmentDate.cpp
trunk/rmol/rmol/bom/SegmentDate.hpp
trunk/rmol/rmol/bom/SegmentDateTypes.hpp
trunk/rmol/test/stdair/
trunk/rmol/test/stdair/Makefile.am
trunk/rmol/test/stdair/stdair.cpp
Modified: trunk/rmol/Makefile.am
===================================================================
--- trunk/rmol/Makefile.am 2009-10-06 13:34:21 UTC (rev 268)
+++ trunk/rmol/Makefile.am 2009-10-06 14:22:28 UTC (rev 269)
@@ -25,7 +25,7 @@
EXTRA_DIST =
# Build in these directories:
-SUBDIRS = rmol win32 po man $(INFO_DOC_DIR) $(HTML_DOC_DIR) samples $(TEST_DIR)
+SUBDIRS = stdair rmol win32 po man $(INFO_DOC_DIR) $(HTML_DOC_DIR) samples $(TEST_DIR)
# Configuration helpers
Modified: trunk/rmol/configure.ac
===================================================================
--- trunk/rmol/configure.ac 2009-10-06 13:34:21 UTC (rev 268)
+++ trunk/rmol/configure.ac 2009-10-06 14:22:28 UTC (rev 269)
@@ -286,6 +286,12 @@
rmol.pc
rmol.spec
rmol.m4
+ stdair/Makefile
+ stdair/basic/Makefile
+ stdair/bom/Makefile
+ stdair/factory/Makefile
+ stdair/core/Makefile
+ stdair/config/Makefile
rmol/Makefile
rmol/basic/Makefile
rmol/field/Makefile
@@ -310,6 +316,7 @@
po/Makefile.in
test/Makefile
test/com/Makefile
+ test/stdair/Makefile
win32/Makefile)
AC_OUTPUT
Added: trunk/rmol/rmol/bom/BomRootTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/BomRootTypes.hpp (rev 0)
+++ trunk/rmol/rmol/bom/BomRootTypes.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,32 @@
+// //////////////////////////////////////////////////////////////////////
+#ifndef __RMOL_BOM_BOMROOTTYPES_HPP
+#define __RMOL_BOM_BOMROOTTYPES_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+
+// Forward declarations.
+namespace stdair {
+ template <typename BOM_CONTENT> class BomStructureRoot;
+ template <typename BOM_CONTENT> class BomStructureRootKey;
+ template <typename BOM_CHILD> class BomContentRoot;
+}
+
+namespace RMOL {
+
+ // Forward declarations.
+ class Inventory;
+
+ /** Define the BomContentRoot. */
+ typedef stdair::BomContentRoot<Inventory> BomContentRoot_T;
+
+ /** Define the BomStructureRoot. */
+ typedef stdair::BomStructureRoot<BomContentRoot_T> BomStructureRoot_T;
+
+ /** Define the BomStructureRootKey. */
+ typedef stdair::BomStructureRootKey<BomContentRoot_T> BomStructureRootKey_T;
+
+}
+#endif // __RMOL_BOM_BOMROOTTYPES_HPP
+
Added: trunk/rmol/rmol/bom/FlightDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/FlightDate.cpp (rev 0)
+++ trunk/rmol/rmol/bom/FlightDate.cpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,243 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// C
+#include <cassert>
+// STL
+#include <sstream>
+#include <algorithm>
+// STDAIR
+#include <stdair/bom/FlightDate.hpp>
+// RMOL
+#include <rmol/bom/Inventory.hpp>
+#include <rmol/bom/FlightDate.hpp>
+#include <rmol/bom/SegmentDate.hpp>
+#include <rmol/bom/LegDate.hpp>
+#include <rmol/service/Logger.hpp>
+
+namespace RMOL {
+
+ // ////////////////////////////////////////////////////////////////////
+ FlightDate::FlightDate (BomStructure_T& ioFlightStructure)
+ : _flightDateStructure (ioFlightStructure) {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ FlightDate::~FlightDate () {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void FlightDate::toStream (std::ostream& ioOut) const {
+ ioOut << toString() << std::endl;
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void FlightDate::fromStream (std::istream& ioIn) {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ std::string FlightDate::toString() const {
+ std::ostringstream oStr;
+
+ // First, put the key of that level
+ oStr << describeShortKey() << std::endl;
+
+ return oStr.str();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string FlightDate::describeKey() const {
+ return _flightDateStructure.describeKey();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string FlightDate::describeShortKey() const {
+ return _flightDateStructure.describeShortKey();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_list_const_iterator FlightDate::segmentDateListConstIteratorBegin () const {
+ return _flightDateStructure.segmentDateListConstIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_list_const_iterator FlightDate::segmentDateListConstIteratorEnd () const {
+ return _flightDateStructure.segmentDateListConstIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::segment_date_list_const_reverse_iterator FlightDate::segmentDateListConstIteratorRBegin () const {
+ return _flightDateStructure.segmentDateListConstIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::segment_date_list_const_reverse_iterator FlightDate::segmentDateListConstIteratorREnd () const {
+ return _flightDateStructure.segmentDateListConstIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_list_iterator FlightDate::segmentDateListIteratorBegin () const {
+ return _flightDateStructure.segmentDateListIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_list_iterator FlightDate::segmentDateListIteratorEnd () const {
+ return _flightDateStructure.segmentDateListIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_list_reverse_iterator FlightDate::segmentDateListIteratorRBegin () const {
+ return _flightDateStructure.segmentDateListIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_list_reverse_iterator FlightDate::segmentDateListIteratorREnd () const {
+ return _flightDateStructure.segmentDateListIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_map_const_iterator FlightDate::segmentDateMapConstIteratorBegin () const {
+ return _flightDateStructure.segmentDateMapConstIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_map_const_iterator FlightDate::segmentDateMapConstIteratorEnd () const {
+ return _flightDateStructure.segmentDateMapConstIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::segment_date_map_const_reverse_iterator FlightDate::segmentDateMapConstIteratorRBegin () const {
+ return _flightDateStructure.segmentDateMapConstIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::segment_date_map_const_reverse_iterator FlightDate::segmentDateMapConstIteratorREnd () const {
+ return _flightDateStructure.segmentDateMapConstIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_map_iterator FlightDate::segmentDateMapIteratorBegin () const {
+ return _flightDateStructure.segmentDateMapIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_map_iterator FlightDate::segmentDateMapIteratorEnd () const {
+ return _flightDateStructure.segmentDateMapIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_map_reverse_iterator FlightDate::segmentDateMapIteratorRBegin () const {
+ return _flightDateStructure.segmentDateMapIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ segment_date_map_reverse_iterator FlightDate::segmentDateMapIteratorREnd () const {
+ return _flightDateStructure.segmentDateMapIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_list_const_iterator FlightDate::legDateListConstIteratorBegin () const {
+ return _flightDateStructure.legDateListConstIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_list_const_iterator FlightDate::legDateListConstIteratorEnd () const {
+ return _flightDateStructure.legDateListConstIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::leg_date_list_const_reverse_iterator FlightDate::legDateListConstIteratorRBegin () const {
+ return _flightDateStructure.legDateListConstIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::leg_date_list_const_reverse_iterator FlightDate::legDateListConstIteratorREnd () const {
+ return _flightDateStructure.legDateListConstIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_list_iterator FlightDate::legDateListIteratorBegin () const {
+ return _flightDateStructure.legDateListIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_list_iterator FlightDate::legDateListIteratorEnd () const {
+ return _flightDateStructure.legDateListIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_list_reverse_iterator FlightDate::legDateListIteratorRBegin () const {
+ return _flightDateStructure.legDateListIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_list_reverse_iterator FlightDate::legDateListIteratorREnd () const {
+ return _flightDateStructure.legDateListIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_map_const_iterator FlightDate::legDateMapConstIteratorBegin () const {
+ return _flightDateStructure.legDateMapConstIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_map_const_iterator FlightDate::legDateMapConstIteratorEnd () const {
+ return _flightDateStructure.legDateMapConstIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::leg_date_map_const_reverse_iterator FlightDate::legDateMapConstIteratorRBegin () const {
+ return _flightDateStructure.legDateMapConstIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::leg_date_map_const_reverse_iterator FlightDate::legDateMapConstIteratorREnd () const {
+ return _flightDateStructure.legDateMapConstIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_map_iterator FlightDate::legDateMapIteratorBegin () const {
+ return _flightDateStructure.legDateMapIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_map_iterator FlightDate::legDateMapIteratorEnd () const {
+ return _flightDateStructure.legDateMapIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_map_reverse_iterator FlightDate::legDateMapIteratorRBegin () const {
+ return _flightDateStructure.legDateMapIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ FlightDate::
+ leg_date_map_reverse_iterator FlightDate::legDateMapIteratorREnd () const {
+ return _flightDateStructure.legDateMapIteratorREnd ();
+ }
+
+}
+
Added: trunk/rmol/rmol/bom/FlightDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/FlightDate.hpp (rev 0)
+++ trunk/rmol/rmol/bom/FlightDate.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,278 @@
+#ifndef __RMOL_BOM_FLIGHTDATE_HPP
+#define __RMOL_BOM_FLIGHTDATE_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STDAIR
+#include <stdair/bom/BomStructureList.hpp>
+#include <stdair/bom/BomContent.hpp>
+#include <stdair/bom/BomIterator.hpp>
+// RMOL
+#include <rmol/bom/FlightDateTypes.hpp>
+#include <rmol/bom/SegmentDateTypes.hpp>
+#include <rmol/bom/LegDateTypes.hpp>
+
+// Forward declarations
+namespace stdair {
+ class FacBomContent;
+ class BomStructure;
+}
+
+namespace RMOL {
+
+ // Forward declarations
+ class Inventory;
+
+ /** Class representing the actual functional/business content for a
+ flight-date. */
+ class FlightDate : public stdair::BomContent {
+ friend class stdair::FacBomContent;
+
+ public:
+ // Type definitions
+ // /////////////////////////////////////////////////////////////////////////
+ // See the explanations, within the stdair::BomContentRoot class, for all
+ // the types which require to be specified below
+ // /////////////////////////////////////////////////////////////////////////
+ /** Definition allowing to retrieve the associated parent
+ BOM content type. */
+ typedef Inventory ParentBomContent_T;
+
+ /** Definition allowing to retrieve the associated BOM structure type. */
+ typedef FlightDateStructure_T BomStructure_T;
+
+ /** Definition allowing to retrieve the associated BOM key type. */
+ typedef FlightDateKey_T BomKey_T;
+
+ /** Definition allowing to retrieve the associated
+ BOM content child type. */
+ typedef SegmentDate ContentChild_T;
+
+ /** Definition allowing to retrieve the associated second
+ BOM content child type. */
+ typedef LegDate SecondContentChild_T;
+
+ public:
+ // /////////////////////////////////////////////////////////////////////////
+ // See the explanations, within the stdair::BomContentRoot class, for all
+ // the iterator types specified below
+ // /////////////////////////////////////////////////////////////////////////
+ /** Define the segment-date list iterators. */
+ typedef stdair::BomConstIterator_T<SegmentDate,
+ SegmentDateStructureList_T::const_iterator> segment_date_list_const_iterator;
+ typedef stdair::BomConstIterator_T<SegmentDate,
+ SegmentDateStructureList_T::const_reverse_iterator> segment_date_list_const_reverse_iterator;
+ typedef stdair::BomIterator_T<SegmentDate,
+ SegmentDateStructureList_T::const_iterator> segment_date_list_iterator;
+ typedef stdair::BomIterator_T<SegmentDate,
+ SegmentDateStructureList_T::const_reverse_iterator> segment_date_list_reverse_iterator;
+
+ /** Define the segment-date map iterators. */
+ typedef stdair::BomConstIterator_T<SegmentDate,
+ SegmentDateStructureMap_T::const_iterator> segment_date_map_const_iterator;
+ typedef stdair::BomConstIterator_T<SegmentDate,
+ SegmentDateStructureMap_T::const_reverse_iterator> segment_date_map_const_reverse_iterator;
+ typedef stdair::BomIterator_T<SegmentDate,
+ SegmentDateStructureMap_T::const_iterator> segment_date_map_iterator;
+ typedef stdair::BomIterator_T<SegmentDate,
+ SegmentDateStructureMap_T::const_reverse_iterator> segment_date_map_reverse_iterator;
+
+ /** Define the leg-date list iterators. */
+ typedef stdair::BomConstIterator_T<LegDate,
+ LegDateStructureList_T::const_iterator> leg_date_list_const_iterator;
+ typedef stdair::BomConstIterator_T<LegDate,
+ LegDateStructureList_T::const_reverse_iterator> leg_date_list_const_reverse_iterator;
+ typedef stdair::BomIterator_T<LegDate,
+ LegDateStructureList_T::const_iterator> leg_date_list_iterator;
+ typedef stdair::BomIterator_T<LegDate,
+ LegDateStructureList_T::const_reverse_iterator> leg_date_list_reverse_iterator;
+
+ /** Define the leg-date map iterators. */
+ typedef stdair::BomConstIterator_T<LegDate,
+ LegDateStructureMap_T::const_iterator> leg_date_map_const_iterator;
+ typedef stdair::BomConstIterator_T<LegDate,
+ LegDateStructureMap_T::const_reverse_iterator> leg_date_map_const_reverse_iterator;
+ typedef stdair::BomIterator_T<LegDate,
+ LegDateStructureMap_T::const_iterator> leg_date_map_iterator;
+ typedef stdair::BomIterator_T<LegDate,
+ LegDateStructureMap_T::const_reverse_iterator> leg_date_map_reverse_iterator;
+ // /////////////////////////////////////////////////////////////////////////
+
+ public:
+ // /////////// Display support methods /////////
+ /** Dump a Business Object into an output stream.
+ @param ostream& the output stream. */
+ void toStream (std::ostream& ioOut) const;
+
+ /** Read a Business Object from an input stream.
+ @param istream& the input stream. */
+ void fromStream (std::istream& ioIn);
+
+ /** Get the serialised version of the Business Object. */
+ std::string toString() const;
+
+ /** Get a string describing the whole key (differentiating two objects
+ at any level). */
+ const std::string describeKey() const;
+
+ /** Get a string describing the short key (differentiating two objects
+ at the same level). */
+ const std::string describeShortKey() const;
+
+ private:
+ /** Retrieve the BOM structure object. */
+ BomStructure_T& getBomStructure () {
+ return _flightDateStructure;
+ }
+
+ public:
+ // /////////// Iteration methods //////////
+ /** Initialise the internal const iterator on segment date:
+ return the const iterator at the begining of the list. */
+ segment_date_list_const_iterator segmentDateListConstIteratorBegin () const;
+
+ /** Initialise the internal const iterator on segment date:
+ return the const iterator at the end of the list. */
+ segment_date_list_const_iterator segmentDateListConstIteratorEnd () const;
+
+ /** Initialise the internal const reverse iterator on segment date:
+ return the const reverse iterator at the rbegining of the list. */
+ segment_date_list_const_reverse_iterator segmentDateListConstIteratorRBegin () const;
+
+ /** Initialise the internal const reverse iterator on segment date:
+ return the const reverse iterator at the end of the list. */
+ segment_date_list_const_reverse_iterator segmentDateListConstIteratorREnd () const;
+
+ /** Initialise the internal iterator on segment date:
+ return the iterator at the begining of the list. */
+ segment_date_list_iterator segmentDateListIteratorBegin () const;
+
+ /** Initialise the internal iterator on segment date:
+ return the iterator at the end of the list. */
+ segment_date_list_iterator segmentDateListIteratorEnd () const;
+
+ /** Initialise the internal reverse iterator on segment date:
+ return the reverse iterator at the rbegining of the list. */
+ segment_date_list_reverse_iterator segmentDateListIteratorRBegin () const;
+
+ /** Initialise the internal reverse iterator on segment date:
+ return the reverse iterator at the end of the list. */
+ segment_date_list_reverse_iterator segmentDateListIteratorREnd () const;
+
+ /** Initialise the internal const iterator on segment date:
+ return the const iterator at the begining of the map. */
+ segment_date_map_const_iterator segmentDateMapConstIteratorBegin () const;
+
+ /** Initialise the internal const iterators on segment date:
+ return the const iterator at the end of the map. */
+ segment_date_map_const_iterator segmentDateMapConstIteratorEnd () const;
+
+ /** Initialise the internal const reverse iterator on segment date:
+ return the const reverse iterator at the rbegining of the map. */
+ segment_date_map_const_reverse_iterator segmentDateMapConstIteratorRBegin () const;
+
+ /** Initialise the internal const reverse iterator on segment date:
+ return the const reverse iterator at the end of the map. */
+ segment_date_map_const_reverse_iterator segmentDateMapConstIteratorREnd () const;
+
+ /** Initialise the internal iterator on segment date:
+ return the iterator at the begining of the map. */
+ segment_date_map_iterator segmentDateMapIteratorBegin () const;
+
+ /** Initialise the internal iterator on segment date:
+ return the iterator at the end of the map. */
+ segment_date_map_iterator segmentDateMapIteratorEnd () const;
+
+ /** Initialise the internal reverse iterator on segment date:
+ return the reverse iterator at the rbegining of the map. */
+ segment_date_map_reverse_iterator segmentDateMapIteratorRBegin () const;
+
+ /** Initialise the internal reverse iterator on segment date:
+ return the reverse iterator at the end of the map. */
+ segment_date_map_reverse_iterator segmentDateMapIteratorREnd () const;
+
+ /** Initialise the internal const iterator on leg date:
+ return the const iterator at the begining of the list. */
+ leg_date_list_const_iterator legDateListConstIteratorBegin () const;
+
+ /** Initialise the internal const iterator on leg date:
+ return the const iterator at the end of the list. */
+ leg_date_list_const_iterator legDateListConstIteratorEnd () const;
+
+ /** Initialise the internal const reverse iterator on leg date:
+ return the const reverse iterator at the rbegining of the list. */
+ leg_date_list_const_reverse_iterator legDateListConstIteratorRBegin () const;
+
+ /** Initialise the internal const reverse iterator on leg date:
+ return the const reverse iterator at the end of the list. */
+ leg_date_list_const_reverse_iterator legDateListConstIteratorREnd () const;
+
+ /** Initialise the internal iterator on leg date:
+ return the iterator at the begining of the list. */
+ leg_date_list_iterator legDateListIteratorBegin () const;
+
+ /** Initialise the internal iterator on leg date:
+ return the iterator at the end of the list. */
+ leg_date_list_iterator legDateListIteratorEnd () const;
+
+ /** Initialise the internal reverse iterator on leg date:
+ return the reverse iterator at the rbegining of the list. */
+ leg_date_list_reverse_iterator legDateListIteratorRBegin () const;
+
+ /** Initialise the internal reverse iterator on leg date:
+ return the reverse iterator at the end of the list. */
+ leg_date_list_reverse_iterator legDateListIteratorREnd () const;
+
+ /** Initialise the internal const iterator on leg date:
+ return the const iterator at the begining of the map. */
+ leg_date_map_const_iterator legDateMapConstIteratorBegin () const;
+
+ /** Initialise the internal const iterators on leg date:
+ return the const iterator at the end of the map. */
+ leg_date_map_const_iterator legDateMapConstIteratorEnd () const;
+
+ /** Initialise the internal const reverse iterator on leg date:
+ return the const reverse iterator at the rbegining of the map. */
+ leg_date_map_const_reverse_iterator legDateMapConstIteratorRBegin () const;
+
+ /** Initialise the internal const reverse iterator on leg date:
+ return the const reverse iterator at the end of the map. */
+ leg_date_map_const_reverse_iterator legDateMapConstIteratorREnd () const;
+
+ /** Initialise the internal iterator on leg date:
+ return the iterator at the begining of the map. */
+ leg_date_map_iterator legDateMapIteratorBegin () const;
+
+ /** Initialise the internal iterator on leg date:
+ return the iterator at the end of the map. */
+ leg_date_map_iterator legDateMapIteratorEnd () const;
+
+ /** Initialise the internal reverse iterator on leg date:
+ return the reverse iterator at the rbegining of the map. */
+ leg_date_map_reverse_iterator legDateMapIteratorRBegin () const;
+
+ /** Initialise the internal reverse iterator on leg date:
+ return the reverse iterator at the end of the map. */
+ leg_date_map_reverse_iterator legDateMapIteratorREnd () const;
+
+ private:
+ /** Constructors are private so as to force the usage of the Factory
+ layer. */
+ /** Default constructors. */
+ FlightDate ();
+ FlightDate (const FlightDate&);
+ FlightDate (BomStructure_T&);
+
+ /** Destructor. */
+ virtual ~FlightDate();
+
+ private:
+ // Attributes
+ /** Reference structure. */
+ BomStructure_T& _flightDateStructure;
+ };
+
+}
+#endif // __RMOL_BOM_FLIGHTDATE_HPP
+
Added: trunk/rmol/rmol/bom/FlightDateTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/FlightDateTypes.hpp (rev 0)
+++ trunk/rmol/rmol/bom/FlightDateTypes.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,34 @@
+// //////////////////////////////////////////////////////////////////////
+#ifndef __RMOL_BOM_FLIGHTDATETYPES_HPP
+#define __RMOL_BOM_FLIGHTDATETYPES_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+
+// Forward declarations.
+namespace stdair {
+ template <typename BOM_CONTENT> class FlightDate;
+ template <typename BOM_CONTENT> class FlightDateKey;
+}
+
+namespace RMOL {
+
+ // Forward declarations.
+ class FlightDate;
+
+ /** Define the FlightDate structure. */
+ typedef stdair::FlightDate<FlightDate> FlightDateStructure_T;
+
+ /** Define the FlightDate key. */
+ typedef stdair::FlightDateKey<FlightDate> FlightDateKey_T;
+
+ /** Define the flight-date structure list. */
+ typedef std::vector<FlightDateStructure_T*> FlightDateStructureList_T;
+
+ /** Define the flight-date structure map. */
+ typedef std::map<const std::string, FlightDateStructure_T*> FlightDateStructureMap_T;
+
+}
+#endif // __RMOL_BOM_FLIGHTDATETYPES_HPP
+
Added: trunk/rmol/rmol/bom/Inventory.cpp
===================================================================
--- trunk/rmol/rmol/bom/Inventory.cpp (rev 0)
+++ trunk/rmol/rmol/bom/Inventory.cpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,147 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STL
+#include <cassert>
+// STDAIR
+#include <stdair/bom/Inventory.hpp>
+// RMOL
+#include <rmol/bom/Inventory.hpp>
+#include <rmol/bom/FlightDate.hpp>
+#include <rmol/bom/SegmentDate.hpp>
+#include <rmol/bom/LegDate.hpp>
+#include <rmol/service/Logger.hpp>
+
+namespace RMOL {
+
+ // ////////////////////////////////////////////////////////////////////
+ Inventory::Inventory (BomStructure_T& ioInventoryStructure)
+ : _inventoryStructure (ioInventoryStructure) {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ Inventory::~Inventory () {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void Inventory::toStream (std::ostream& ioOut) const {
+ ioOut << toString() << std::endl;
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void Inventory::fromStream (std::istream& ioIn) {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ std::string Inventory::toString() const {
+ std::ostringstream oStr;
+
+ _inventoryStructure.describeFull (oStr);
+
+ return oStr.str();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string Inventory::describeKey() const {
+ return _inventoryStructure.describeKey();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string Inventory::describeShortKey() const {
+ return _inventoryStructure.describeShortKey();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ list_const_iterator Inventory::flightDateListConstIteratorBegin () const {
+ return _inventoryStructure.flightDateListConstIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ list_const_iterator Inventory::flightDateListConstIteratorEnd () const {
+ return _inventoryStructure.flightDateListConstIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::list_const_reverse_iterator Inventory::flightDateListConstIteratorRBegin () const {
+ return _inventoryStructure.flightDateListConstIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::list_const_reverse_iterator Inventory::flightDateListConstIteratorREnd () const {
+ return _inventoryStructure.flightDateListConstIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ list_iterator Inventory::flightDateListIteratorBegin () const {
+ return _inventoryStructure.flightDateListIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ list_iterator Inventory::flightDateListIteratorEnd () const {
+ return _inventoryStructure.flightDateListIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ list_reverse_iterator Inventory::flightDateListIteratorRBegin () const {
+ return _inventoryStructure.flightDateListIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ list_reverse_iterator Inventory::flightDateListIteratorREnd () const {
+ return _inventoryStructure.flightDateListIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ map_const_iterator Inventory::flightDateMapConstIteratorBegin () const {
+ return _inventoryStructure.flightDateMapConstIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ map_const_iterator Inventory::flightDateMapConstIteratorEnd () const {
+ return _inventoryStructure.flightDateMapConstIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::map_const_reverse_iterator Inventory::flightDateMapConstIteratorRBegin () const {
+ return _inventoryStructure.flightDateMapConstIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::map_const_reverse_iterator Inventory::flightDateMapConstIteratorREnd () const {
+ return _inventoryStructure.flightDateMapConstIteratorREnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ map_iterator Inventory::flightDateMapIteratorBegin () const {
+ return _inventoryStructure.flightDateMapIteratorBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ map_iterator Inventory::flightDateMapIteratorEnd () const {
+ return _inventoryStructure.flightDateMapIteratorEnd ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ map_reverse_iterator Inventory::flightDateMapIteratorRBegin () const {
+ return _inventoryStructure.flightDateMapIteratorRBegin ();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ Inventory::
+ map_reverse_iterator Inventory::flightDateMapIteratorREnd () const {
+ return _inventoryStructure.flightDateMapIteratorREnd ();
+ }
+
+}
+
Added: trunk/rmol/rmol/bom/Inventory.hpp
===================================================================
--- trunk/rmol/rmol/bom/Inventory.hpp (rev 0)
+++ trunk/rmol/rmol/bom/Inventory.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,191 @@
+#ifndef __RMOL_BOM_INVENTORY_HPP
+#define __RMOL_BOM_INVENTORY_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STDAIR
+#include <stdair/bom/BomContent.hpp>
+#include <stdair/bom/BomContentRoot.hpp>
+#include <stdair/bom/BomIterator.hpp>
+// RMOL
+#include <rmol/bom/BomRootTypes.hpp>
+#include <rmol/bom/InventoryTypes.hpp>
+#include <rmol/bom/FlightDateTypes.hpp>
+
+// Forward declarations
+namespace stdair {
+ class FacBomContent;
+ template <typename BOM_CONTENT, typename ITERATOR> struct BomConstIterator_T;
+}
+
+namespace RMOL {
+
+ // Forward declarations.
+ class FlightDate;
+
+ /** Class representing the actual functional/business content for
+ an airline inventory. */
+ class Inventory : public stdair::BomContent {
+ friend class stdair::FacBomContent;
+
+ public:
+ // /////////////////////////////////////////////////////////////////////////
+ // See the explanations, within the stdair::BomContentRoot class, for all
+ // the types which require to be specified below
+ // /////////////////////////////////////////////////////////////////////////
+ /** Definition allowing to retrieve the associated parent
+ BOM content type. */
+ typedef BomContentRoot_T ParentBomContent_T;
+
+ /** Definition allowing to retrieve the associated BOM structure type. */
+ typedef InventoryStructure_T BomStructure_T;
+
+ /** Definition allowing to retrieve the associated BOM key type. */
+ typedef InventoryKey_T BomKey_T;
+
+ /** Definition allowing to retrieve the associated BOM content child
+ type. */
+ typedef FlightDate ContentChild_T;
+ // /////////////////////////////////////////////////////////////////////////
+
+
+ public:
+ // /////////////////////////////////////////////////////////////////////////
+ // See the explanations, within the stdair::BomContentRoot class, for all
+ // the iterator types specified below
+ // /////////////////////////////////////////////////////////////////////////
+ /** Define the flight-date list iterators. */
+ typedef stdair::BomConstIterator_T<FlightDate,
+ FlightDateStructureList_T::const_iterator> list_const_iterator;
+ typedef stdair::BomConstIterator_T<FlightDate,
+ FlightDateStructureList_T::const_reverse_iterator> list_const_reverse_iterator;
+ typedef stdair::BomIterator_T<FlightDate,
+ FlightDateStructureList_T::const_iterator> list_iterator;
+ typedef stdair::BomIterator_T<FlightDate,
+ FlightDateStructureList_T::const_reverse_iterator> list_reverse_iterator;
+
+ /** Define the flight-date map iterators. */
+ typedef stdair::BomConstIterator_T<FlightDate,
+ FlightDateStructureMap_T::const_iterator> map_const_iterator;
+ typedef stdair::BomConstIterator_T<FlightDate,
+ FlightDateStructureMap_T::const_reverse_iterator> map_const_reverse_iterator;
+ typedef stdair::BomIterator_T<FlightDate,
+ FlightDateStructureMap_T::const_iterator> map_iterator;
+ typedef stdair::BomIterator_T<FlightDate,
+ FlightDateStructureMap_T::const_reverse_iterator> map_reverse_iterator;
+ // /////////////////////////////////////////////////////////////////////////
+
+
+ public:
+ // /////////// Display support methods /////////
+ /** Dump a Business Object into an output stream.
+ @param ostream& the output stream. */
+ void toStream (std::ostream& ioOut) const;
+
+ /** Read a Business Object from an input stream.
+ @param istream& the input stream. */
+ void fromStream (std::istream& ioIn);
+
+ /** Get the serialised version of the Business Object. */
+ std::string toString() const;
+
+ /** Get a string describing the whole key (differentiating two objects
+ at any level). */
+ const std::string describeKey() const;
+
+ /** Get a string describing the short key (differentiating two objects
+ at the same level). */
+ const std::string describeShortKey() const;
+
+ // /////////// Iteration methods //////////
+ /** Initialise the internal const iterator on flight date:
+ return the const iterator at the begining of the list. */
+ list_const_iterator flightDateListConstIteratorBegin () const;
+
+ /** Initialise the internal const iterator on flight date:
+ return the const iterator at the end of the list. */
+ list_const_iterator flightDateListConstIteratorEnd () const;
+
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the rbegining of the list. */
+ list_const_reverse_iterator flightDateListConstIteratorRBegin () const;
+
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the end of the list. */
+ list_const_reverse_iterator flightDateListConstIteratorREnd () const;
+
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the begining of the list. */
+ list_iterator flightDateListIteratorBegin () const;
+
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the end of the list. */
+ list_iterator flightDateListIteratorEnd () const;
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the rbegining of the list. */
+ list_reverse_iterator flightDateListIteratorRBegin () const;
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the end of the list. */
+ list_reverse_iterator flightDateListIteratorREnd () const;
+
+ /** Initialise the internal const iterator on flight date:
+ return the const iterator at the begining of the map. */
+ map_const_iterator flightDateMapConstIteratorBegin () const;
+
+ /** Initialise the internal const iterators on flight date:
+ return the const iterator at the end of the map. */
+ map_const_iterator flightDateMapConstIteratorEnd () const;
+
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the rbegining of the map. */
+ map_const_reverse_iterator flightDateMapConstIteratorRBegin () const;
+
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the end of the map. */
+ map_const_reverse_iterator flightDateMapConstIteratorREnd () const;
+
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the begining of the map. */
+ map_iterator flightDateMapIteratorBegin () const;
+
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the end of the map. */
+ map_iterator flightDateMapIteratorEnd () const;
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the rbegining of the map. */
+ map_reverse_iterator flightDateMapIteratorRBegin () const;
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the end of the map. */
+ map_reverse_iterator flightDateMapIteratorREnd () const;
+
+ private:
+ /** Retrieve the BOM structure object. */
+ BomStructure_T& getBomStructure () {
+ return _inventoryStructure;
+ }
+
+ private:
+ /** Constructors are private so as to force the usage of the Factory
+ layer. */
+ /** Default constructors. */
+ Inventory ();
+ Inventory (const Inventory&);
+ Inventory (BomStructure_T&);
+
+ /** Destructor. */
+ virtual ~Inventory();
+
+ private:
+ // Attributes
+ /** Reference structure. */
+ BomStructure_T& _inventoryStructure;
+ };
+
+}
+#endif // __RMOL_BOM_INVENTORY_HPP
+
Added: trunk/rmol/rmol/bom/InventoryTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/InventoryTypes.hpp (rev 0)
+++ trunk/rmol/rmol/bom/InventoryTypes.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,34 @@
+// //////////////////////////////////////////////////////////////////////
+#ifndef __RMOL_BOM_INVENTORYTYPES_HPP
+#define __RMOL_BOM_INVENTORYTYPES_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+
+// Forward declarations.
+namespace stdair {
+ template <typename BOM_CONTENT> class Inventory;
+ template <typename BOM_CONTENT> class InventoryKey;
+}
+
+namespace RMOL {
+
+ // Forward declarations.
+ class Inventory;
+
+ /** Define the Inventory structure. */
+ typedef stdair::Inventory<Inventory> InventoryStructure_T;
+
+ /** Define the Inventory key. */
+ typedef stdair::InventoryKey<Inventory> InventoryKey_T;
+
+ /** Define the flight-date structure list. */
+ typedef std::vector<InventoryStructure_T*> InventoryStructureList_T;
+
+ /** Define the flight-date structure map. */
+ typedef std::map<const std::string, InventoryStructure_T*> InventoryStructureMap_T;
+
+}
+#endif // __RMOL_BOM_INVENTORYTYPES_HPP
+
Added: trunk/rmol/rmol/bom/LegDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/LegDate.cpp (rev 0)
+++ trunk/rmol/rmol/bom/LegDate.cpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,56 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// C
+#include <cassert>
+// STDAIR
+#include <stdair/bom/LegDate.hpp>
+// RMOL
+#include <rmol/bom/FlightDate.hpp>
+#include <rmol/bom/LegDate.hpp>
+
+namespace RMOL {
+
+ // ////////////////////////////////////////////////////////////////////
+ LegDate::LegDate (BomStructure_T& ioLegStructure)
+ : _legDateStructure (ioLegStructure) {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ LegDate::~LegDate () {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void LegDate::toStream (std::ostream& ioOut) const {
+ ioOut << toString() << std::endl;
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void LegDate::fromStream (std::istream& ioIn) {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ std::string LegDate::toString() const {
+ std::ostringstream oStr;
+
+ // First, put the key of that level
+ oStr << describeShortKey() << std::endl;
+
+ // Then, browse the children
+ // [...] (no child for now)
+
+ return oStr.str();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string LegDate::describeKey() const {
+ return _legDateStructure.describeKey();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string LegDate::describeShortKey() const {
+ return _legDateStructure.describeShortKey();
+ }
+
+}
+
Added: trunk/rmol/rmol/bom/LegDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/LegDate.hpp (rev 0)
+++ trunk/rmol/rmol/bom/LegDate.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,86 @@
+#ifndef __RMOL_BOM_LEGDATE_HPP
+#define __RMOL_BOM_LEGDATE_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STDAIR
+#include <stdair/bom/BomContent.hpp>
+// RMOL
+#include <rmol/bom/LegDateTypes.hpp>
+
+// Forward declarations
+namespace stdair {
+ class FacBomContent;
+}
+
+namespace RMOL {
+
+ // Forward declarations
+ class FlightDate;
+
+ /** Class representing the actual functional/business content for a
+ leg-date. */
+ class LegDate : public stdair::BomContent {
+ friend class stdair::FacBomContent;
+
+ public:
+ // Type definitions
+ /** Definition allowing to retrieve the associated parent
+ BOM content type. */
+ typedef FlightDate ParentBomContent_T;
+
+ /** Definition allowing to retrieve the associated BOM structure type. */
+ typedef LegDateStructure_T BomStructure_T;
+
+ /** Definition allowing to retrieve the associated BOM key type. */
+ typedef LegDateKey_T BomKey_T;
+
+ public:
+
+ // /////////// Display support methods /////////
+ /** Dump a Business Object into an output stream.
+ @param ostream& the output stream. */
+ void toStream (std::ostream& ioOut) const;
+
+ /** Read a Business Object from an input stream.
+ @param istream& the input stream. */
+ void fromStream (std::istream& ioIn);
+
+ /** Get the serialised version of the Business Object. */
+ std::string toString() const;
+
+ /** Get a string describing the whole key (differentiating two objects
+ at any level). */
+ const std::string describeKey() const;
+
+ /** Get a string describing the short key (differentiating two objects
+ at the same level). */
+ const std::string describeShortKey() const;
+
+ private:
+ /** Retrieve the BOM structure object. */
+ BomStructure_T& getBomStructure () {
+ return _legDateStructure;
+ }
+
+ private:
+ /** Constructors are private so as to force the usage of the Factory
+ layer. */
+ /** Default constructors. */
+ LegDate ();
+ LegDate (const LegDate&);
+ LegDate (BomStructure_T&);
+
+ /** Destructor. */
+ virtual ~LegDate();
+
+ private:
+ // Attributes
+ /** Reference structure. */
+ BomStructure_T& _legDateStructure;
+ };
+
+}
+#endif // __RMOL_BOM_LEGDATE_HPP
+
Added: trunk/rmol/rmol/bom/LegDateTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/LegDateTypes.hpp (rev 0)
+++ trunk/rmol/rmol/bom/LegDateTypes.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,34 @@
+// //////////////////////////////////////////////////////////////////////
+#ifndef __RMOL_BOM_LEGDATETYPES_HPP
+#define __RMOL_BOM_LEGDATETYPES_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+
+// Forward declarations.
+namespace stdair {
+ template <typename BOM_CONTENT> class LegDate;
+ template <typename BOM_CONTENT> class LegDateKey;
+}
+
+namespace RMOL {
+
+ // Forward declarations.
+ class LegDate;
+
+ /** Define the LegDate structure. */
+ typedef stdair::LegDate<LegDate> LegDateStructure_T;
+
+ /** Define the LegDate key. */
+ typedef stdair::LegDateKey<LegDate> LegDateKey_T;
+
+ /** Define the leg-date structure list. */
+ typedef std::vector<LegDateStructure_T*> LegDateStructureList_T;
+
+ /** Define the leg-date structure map. */
+ typedef std::map<const std::string, LegDateStructure_T*> LegDateStructureMap_T;
+
+}
+#endif // __RMOL_BOM_LEGDATETYPES_HPP
+
Added: trunk/rmol/rmol/bom/SegmentDate.cpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.cpp (rev 0)
+++ trunk/rmol/rmol/bom/SegmentDate.cpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,56 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// C
+#include <cassert>
+// STDAIR
+#include <stdair/bom/SegmentDate.hpp>
+// RMOL
+#include <rmol/bom/FlightDate.hpp>
+#include <rmol/bom/SegmentDate.hpp>
+
+namespace RMOL {
+
+ // ////////////////////////////////////////////////////////////////////
+ SegmentDate::SegmentDate (BomStructure_T& ioSegmentStructure)
+ : _segmentDateStructure (ioSegmentStructure) {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ SegmentDate::~SegmentDate () {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void SegmentDate::toStream (std::ostream& ioOut) const {
+ ioOut << toString() << std::endl;
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void SegmentDate::fromStream (std::istream& ioIn) {
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ std::string SegmentDate::toString() const {
+ std::ostringstream oStr;
+
+ // First, put the key of that level
+ oStr << describeShortKey() << std::endl;
+
+ // Then, browse the children
+ // [...] (no child for now)
+
+ return oStr.str();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string SegmentDate::describeKey() const {
+ return _segmentDateStructure.describeKey();
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ const std::string SegmentDate::describeShortKey() const {
+ return _segmentDateStructure.describeShortKey();
+ }
+
+}
+
Added: trunk/rmol/rmol/bom/SegmentDate.hpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDate.hpp (rev 0)
+++ trunk/rmol/rmol/bom/SegmentDate.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,86 @@
+#ifndef __RMOL_BOM_SEGMENTDATE_HPP
+#define __RMOL_BOM_SEGMENTDATE_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STDAIR
+#include <stdair/bom/BomContent.hpp>
+// RMOL
+#include <rmol/bom/SegmentDateTypes.hpp>
+
+// Forward declarations
+namespace stdair {
+ class FacBomContent;
+}
+
+namespace RMOL {
+
+ // Forward declarations
+ class FlightDate;
+
+ /** Class representing the actual functional/business content for a
+ segment-date. */
+ class SegmentDate : public stdair::BomContent {
+ friend class stdair::FacBomContent;
+
+ public:
+ // Type definitions
+ /** Definition allowing to retrieve the associated parent
+ BOM content type. */
+ typedef FlightDate ParentBomContent_T;
+
+ /** Definition allowing to retrieve the associated BOM structure type. */
+ typedef SegmentDateStructure_T BomStructure_T;
+
+ /** Definition allowing to retrieve the associated BOM key type. */
+ typedef SegmentDateKey_T BomKey_T;
+
+ public:
+
+ // /////////// Display support methods /////////
+ /** Dump a Business Object into an output stream.
+ @param ostream& the output stream. */
+ void toStream (std::ostream& ioOut) const;
+
+ /** Read a Business Object from an input stream.
+ @param istream& the input stream. */
+ void fromStream (std::istream& ioIn);
+
+ /** Get the serialised version of the Business Object. */
+ std::string toString() const;
+
+ /** Get a string describing the whole key (differentiating two objects
+ at any level). */
+ const std::string describeKey() const;
+
+ /** Get a string describing the short key (differentiating two objects
+ at the same level). */
+ const std::string describeShortKey() const;
+
+ private:
+ /** Retrieve the BOM structure object. */
+ BomStructure_T& getBomStructure () {
+ return _segmentDateStructure;
+ }
+
+ private:
+ /** Constructors are private so as to force the usage of the Factory
+ layer. */
+ /** Default constructors. */
+ SegmentDate ();
+ SegmentDate (const SegmentDate&);
+ SegmentDate (BomStructure_T&);
+
+ /** Destructor. */
+ virtual ~SegmentDate();
+
+ private:
+ // Attributes
+ /** Reference structure. */
+ BomStructure_T& _segmentDateStructure;
+ };
+
+}
+#endif // __RMOL_BOM_SEGMENTDATE_HPP
+
Added: trunk/rmol/rmol/bom/SegmentDateTypes.hpp
===================================================================
--- trunk/rmol/rmol/bom/SegmentDateTypes.hpp (rev 0)
+++ trunk/rmol/rmol/bom/SegmentDateTypes.hpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,34 @@
+// //////////////////////////////////////////////////////////////////////
+#ifndef __RMOL_BOM_SEGMENTDATETYPES_HPP
+#define __RMOL_BOM_SEGMENTDATETYPES_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+
+// Forward declarations.
+namespace stdair {
+ template <typename BOM_CONTENT> class SegmentDate;
+ template <typename BOM_CONTENT> class SegmentDateKey;
+}
+
+namespace RMOL {
+
+ // Forward declarations.
+ class SegmentDate;
+
+ /** Define the SegmentDate structure. */
+ typedef stdair::SegmentDate<SegmentDate> SegmentDateStructure_T;
+
+ /** Define the SegmentDate key. */
+ typedef stdair::SegmentDateKey<SegmentDate> SegmentDateKey_T;
+
+ /** Define the segment-date structure list. */
+ typedef std::vector<SegmentDateStructure_T*> SegmentDateStructureList_T;
+
+ /** Define the segment-date structure map. */
+ typedef std::map<const std::string, SegmentDateStructure_T*> SegmentDateStructureMap_T;
+
+}
+#endif // __RMOL_BOM_SEGMENTDATETYPES_HPP
+
Modified: trunk/rmol/rmol/bom/sources.mk
===================================================================
--- trunk/rmol/rmol/bom/sources.mk 2009-10-06 13:34:21 UTC (rev 268)
+++ trunk/rmol/rmol/bom/sources.mk 2009-10-06 14:22:28 UTC (rev 269)
@@ -23,7 +23,17 @@
$(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \
$(top_srcdir)/rmol/bom/StudyStatManager.hpp \
$(top_srcdir)/rmol/bom/ExpectationMaximization.hpp \
- $(top_srcdir)/rmol/bom/QForecaster.hpp
+ $(top_srcdir)/rmol/bom/QForecaster.hpp \
+ $(top_srcdir)/rmol/bom/BomRootTypes.hpp \
+ $(top_srcdir)/rmol/bom/InventoryTypes.hpp \
+ $(top_srcdir)/rmol/bom/Inventory.hpp \
+ $(top_srcdir)/rmol/bom/FlightDateTypes.hpp \
+ $(top_srcdir)/rmol/bom/FlightDate.hpp \
+ $(top_srcdir)/rmol/bom/LegDateTypes.hpp \
+ $(top_srcdir)/rmol/bom/LegDate.hpp \
+ $(top_srcdir)/rmol/bom/SegmentDateTypes.hpp \
+ $(top_srcdir)/rmol/bom/SegmentDate.hpp
+
bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \
$(top_srcdir)/rmol/bom/Bucket.cpp \
$(top_srcdir)/rmol/bom/BucketHolder.cpp \
@@ -42,4 +52,8 @@
$(top_srcdir)/rmol/bom/StatAggregatorStruct.cpp \
$(top_srcdir)/rmol/bom/StudyStatManager.cpp \
$(top_srcdir)/rmol/bom/ExpectationMaximization.cpp \
- $(top_srcdir)/rmol/bom/QForecaster.cpp
+ $(top_srcdir)/rmol/bom/QForecaster.cpp \
+ $(top_srcdir)/rmol/bom/Inventory.cpp \
+ $(top_srcdir)/rmol/bom/FlightDate.cpp \
+ $(top_srcdir)/rmol/bom/LegDate.cpp \
+ $(top_srcdir)/rmol/bom/SegmentDate.cpp
Modified: trunk/rmol/test/Makefile.am
===================================================================
--- trunk/rmol/test/Makefile.am 2009-10-06 13:34:21 UTC (rev 268)
+++ trunk/rmol/test/Makefile.am 2009-10-06 14:22:28 UTC (rev 269)
@@ -4,7 +4,7 @@
MAINTAINERCLEANFILES = Makefile.in
##
-SUBDIRS = com
+SUBDIRS = com stdair
EXTRA_DIST = testLib.sh
##
Property changes on: trunk/rmol/test/stdair
___________________________________________________________________
Added: svn:ignore
+ .deps
.libs
Makefile
Makefile.in
Added: trunk/rmol/test/stdair/Makefile.am
===================================================================
--- trunk/rmol/test/stdair/Makefile.am (rev 0)
+++ trunk/rmol/test/stdair/Makefile.am 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,20 @@
+## test sub-directory
+include $(top_srcdir)/Makefile.common
+
+MAINTAINERCLEANFILES = Makefile.in
+
+##
+SUBDIRS =
+
+EXTRA_DIST =
+##
+
+check_PROGRAMS = stdair
+
+stdair_SOURCES = stdair.cpp
+stdair_CXXFLAGS= $(BOOST_CFLAGS)
+stdair_LDADD =
+stdair_LDFLAGS = $(BOOST_LIBS) \
+ $(top_builddir)/stdair/core/libstdair.la
+ $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la
+
Added: trunk/rmol/test/stdair/stdair.cpp
===================================================================
--- trunk/rmol/test/stdair/stdair.cpp (rev 0)
+++ trunk/rmol/test/stdair/stdair.cpp 2009-10-06 14:22:28 UTC (rev 269)
@@ -0,0 +1,239 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// C
+#include <cassert>
+// STL
+#include <iostream>
+#include <string>
+// STDAIR
+#include <stdair/bom/BomStructureRoot.hpp>
+#include <stdair/bom/BomStructureDummy.hpp>
+#include <stdair/bom/BomContentDummy.hpp>
+#include <stdair/bom/Inventory.hpp>
+#include <stdair/bom/FlightDate.hpp>
+#include <stdair/bom/LegDate.hpp>
+#include <stdair/bom/SegmentDate.hpp>
+#include <stdair/bom/BomContentRoot.hpp>
+#include <stdair/bom/BomIterator.hpp>
+#include <stdair/factory/FacBomContent.hpp>
+// RMOL
+#include <rmol/bom/Inventory.hpp>
+#include <rmol/bom/FlightDate.hpp>
+#include <rmol/bom/LegDate.hpp>
+#include <rmol/bom/SegmentDate.hpp>
+
+// /////////////////////////////////////////////////////////////////
+#define LOG_DEBUG(iToBeLogged) \
+ { std::cout << __FILE__ << ":" << __LINE__ << ": " << iToBeLogged << std::endl; }
+
+// //////////////////////////////////////////////////////////////////////
+RMOL::Inventory& initialise () {
+ // DEBUG
+ LOG_DEBUG ("Welcome to Air-Schedule");
+
+ // Step 0.0: initialisation
+ // Create the root of the Bom tree (i.e., a BomContentRoot object)
+ RMOL::BomContentRoot_T& lBomContentRoot =
+ stdair::FacBomContent::instance().createBomRoot<RMOL::Inventory>();
+
+
+ // Step 0.1: Inventory level
+ // Create an Inventory (BA)
+ const stdair::AirlineCode_T lAirlineCode ("BA");
+ const RMOL::InventoryKey_T lInventoryKey (lAirlineCode);
+
+ RMOL::Inventory& lInventory =
+ stdair::FacBomContent::instance...
[truncated message content] |
|
From: <den...@us...> - 2009-10-06 13:34:32
|
Revision: 268
http://rmol.svn.sourceforge.net/rmol/?rev=268&view=rev
Author: denis_arnaud
Date: 2009-10-06 13:34:21 +0000 (Tue, 06 Oct 2009)
Log Message:
-----------
[Dev] Added an external reference on the STDAIR library.
Property Changed:
----------------
trunk/rmol/
Property changes on: trunk/rmol
___________________________________________________________________
Added: svn:externals
+ stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-10-05 13:07:08
|
Revision: 267
http://rmol.svn.sourceforge.net/rmol/?rev=267&view=rev
Author: dkchoe
Date: 2009-10-05 13:06:51 +0000 (Mon, 05 Oct 2009)
Log Message:
-----------
Used vector iterators and some code clean-up
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
trunk/rmol/rmol/RMOL_UTILITY_Types.hpp
trunk/rmol/rmol/bom/ExpectationMaximization.cpp
trunk/rmol/rmol/bom/QForecaster.cpp
trunk/rmol/rmol/command/Forecaster.cpp
trunk/rmol/rmol/command/Utilities.cpp
trunk/rmol/rmol/command/Utilities.hpp
Modified: trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-10-02 09:38:34 UTC (rev 266)
+++ trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-10-05 13:06:51 UTC (rev 267)
@@ -32,7 +32,7 @@
typedef std::vector<double> HistoricalDataHolder_T;
/** Define vector of historical data vector*/
- typedef std::vector< std::vector<double> > HistoricalDataHolderHolder_T;
+ typedef std::vector<HistoricalDataHolder_T> HistoricalDataHolderHolder_T;
/** Define a holder for Q-equivalent demand parameters. */
typedef std::vector<double> QEquivalentDemandParameterHolder_T;
Modified: trunk/rmol/rmol/RMOL_UTILITY_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_UTILITY_Types.hpp 2009-10-02 09:38:34 UTC (rev 266)
+++ trunk/rmol/rmol/RMOL_UTILITY_Types.hpp 2009-10-05 13:06:51 UTC (rev 267)
@@ -18,6 +18,7 @@
/** Define a standard deviation type. */
typedef double StandardDeviation_T;
-
+ /** Define a position in a vector. */
+ typedef int PositionInAVector_T;
}
#endif // __RMOL_RMOL_UTILITY_TYPES_HPP
Modified: trunk/rmol/rmol/bom/ExpectationMaximization.cpp
===================================================================
--- trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2009-10-02 09:38:34 UTC (rev 266)
+++ trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2009-10-05 13:06:51 UTC (rev 267)
@@ -40,8 +40,9 @@
Utilities::sumUpElements (lSumOfUnconstrainedData,
iUnconstrainedDataHolder);
lCompleteDataMean = lSumOfUnconstrainedData / NoOfUnconstrainedData;
- Utilities::getSquaredError (lSqErrorOfUnconstrainedData,
- iUnconstrainedDataHolder, lCompleteDataMean);
+ Utilities::updateSquaredError (lSqErrorOfUnconstrainedData,
+ iUnconstrainedDataHolder,
+ lCompleteDataMean);
lCompleteDataSD = sqrt(lSqErrorOfUnconstrainedData /
(NoOfUnconstrainedData-1));
@@ -74,11 +75,12 @@
lEstimatedMean = (lEstimatedMean + lSumOfUnconstrainedData) /
lTotalNumberOfData;
// S.D.
- Utilities::getSquaredError (lSqErrorOfUnconstrainedData,
- iUnconstrainedDataHolder, lEstimatedMean);
- Utilities::getSquaredError (lSqErrorOfConstrainedData,
- lUnconstrainedDataDuringIteration,
- lEstimatedMean);
+ Utilities::updateSquaredError (lSqErrorOfUnconstrainedData,
+ iUnconstrainedDataHolder,
+ lEstimatedMean);
+ Utilities::updateSquaredError (lSqErrorOfConstrainedData,
+ lUnconstrainedDataDuringIteration,
+ lEstimatedMean);
lEstimatedSD = sqrt((lSqErrorOfUnconstrainedData +
lSqErrorOfConstrainedData) / (lTotalNumberOfData-1));
Modified: trunk/rmol/rmol/bom/QForecaster.cpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.cpp 2009-10-02 09:38:34 UTC (rev 266)
+++ trunk/rmol/rmol/bom/QForecaster.cpp 2009-10-05 13:06:51 UTC (rev 267)
@@ -5,11 +5,10 @@
#include <cmath>
#include <algorithm>
#include <numeric>
-#include <iostream>
+#include <sstream>
#include <fstream>
// RMOL
-// #include <rmol/bom/Bucket.hpp>
-// #include <rmol/bom/BucketHolder.hpp>
+#include <rmol/RMOL_UTILITY_Types.hpp>
#include <rmol/bom/QForecaster.hpp>
#include <rmol/command/Utilities.hpp>
#include <rmol/service/Logger.hpp>
@@ -44,7 +43,7 @@
for (unsigned short j = 0; j < iPriceHolder.size(); j++){
const double lYield = iPriceHolder.at(j);
const double probSellup =
- exp(-iSellupFactorHolder.at(j) * (lYield / iQYield - 1));
+ std::exp(-iSellupFactorHolder.at(j) * (lYield / iQYield - 1));
ioSellupProbabilityVector.push_back(probSellup);
}
}
@@ -61,22 +60,27 @@
// 1. Calculate Q-equivalent demand parameters
// Initialize a holder for Q-equivalent Demands
- // std::vector<double> aZeroVector (iSellupProbabilityVector.size(), 0);
- // std::vector<double>& lQEquivalentDemandHolder = aZeroVector;
-
- // Initialize 0 vector with the size of a data holder
+ // 0 vector with the size of a data holder
+ HistoricalDataHolder_T aHistoricalDataHolder =
+ iHistoricalDataHolderHolder.at(0);
QEquivalentDemandHolder_T lQEquivalentDemandHolder
- (iHistoricalDataHolderHolder.at(0).size(), 0);
- for (unsigned int j = 0; j < iHistoricalDataHolderHolder.size(); j++) {
+ (aHistoricalDataHolder.size(), 0);
+ // Index
+ unsigned int j = 0;
+ std::vector<HistoricalDataHolder_T>::iterator itHDHolderHolder;
+ for (itHDHolderHolder = iHistoricalDataHolderHolder.begin();
+ itHDHolderHolder != iHistoricalDataHolderHolder.end();
+ ++itHDHolderHolder, ++j) {
// Retrieve HistoricalDataHolder which are the data of the same product
// over different dates
- HistoricalDataHolder_T lHistoricalDataHolder =
- iHistoricalDataHolderHolder.at(j);
- double lSellupProbability = iSellupProbabilityVector.at(j);
+ HistoricalDataHolder_T lHistoricalDataHolder = *itHDHolderHolder;
+ const SellupProbability_T lSellupProbability =
+ iSellupProbabilityVector.at(j);
+ const double lQDemandRate = static_cast<double> (1/lSellupProbability);
// Apply sellup probability to historical data
Utilities::multiplyAValueToAVector (lHistoricalDataHolder,
- 1/lSellupProbability);
+ lQDemandRate);
oDebugStr << "Q-equivalent demand of a product for each date "
<< Utilities::vectorToString (lHistoricalDataHolder);
@@ -88,7 +92,7 @@
<< Utilities::vectorToString (lQEquivalentDemandHolder);
// 2. Compute Q-equivalent demand mean and standard deviation
- Utilities::getMeanAndStandardDeviation (ioQEquivalentDemandParameterHolder,
+ Utilities::updateMeanAndStandardDeviation (ioQEquivalentDemandParameterHolder,
lQEquivalentDemandHolder);
RMOL_LOG_DEBUG (oDebugStr.str());
}
@@ -99,7 +103,7 @@
QEquivalentDemandParameterHolder_T& iQEquivalentDemandParameterHolder,
SellupProbabilityVector_T& iSellupProbabilityVector) {
- NumberOfProducts_T noOfClasses = iSellupProbabilityVector.size();
+ const NumberOfProducts_T noOfClasses = iSellupProbabilityVector.size();
// Sort sellup probabilities in increasing order and copy into a vector
SellupProbabilityVector_T lSortedSellupProbabilityVector(noOfClasses);
@@ -111,23 +115,29 @@
// Compute the probability to sell-up to class i but not i-1 (class
// with the next higher fare) and copy into a vector
SellupProbabilityVector_T lSellupProbabilityDifferenceVector(noOfClasses);
- adjacent_difference (lSortedSellupProbabilityVector.begin(),
+ std::adjacent_difference (lSortedSellupProbabilityVector.begin(),
lSortedSellupProbabilityVector.end(),
lSellupProbabilityDifferenceVector.begin());
// Partition Q-equivalent demand mean and S.D. into each class
+ unsigned int k = 0;
ioForecastedDemandParameterList.clear();
- for (unsigned int k=0; k < noOfClasses; k++) {
+ SellupProbabilityVector_T::iterator itSellupProbabilityVector;
+ for (itSellupProbabilityVector = iSellupProbabilityVector.begin();
+ itSellupProbabilityVector != iSellupProbabilityVector.end();
+ ++itSellupProbabilityVector, ++k) {
// Locate the current sell-up probability in the sorted one
+ SellupProbability_T sellupProbabilityInUnsortedVector =
+ *itSellupProbabilityVector;
SellupProbabilityVector_T::iterator pos =
std::lower_bound (lSortedSellupProbabilityVector.begin(),
lSortedSellupProbabilityVector.end(),
- iSellupProbabilityVector.at(k));
- const int posOfCurrentSellupProbInSortedVector =
+ sellupProbabilityInUnsortedVector);
+ const PositionInAVector_T posOfCurrentSellupProbInSortedVector =
std::distance(lSortedSellupProbabilityVector.begin(), pos);
// Find the corresponding sell-up probability difference
- SellupProbability_T correspondingSellupProbability =
+ const SellupProbability_T correspondingSellupProbability =
lSellupProbabilityDifferenceVector.at(
posOfCurrentSellupProbInSortedVector);
@@ -137,7 +147,7 @@
ioForecastedDemandParameterList.push_back
(iQEquivalentDemandParameterHolder);
ForecastedDemandParameters_T& lForecastedDemandParameters =
- ioForecastedDemandParameterList.at(k);
+ ioForecastedDemandParameterList.at(k);
Utilities::multiplyAValueToAVector (lForecastedDemandParameters,
correspondingSellupProbability);
}
Modified: trunk/rmol/rmol/command/Forecaster.cpp
===================================================================
--- trunk/rmol/rmol/command/Forecaster.cpp 2009-10-02 09:38:34 UTC (rev 266)
+++ trunk/rmol/rmol/command/Forecaster.cpp 2009-10-05 13:06:51 UTC (rev 267)
@@ -1,16 +1,12 @@
// //////////////////////////////////////////////////////////////////////
// Import section
// //////////////////////////////////////////////////////////////////////
-#include <math.h>
+// STL
+#include <cmath>
#include <string>
-#include <iostream>
+#include <sstream>
#include <fstream>
// RMOL
-// #include <rmol/bom/Bucket.hpp>
-// #include <rmol/bom/BucketHolder.hpp>
-// #include <rmol/bom/HistoricalBooking.hpp>
-// #include <rmol/bom/HistoricalBookingHolder.hpp>
-// #include <rmol/bom/HistoricalBookingHolderHolder.hpp>
#include <rmol/bom/QForecaster.hpp>
#include <rmol/command/Forecaster.hpp>
#include <rmol/command/Utilities.hpp>
@@ -57,15 +53,15 @@
// Debug
std::ostringstream oDebugStr;
oDebugStr << "Prices are "
- << Utilities::vectorToString(iPriceHolder) << "\n"
+ << Utilities::vectorToString(iPriceHolder) << std::endl
<< "Sell up factors are "
- << Utilities::vectorToString(iSellupFactorHolder) << "\n";
+ << Utilities::vectorToString(iSellupFactorHolder) << std::endl;
// Find the class with the lowest yield
double lQYield;
- Utilities::getMinimumElement (lQYield, iPriceHolder);
+ Utilities::updateMinimumElement (lQYield, iPriceHolder);
// Debug
- oDebugStr << "The minimum yield is " << lQYield << "\n";
+ oDebugStr << "The minimum yield is " << lQYield << std::endl;
// Initialize a holder for sell-up probabilities
SellupProbabilityVector_T lSellupProbabilityVector;
@@ -74,7 +70,7 @@
(lSellupProbabilityVector, lQYield, iPriceHolder, iSellupFactorHolder);
// Debug
oDebugStr << "Sell-up Probabilities are "
- << Utilities::vectorToString (lSellupProbabilityVector) << "\n";
+ << Utilities::vectorToString (lSellupProbabilityVector) << std::endl;
// Initialize a holder for Q-equivalent Demand Parameters
QEquivalentDemandParameterHolder_T lQEquivalentDemandParameterHolder;
@@ -85,7 +81,7 @@
// Debug
oDebugStr << "Q-equivalent demand parameters [mean, SD] = "
<< Utilities::vectorToString (lQEquivalentDemandParameterHolder)
- << "\n";
+ << std::endl;
// Calculate Q-equivalent demand distribution parameters and
// partition it to each class/bucket
@@ -93,8 +89,11 @@
(ioForecastedDemandParameterList, lQEquivalentDemandParameterHolder,
lSellupProbabilityVector);
// debug
- for (unsigned int k = 0; k < ioForecastedDemandParameterList.size(); k++) {
- std::vector<double> lMeanAndSDOfAClass = ioForecastedDemandParameterList.at(k);
+ ForecastedDemandParameterList_T::iterator itForecastedDemandParameterList;
+ for (itForecastedDemandParameterList = ioForecastedDemandParameterList.begin();
+ itForecastedDemandParameterList != ioForecastedDemandParameterList.end();
+ ++itForecastedDemandParameterList) {
+ std::vector<double> lMeanAndSDOfAClass = *itForecastedDemandParameterList;
oDebugStr << "Q-equivalent distribution parameters per class "
<< Utilities::vectorToString (lMeanAndSDOfAClass);
}
Modified: trunk/rmol/rmol/command/Utilities.cpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.cpp 2009-10-02 09:38:34 UTC (rev 266)
+++ trunk/rmol/rmol/command/Utilities.cpp 2009-10-05 13:06:51 UTC (rev 267)
@@ -7,8 +7,8 @@
#include <string>
#include <sstream>
#include <numeric>
-#include <math.h>
-#include <assert.h>
+#include <cmath>
+#include <cassert>
#include <functional>
// RMOL
#include <rmol/command/Utilities.hpp>
@@ -16,7 +16,7 @@
namespace RMOL {
// /////////////////////////////////////////////////////////////////////
- void Utilities::getMinimumElement (double& oMinValue,
+ void Utilities::updateMinimumElement (double& oMinValue,
std::vector<double>& iVector) {
assert(!iVector.empty());
@@ -37,7 +37,7 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::getMean (double& oMean, std::vector<double>& iVector) {
+ void Utilities::updateMean (double& oMean, std::vector<double>& iVector) {
assert(!iVector.empty());
double lSum = std::accumulate(iVector.begin(), iVector.end(),0);
oMean = lSum/iVector.size();
@@ -45,25 +45,31 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::getSquaredError (double& oSquaredError,
+ void Utilities::updateSquaredError (double& oSquaredError,
std::vector<double>& iVector,
double& iMean) {
- if (iMean < 0) {RMOL_LOG_ERROR ("Negative mean is not expected.");}
- else {
+ if (iMean < 0) {
+ RMOL_LOG_ERROR ("Negative mean is not expected.");
+
+ } else {
const unsigned int lSize = iVector.size();
+
if (lSize > 0) {
oSquaredError = 0.0;
+
for (unsigned int j = 0; j < lSize; j++) {
const double lError = iVector.at(j) - iMean;
oSquaredError += lError * lError;
}
- }
- else {RMOL_LOG_ERROR ("No value to compute the squared error");}
+
+ } else {
+ RMOL_LOG_ERROR ("No value to compute the squared error");
+ }
}
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::getStandardDeviation (double& oSD,
+ void Utilities::updateStandardDeviation (double& oSD,
std::vector<double>& iVector,
double& iMean) {
assert(iMean > 0);
@@ -81,7 +87,8 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::getMeanAndStandardDeviation (std::vector<double>& ioMean_SD,
+ void Utilities::updateMeanAndStandardDeviation
+ (std::vector<double>& ioMean_SD,
std::vector<double>& iVector) {
const unsigned int lSize = iVector.size();
assert(lSize > 0);
Modified: trunk/rmol/rmol/command/Utilities.hpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.hpp 2009-10-02 09:38:34 UTC (rev 266)
+++ trunk/rmol/rmol/command/Utilities.hpp 2009-10-05 13:06:51 UTC (rev 267)
@@ -12,27 +12,28 @@
struct Utilities {
/** Returns the minimum element of a given vector*/
- static void getMinimumElement (double& oMinValue, std::vector<double>&);
+ static void updateMinimumElement (double& oMinValue,
+ std::vector<double>&);
/** Return the sum of all elements of a given vector*/
static void sumUpElements (double& oSum, std::vector<double>&);
/** Return mean for the given elements of a vector. */
- static void getMean (double& oMean, std::vector<double>&);
+ static void updateMean (double& oMean, std::vector<double>&);
/** Return squared error. */
- static void getSquaredError (double& oSquaredError,
- std::vector<double>&,
- double& iMean);
+ static void updateSquaredError (double& oSquaredError,
+ std::vector<double>&,
+ double& iMean);
/** Return standard deviation for the given elements of a vector and
precomputed mean. */
- static void getStandardDeviation (double& oSD, std::vector<double>&,
- double& iMean);
+ static void updateStandardDeviation (double& oSD, std::vector<double>&,
+ double& iMean);
/** Return mean & standard deviation for given elements of a vector. */
- static void getMeanAndStandardDeviation (std::vector<double>& ioMean_SD,
- std::vector<double>&);
+ static void updateMeanAndStandardDeviation (std::vector<double>& ioMean_SD,
+ std::vector<double>&);
/** Return the input vector after adding a value. */
static void addAValueToAVector (std::vector<double>& ioVector,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-10-02 09:38:41
|
Revision: 266
http://rmol.svn.sourceforge.net/rmol/?rev=266&view=rev
Author: dkchoe
Date: 2009-10-02 09:38:34 +0000 (Fri, 02 Oct 2009)
Log Message:
-----------
Added CPPUNIT test for Unconstraining method usign EM algorithm.
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_Service.hpp
trunk/rmol/rmol/bom/ExpectationMaximization.cpp
trunk/rmol/rmol/command/Unconstrainer.cpp
trunk/rmol/rmol/command/Unconstrainer.hpp
trunk/rmol/rmol/command/Utilities.cpp
trunk/rmol/rmol/service/RMOL_Service.cpp
trunk/rmol/test/ForecasterTestSuite.cpp
trunk/rmol/test/Makefile.am
Added Paths:
-----------
trunk/rmol/test/UnconstrainerTestSuite.cpp
trunk/rmol/test/UnconstrainerTestSuite.hpp
Property Changed:
----------------
trunk/rmol/test/
Modified: trunk/rmol/rmol/RMOL_Service.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Service.hpp 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/rmol/RMOL_Service.hpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -9,6 +9,8 @@
// RMOL
#include <rmol/RMOL_Types.hpp>
#include <rmol/RMOL_FORECASTER_Types.hpp>
+#include <rmol/RMOL_UNCONSTRAINER_Types.hpp>
+#include <rmol/RMOL_UTILITY_Types.hpp>
namespace RMOL {
@@ -125,7 +127,10 @@
BookingLimitVector_T&);
/** Data unconstraining by Expectation Maximization */
- void dataUnconstrainingByExpectationMaximization ();
+ void dataUnconstrainingByExpectationMaximization
+ (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ UnconstrainedDataHolder_T& iUnconstrainedDataHolder,
+ StoppingCriterion_T& iStoppingCriterion);
/** Demand forecast using Q-Forecasting */
void demandForecastByQForecasting (ForecastedDemandParameterList_T&,
Modified: trunk/rmol/rmol/bom/ExpectationMaximization.cpp
===================================================================
--- trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -10,6 +10,7 @@
#include <rmol/basic/BasConst_General.hpp>
#include <rmol/command/Utilities.hpp>
#include <rmol/bom/ExpectationMaximization.hpp>
+#include <rmol/service/Logger.hpp>
namespace RMOL {
@@ -46,13 +47,13 @@
// If there are constrained data
if (NoOfConstrainededData > 0) {
- double lEstimatedMean, lEstimatedSD, lSqErrorOfConstrainedData =
- DEFAULT_INITIALIZER_DOUBLE_NEGATIVE;
+ double lEstimatedMean, lEstimatedSD;
+ double lSqErrorOfConstrainedData = DEFAULT_INITIALIZER_DOUBLE_NEGATIVE;
// A holder for unconstrained results at each iteration
UnconstrainedDataHolder_T lUnconstrainedDataDuringIteration;
do {
- if (lEstimatedMean != DEFAULT_INITIALIZER_DOUBLE_NEGATIVE) {
+ if (lSqErrorOfConstrainedData != DEFAULT_INITIALIZER_DOUBLE_NEGATIVE) {
lCompleteDataMean = lEstimatedMean;
lCompleteDataSD = lEstimatedSD;
}
@@ -62,6 +63,10 @@
(lUnconstrainedDataDuringIteration, ioConstrainedDataHolder,
lCompleteDataMean, lCompleteDataSD);
+ // Debug
+ RMOL_LOG_DEBUG ("\nUnconstrained data: "
+ << Utilities::vectorToString
+ (lUnconstrainedDataDuringIteration));
// Maximization step
// Mean
Utilities::sumUpElements (lEstimatedMean,
@@ -77,7 +82,12 @@
lEstimatedSD = sqrt((lSqErrorOfUnconstrainedData +
lSqErrorOfConstrainedData) / (lTotalNumberOfData-1));
- } while(fabs(lCompleteDataMean - lEstimatedMean ) > iStoppingCriterion);
+ // Debug
+ RMOL_LOG_DEBUG ("\nEstimated Mean: " << lEstimatedMean
+ << "\nnEstimated s.d.: " << lEstimatedSD);
+
+ } while(fabs(lCompleteDataMean - lEstimatedMean ) > iStoppingCriterion
+ || fabs(lCompleteDataSD - lEstimatedSD ) > iStoppingCriterion);
// Should mean and s.d. of unconstrained data be outputed:
// lCompleteDataMean = lEstimatedMean; lCompleteDataSD = lEstimatedSD;
@@ -100,7 +110,9 @@
(UnconstrainedDataHolder_T& ioUnconstrainedDataHolder,
ConstrainedDataHolder_T& iConstrainedDataHolder,
Mean_T& iMean, StandardDeviation_T& iSD) {
- for (unsigned int k = 0; iConstrainedDataHolder.size(); ++k) {
+
+ ioUnconstrainedDataHolder.clear();
+ for (unsigned int k = 0; k < iConstrainedDataHolder.size(); ++k) {
const double kthCensoredData = iConstrainedDataHolder.at(k);
/* Compute E[X | X >= d] where X ~ N(mu, sigma)
@@ -115,12 +127,13 @@
e = - (lerror) * (lerror) * 0.5 / (iSD * iSD);
d2 = exp(e) * iSD / sqrt(2 * 3.14159265);
if (d1 < DEFAULT_EPSILON) {
- ioUnconstrainedDataHolder.push_back(iConstrainedDataHolder.at(k));
+ ioUnconstrainedDataHolder.push_back(kthCensoredData);
}
else {
ioUnconstrainedDataHolder.push_back(iMean + d2/d1);
}
}
+
}
// //////////////////////////////////////////////////////////////////////
Modified: trunk/rmol/rmol/command/Unconstrainer.cpp
===================================================================
--- trunk/rmol/rmol/command/Unconstrainer.cpp 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/rmol/command/Unconstrainer.cpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -21,19 +21,18 @@
// Debug message
std::ostringstream oDebugStr;
- oDebugStr << "Before unconstraining, the constrained Data are "
- << Utilities::vectorToString(ioConstrainedDataHolder) << "."
- << "Unconstrained Data are "
- << Utilities::vectorToString(iUnconstrainedDataHolder)
- << "." ;
+ oDebugStr << "\nProvided unconstrained data: "
+ << Utilities::vectorToString(iUnconstrainedDataHolder)
+ << "Constrained data: "
+ << Utilities::vectorToString(ioConstrainedDataHolder);
// Unconstrain
ExpectationMaximization::unconstrainData
(ioConstrainedDataHolder, iUnconstrainedDataHolder, iStoppingCriterion);
// Debug message
- oDebugStr << "After unconstraining, the constrained Data are "
- << Utilities::vectorToString(ioConstrainedDataHolder) << ".";
+ oDebugStr << "After unconstraining, the constrained data became "
+ << Utilities::vectorToString(ioConstrainedDataHolder);
RMOL_LOG_DEBUG (oDebugStr.str());
Modified: trunk/rmol/rmol/command/Unconstrainer.hpp
===================================================================
--- trunk/rmol/rmol/command/Unconstrainer.hpp 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/rmol/command/Unconstrainer.hpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -20,7 +20,8 @@
Reference: K.T. Talluri and G.Van Ryzin,
The Theory and Practice of Revenue Management. */
static void dataUnconstrainByExpectationMaximization
- (ConstrainedDataHolder_T&, UnconstrainedDataHolder_T&, StoppingCriterion_T&);
+ (ConstrainedDataHolder_T&, UnconstrainedDataHolder_T&,
+ StoppingCriterion_T&);
};
}
Modified: trunk/rmol/rmol/command/Utilities.cpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.cpp 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/rmol/command/Utilities.cpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -31,7 +31,7 @@
{
const unsigned int lSize = iVector.size();
if (lSize > 0) {
- oSum = std::accumulate(iVector.begin(), iVector.end(),0);
+ oSum = std::accumulate(iVector.begin(), iVector.end(), 0.0);
}
else {RMOL_LOG_ERROR ("There is no element to sum up.");}
}
@@ -157,7 +157,7 @@
std::string Utilities::vectorToString (std::vector<double>& iVector) {
std::ostringstream oStr;
for (unsigned int k = 0; k < iVector.size(); k++) {
- oStr << iVector.at(k) << ", ";
+ oStr << iVector.at(k) << " ";
}
return oStr.str() + "\n";
}
Modified: trunk/rmol/rmol/service/RMOL_Service.cpp
===================================================================
--- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -17,6 +17,7 @@
#include <rmol/bom/StudyStatManager.hpp>
#include <rmol/factory/FacRmolServiceContext.hpp>
#include <rmol/command/Optimiser.hpp>
+#include <rmol/command/Unconstrainer.hpp>
#include <rmol/command/Forecaster.hpp>
#include <rmol/service/RMOL_ServiceContext.hpp>
#include <rmol/service/Logger.hpp>
@@ -428,13 +429,14 @@
}
// ///////////////////////////////////////////////////////////////////////
- void dataUnconstrainingByExpectationMaximization () {
+ void RMOL_Service::dataUnconstrainingByExpectationMaximization
+ (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ UnconstrainedDataHolder_T& iUnconstrainedDataHolder,
+ StoppingCriterion_T& iStoppingCriterion) {
+
+ Unconstrainer::dataUnconstrainByExpectationMaximization
+ (ioConstrainedDataHolder, iUnconstrainedDataHolder, iStoppingCriterion);
- // DEBUG
- std::ostringstream logStream;
- logStream << "Testing data unconstraining by Expectation Maximization";
- RMOL_LOG_DEBUG (logStream.str());
-
}
// ///////////////////////////////////////////////////////////////////////
Property changes on: trunk/rmol/test
___________________________________________________________________
Modified: svn:ignore
- .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
ForecasterTestSuite
ForecasterTestSuite.log
ForecasterTestSuite_results.xml
valarrays
+ .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
ForecasterTestSuite
ForecasterTestSuite.log
ForecasterTestSuite_results.xml
UnconstrainerTestSuite
UnconstrainerTestSuite.log
UnconstrainerTestSuite_results.xml
valarrays
Modified: trunk/rmol/test/ForecasterTestSuite.cpp
===================================================================
--- trunk/rmol/test/ForecasterTestSuite.cpp 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/test/ForecasterTestSuite.cpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -99,11 +99,9 @@
// Verify the known mean is returned
oDebugStr << "Case 0: Tested Q-Forecasting algorithm for the given example\n"
<< "Before the test, the flag is " << passedTests << "\n";
- for (unsigned int k = 0; k < lForecastedDemandParameterList.size(); k++) {
- std::vector<double> demandParametersOfAClass =
- lForecastedDemandParameterList.at(k);
- if (k == 1 && demandParametersOfAClass.at(0) == 10.8125) {passedTests = 1;};
- }
+ std::vector<double> demandParametersOfAClass =
+ lForecastedDemandParameterList.at(1);
+ if (demandParametersOfAClass.at(0) == 10.8125) {passedTests = 1;};
oDebugStr << "After the test, the flag is " << passedTests << "\n";
break;
}
@@ -125,11 +123,9 @@
lSellupFactorHolder);
oDebugStr << "Default case Tested Q-Forecasting algorithm for the given example\n"
<< "Before the test, the flag is " << passedTests << "\n";
- for (unsigned int k = 0; k < lForecastedDemandParameterList.size(); k++) {
- std::vector<double> demandParametersOfAClass =
- lForecastedDemandParameterList.at(k);
- if (k == 1 && demandParametersOfAClass.at(0) == 10.8125) {passedTests = 1;};
- }
+ std::vector<double> demandParametersOfAClass =
+ lForecastedDemandParameterList.at(1);
+ if (demandParametersOfAClass.at(0) == 10.8125) {passedTests = 1;};
oDebugStr << "After the test, the flag is " << passedTests << "\n";
}
}
Modified: trunk/rmol/test/Makefile.am
===================================================================
--- trunk/rmol/test/Makefile.am 2009-10-01 13:21:47 UTC (rev 265)
+++ trunk/rmol/test/Makefile.am 2009-10-02 09:38:34 UTC (rev 266)
@@ -10,7 +10,7 @@
##
EXTRA_TESTS = valarrays
-STD_CHECKS = OptimiseTestSuite SimulateTestSuite ForecasterTestSuite
+STD_CHECKS = OptimiseTestSuite SimulateTestSuite ForecasterTestSuite UnconstrainerTestSuite
check_PROGRAMS = $(STD_CHECKS) $(EXTRA_TESTS)
TESTS = $(STD_CHECKS)
XFAIL_TESTS = #IndexBuildingTestSuite
@@ -35,7 +35,15 @@
$(top_builddir)/test/com/libcppunitcore.la \
$(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la
+UnconstrainerTestSuite_SOURCES = UnconstrainerTestSuite.hpp UnconstrainerTestSuite.cpp
+UnconstrainerTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS)
+UnconstrainerTestSuite_LDADD =
+UnconstrainerTestSuite_LDFLAGS = $(CPPUNIT_LIBS) \
+ $(top_builddir)/test/com/libcppunitcore.la \
+ $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la
+
valarrays_SOURCES = valarrays.cpp
valarrays_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS)
valarrays_LDADD =
valarrays_LDFLAGS = $(BOOST_LIBS)
+
Added: trunk/rmol/test/UnconstrainerTestSuite.cpp
===================================================================
--- trunk/rmol/test/UnconstrainerTestSuite.cpp (rev 0)
+++ trunk/rmol/test/UnconstrainerTestSuite.cpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -0,0 +1,112 @@
+// STL
+#include <sstream>
+#include <iostream>
+#include <fstream>
+#include <string>
+// CPPUNIT
+#include <test/com/CppUnitCore.hpp>
+// RMOL
+#include <rmol/RMOL_Service.hpp>
+#include <rmol/RMOL_Types.hpp>
+#include <rmol/RMOL_UNCONSTRAINER_Types.hpp>
+#include <rmol/RMOL_UTILITY_Types.hpp>
+// RMOL Test Suite
+#include <test/UnconstrainerTestSuite.hpp>
+
+// //////////////////////////////////////////////////////////////////////
+int testUnconstrainerHelper (const unsigned short unconstrainingMethodFlag) {
+ int passedTests = 0;
+ try {
+
+ // Output log File
+ std::string lLogFilename ("UnconstrainerTestSuite.log");
+
+ // Methods of unconstraining:
+ // 0 = Unconstraining by Expectation Maximization
+ const unsigned short METHOD_FLAG = unconstrainingMethodFlag;
+
+ // Set the log parameters
+ std::ofstream logOutputFile;
+ // Open and clean the log outputfile
+ logOutputFile.open (lLogFilename.c_str());
+ logOutputFile.clear();
+ std::ostringstream oDebugStr;
+
+ // Initialise the RMOL service
+ RMOL::RMOL_Service rmolService (logOutputFile);
+
+ // A sample historical booking data to be processed by unconstrainer
+ RMOL::ConstrainedDataHolder_T lConstrainedDataHolder;
+ lConstrainedDataHolder.push_back(3);
+ RMOL::UnconstrainedDataHolder_T lUnconstrainedDataHolder;
+ lUnconstrainedDataHolder.push_back(4);
+ lUnconstrainedDataHolder.push_back(3);
+ lUnconstrainedDataHolder.push_back(7);
+ lUnconstrainedDataHolder.push_back(5);
+
+ // Sample price vector
+ RMOL::StoppingCriterion_T lStoppingCriterion = 0.0001;
+
+ switch (METHOD_FLAG) {
+
+ case 0 : // Calculate expected unconstrained value of constrained data
+ {
+ rmolService.dataUnconstrainingByExpectationMaximization
+ (lConstrainedDataHolder, lUnconstrainedDataHolder, lStoppingCriterion);
+
+ // Verify if the test returned expected values
+ oDebugStr << "Test Case 0: EM unconstraining method for a given example\n"
+ << "Before the test, the flag is " << passedTests << "\n";
+ if ( lConstrainedDataHolder.at(0) > 5.142 &&
+ lConstrainedDataHolder.at(0) < 5.143) {
+ passedTests = 1;
+ }
+ // for (unsigned int k = 0; k < lConstrainedDataHolder.size(); k++) {
+ // std::vector<double> demandParametersOfAClass =
+ // lForecastedDemandParameterList.at(k);
+ // if (k == 1 && demandParametersOfAClass.at(0) == 10.8125) {passedTests = 1;};
+ // }
+ oDebugStr << "After the test, the flag is " << passedTests << "\n";
+ break;
+ }
+ case 1 :
+ {
+ oDebugStr << "Test Case 1: "
+ << "Before the test, the flag is " << passedTests << "\n";
+ //
+ oDebugStr << "After the test, the flag is " << passedTests << "\n";
+ break;
+ }
+
+
+ default :
+ {
+ }
+ }
+ logOutputFile << oDebugStr.str() << "\n";
+ logOutputFile.close();
+
+ } catch (const std::exception& stde) {
+ std::cerr << "Standard exception: " << stde.what() << std::endl;
+
+ } catch (...) {
+ std::cerr << "Unknown exception" << std::endl;
+ }
+
+ return passedTests;
+}
+
+// //////////////////////////////////////////////////////////////////////
+void UnconstrainerTestSuite::testUnconstrainingByEM() {
+ const int lTestSuccessFlag = testUnconstrainerHelper(0);
+ CPPUNIT_ASSERT (lTestSuccessFlag == 1);
+}
+
+// //////////////////////////////////////////////////////////////////////
+UnconstrainerTestSuite::UnconstrainerTestSuite () {
+ _describeKey << "Running tests on RMOL data unconstraining methods";
+}
+
+// /////////////// M A I N /////////////////
+CPPUNIT_MAIN()
+
Added: trunk/rmol/test/UnconstrainerTestSuite.hpp
===================================================================
--- trunk/rmol/test/UnconstrainerTestSuite.hpp (rev 0)
+++ trunk/rmol/test/UnconstrainerTestSuite.hpp 2009-10-02 09:38:34 UTC (rev 266)
@@ -0,0 +1,22 @@
+// STL
+#include <sstream>
+// CPPUNIT
+#include <cppunit/extensions/HelperMacros.h>
+
+class UnconstrainerTestSuite : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE (UnconstrainerTestSuite);
+ CPPUNIT_TEST (testUnconstrainingByEM);
+ CPPUNIT_TEST_SUITE_END ();
+public:
+
+ /** Test data unconstraining by Expectation Maximization. */
+ void testUnconstrainingByEM();
+
+ /** Constructor. */
+ UnconstrainerTestSuite ();
+
+protected:
+ std::stringstream _describeKey;
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION (UnconstrainerTestSuite);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-10-01 21:14:48
|
Revision: 265
http://rmol.svn.sourceforge.net/rmol/?rev=265&view=rev
Author: dkchoe
Date: 2009-10-01 13:21:47 +0000 (Thu, 01 Oct 2009)
Log Message:
-----------
Added a method that computes expected (unconstrained) value of constrained data when the variable is normally distributed.
Modified Paths:
--------------
trunk/rmol/rmol/bom/ExpectationMaximization.cpp
trunk/rmol/rmol/bom/ExpectationMaximization.hpp
Modified: trunk/rmol/rmol/bom/ExpectationMaximization.cpp
===================================================================
--- trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2009-09-30 16:59:52 UTC (rev 264)
+++ trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2009-10-01 13:21:47 UTC (rev 265)
@@ -1,8 +1,10 @@
// //////////////////////////////////////////////////////////////////////
// Import section
// //////////////////////////////////////////////////////////////////////
+//GSL
+#include <gsl/gsl_cdf.h>
// STL
-# include <math.h>
+#include <math.h>
// RMOL
#include <rmol/service/Logger.hpp>
#include <rmol/basic/BasConst_General.hpp>
@@ -47,30 +49,40 @@
double lEstimatedMean, lEstimatedSD, lSqErrorOfConstrainedData =
DEFAULT_INITIALIZER_DOUBLE_NEGATIVE;
+ // A holder for unconstrained results at each iteration
+ UnconstrainedDataHolder_T lUnconstrainedDataDuringIteration;
do {
if (lEstimatedMean != DEFAULT_INITIALIZER_DOUBLE_NEGATIVE) {
lCompleteDataMean = lEstimatedMean;
lCompleteDataSD = lEstimatedSD;
}
- // TO-DO: Expectation step
+ // Expectation step
expectedValueOfNormallyDistributedConstrainedData
- (ioConstrainedDataHolder, lCompleteDataMean, lCompleteDataSD);
+ (lUnconstrainedDataDuringIteration, ioConstrainedDataHolder,
+ lCompleteDataMean, lCompleteDataSD);
+
// Maximization step
// Mean
- Utilities::sumUpElements (lEstimatedMean, ioConstrainedDataHolder);
+ Utilities::sumUpElements (lEstimatedMean,
+ lUnconstrainedDataDuringIteration);
lEstimatedMean = (lEstimatedMean + lSumOfUnconstrainedData) /
- lTotalNumberOfData;
+ lTotalNumberOfData;
// S.D.
Utilities::getSquaredError (lSqErrorOfUnconstrainedData,
iUnconstrainedDataHolder, lEstimatedMean);
Utilities::getSquaredError (lSqErrorOfConstrainedData,
- ioConstrainedDataHolder, lEstimatedMean);
+ lUnconstrainedDataDuringIteration,
+ lEstimatedMean);
lEstimatedSD = sqrt((lSqErrorOfUnconstrainedData +
lSqErrorOfConstrainedData) / (lTotalNumberOfData-1));
- } while ( fabs(lCompleteDataMean - lEstimatedMean ) > iStoppingCriterion );
- // If should mean and s.d. of unconstrained data be outputed
+
+ } while(fabs(lCompleteDataMean - lEstimatedMean ) > iStoppingCriterion);
+ // Should mean and s.d. of unconstrained data be outputed:
// lCompleteDataMean = lEstimatedMean; lCompleteDataSD = lEstimatedSD;
+
+ // Update constrained data with unconstrained ones
+ ioConstrainedDataHolder = lUnconstrainedDataDuringIteration;
}
// Job finished as all are unconstrained or nothing to be unconstrained
}
@@ -85,9 +97,31 @@
// //////////////////////////////////////////////////////////////////////
void ExpectationMaximization::
expectedValueOfNormallyDistributedConstrainedData
- (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ (UnconstrainedDataHolder_T& ioUnconstrainedDataHolder,
+ ConstrainedDataHolder_T& iConstrainedDataHolder,
Mean_T& iMean, StandardDeviation_T& iSD) {
-
+ for (unsigned int k = 0; iConstrainedDataHolder.size(); ++k) {
+ const double kthCensoredData = iConstrainedDataHolder.at(k);
+
+ /* Compute E[X | X >= d] where X ~ N(mu, sigma)
+ integral_B^infinity f(x) dx
+ E[X | X >= B] = ----------------------------
+ integral_B^infinity xf(x) dx
+ = mu + d2 / d1
+ */
+ double e, d1, d2;
+ const double lerror = kthCensoredData - iMean;
+ d1 = gsl_cdf_gaussian_Q (lerror, iSD);
+ e = - (lerror) * (lerror) * 0.5 / (iSD * iSD);
+ d2 = exp(e) * iSD / sqrt(2 * 3.14159265);
+ if (d1 < DEFAULT_EPSILON) {
+ ioUnconstrainedDataHolder.push_back(iConstrainedDataHolder.at(k));
+ }
+ else {
+ ioUnconstrainedDataHolder.push_back(iMean + d2/d1);
+ }
+ }
}
+ // //////////////////////////////////////////////////////////////////////
}
Modified: trunk/rmol/rmol/bom/ExpectationMaximization.hpp
===================================================================
--- trunk/rmol/rmol/bom/ExpectationMaximization.hpp 2009-09-30 16:59:52 UTC (rev 264)
+++ trunk/rmol/rmol/bom/ExpectationMaximization.hpp 2009-10-01 13:21:47 UTC (rev 265)
@@ -13,13 +13,16 @@
class ExpectationMaximization {
public :
+
+ /** Return the input constrained data holder after unconstraining. */
static void unconstrainData
(ConstrainedDataHolder_T& ioConstrainedDataHolder,
UnconstrainedDataHolder_T& iUnconstrainedDataHolder,
StoppingCriterion_T& iStoppingCriterion);
static void expectedValueOfNormallyDistributedConstrainedData
- (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ (UnconstrainedDataHolder_T& ioUnconstrainedDataHolder,
+ ConstrainedDataHolder_T& iConstrainedDataHolder,
Mean_T&, StandardDeviation_T&);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-09-30 17:00:07
|
Revision: 264
http://rmol.svn.sourceforge.net/rmol/?rev=264&view=rev
Author: dkchoe
Date: 2009-09-30 16:59:52 +0000 (Wed, 30 Sep 2009)
Log Message:
-----------
Added Expectation Maximization data unconstraining algorithm; Calculation of expected value of censored data is to be done
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_Service.hpp
trunk/rmol/rmol/RMOL_Types.hpp
trunk/rmol/rmol/basic/BasConst.cpp
trunk/rmol/rmol/basic/BasConst_General.hpp
trunk/rmol/rmol/bom/sources.mk
trunk/rmol/rmol/command/Unconstrainer.cpp
trunk/rmol/rmol/command/Unconstrainer.hpp
trunk/rmol/rmol/command/Utilities.cpp
trunk/rmol/rmol/command/Utilities.hpp
trunk/rmol/rmol/core/sources.mk
trunk/rmol/rmol/service/RMOL_Service.cpp
Added Paths:
-----------
trunk/rmol/rmol/RMOL_UNCONSTRAINER_Types.hpp
trunk/rmol/rmol/RMOL_UTILITY_Types.hpp
trunk/rmol/rmol/bom/ExpectationMaximization.cpp
trunk/rmol/rmol/bom/ExpectationMaximization.hpp
Modified: trunk/rmol/rmol/RMOL_Service.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Service.hpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/RMOL_Service.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -124,8 +124,8 @@
ProtectionLevelVector_T&,
BookingLimitVector_T&);
- /** Demand unconstraining by Expectation Maximization */
- void demandUnconstrainingByExpectationMaximization ();
+ /** Data unconstraining by Expectation Maximization */
+ void dataUnconstrainingByExpectationMaximization ();
/** Demand forecast using Q-Forecasting */
void demandForecastByQForecasting (ForecastedDemandParameterList_T&,
Modified: trunk/rmol/rmol/RMOL_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Types.hpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/RMOL_Types.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -94,19 +94,6 @@
/** Define the holder of sellup factors (used for computing Q-eq bookings)*/
typedef std::vector<double> SellupFactorHolder_T;
-// /** Define the historical booking data of a flight date in the order of
-// the classes in the BucketHolder
-// eg.
-// BucketHolder=[Q;M;B;Y], OrderedHistoricalBookingVector_T=[10;5;0;0]
-// 5 corresponds to bookings of class M of a similar flight */
-// typedef std::vector<double> OrderedHistoricalBookingVector_T;
-// /** Define the holder of historical booking vectors */
-// typedef std::vector<HistoricalBookingHolder>
-// HistoricalBookingHolderHolder_T;
-
- // /** Define the holder of Q-equivalent booking values*/
- // typedef std::vector<double> HolderOfQEquivalentBookingsPerSimilarFlight_T;
-
}
#endif // __RMOL_RMOL_TYPES_HPP
Added: trunk/rmol/rmol/RMOL_UNCONSTRAINER_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_UNCONSTRAINER_Types.hpp (rev 0)
+++ trunk/rmol/rmol/RMOL_UNCONSTRAINER_Types.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -0,0 +1,22 @@
+#ifndef __RMOL_RMOL_UNCONSTRAINER_TYPES_HPP
+#define __RMOL_RMOL_UNCONSTRAINER_TYPES_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STL
+#include <vector>
+
+
+namespace RMOL {
+
+ // //////// Type definitions /////////
+
+ /** Define a holder of constrained data.*/
+ typedef std::vector<double> ConstrainedDataHolder_T;
+
+ /** Define a holder of unconstrained data*/
+ typedef std::vector<double> UnconstrainedDataHolder_T;
+
+}
+#endif // __RMOL_RMOL_UNCONSTRAINER_TYPES_HPP
Added: trunk/rmol/rmol/RMOL_UTILITY_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_UTILITY_Types.hpp (rev 0)
+++ trunk/rmol/rmol/RMOL_UTILITY_Types.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -0,0 +1,23 @@
+#ifndef __RMOL_RMOL_UTILITY_TYPES_HPP
+#define __RMOL_RMOL_UTILITY_TYPES_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+
+namespace RMOL {
+
+ // //////// Type definitions /////////
+
+ /** Define a stopping criterion. */
+ typedef double StoppingCriterion_T;
+
+ /** Define a mean type. */
+ typedef double Mean_T;
+
+ /** Define a standard deviation type. */
+ typedef double StandardDeviation_T;
+
+
+}
+#endif // __RMOL_RMOL_UTILITY_TYPES_HPP
Modified: trunk/rmol/rmol/basic/BasConst.cpp
===================================================================
--- trunk/rmol/rmol/basic/BasConst.cpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/basic/BasConst.cpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -18,7 +18,13 @@
/** Default epsilon value to qualify a denominator */
const double DEFAULT_EPSILON = 0.0001;
+
+ /** Default stopping value for an iterative algorithm. */
+ const double DEFAULT_STOPPING_CRITERION = 0.01;
+ /** Default negative value used to initialze a double variable. */
+ const double DEFAULT_INITIALIZER_DOUBLE_NEGATIVE = -10.0;
+
/** Default value for the load factor used for overbooking calculation. */
const double DEFAULT_OVERBOOKING_LOAD_FACTOR = 0.0;
Modified: trunk/rmol/rmol/basic/BasConst_General.hpp
===================================================================
--- trunk/rmol/rmol/basic/BasConst_General.hpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/basic/BasConst_General.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -17,5 +17,12 @@
/** Default epsilon value to qualify a denominator */
extern const double DEFAULT_EPSILON;
+
+ /** Default stopping value for an iterative algorithm. */
+ extern const double DEFAULT_STOPPING_CRITERION;
+
+ /** Default negative value used to initialze a double variable. */
+ extern const double DEFAULT_INITIALIZER_DOUBLE_NEGATIVE;
+
}
#endif // __RMOL_BAS_BASCONST_GENERAL_HPP
Added: trunk/rmol/rmol/bom/ExpectationMaximization.cpp
===================================================================
--- trunk/rmol/rmol/bom/ExpectationMaximization.cpp (rev 0)
+++ trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -0,0 +1,93 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STL
+# include <math.h>
+// RMOL
+#include <rmol/service/Logger.hpp>
+#include <rmol/basic/BasConst_General.hpp>
+#include <rmol/command/Utilities.hpp>
+#include <rmol/bom/ExpectationMaximization.hpp>
+
+namespace RMOL {
+
+ // //////////////////////////////////////////////////////////////////////
+ void ExpectationMaximization::unconstrainData
+ (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ UnconstrainedDataHolder_T& iUnconstrainedDataHolder,
+ StoppingCriterion_T& iStoppingCriterion) {
+
+ if (iStoppingCriterion <= 0) {
+ iStoppingCriterion = DEFAULT_STOPPING_CRITERION;
+ }
+
+ const unsigned int NoOfConstrainededData =
+ ioConstrainedDataHolder.size();
+ const unsigned int NoOfUnconstrainedData =
+ iUnconstrainedDataHolder.size();
+
+ // Unconstraining process
+ if (NoOfUnconstrainedData > 0) {
+ Mean_T lCompleteDataMean = 0.0;
+ StandardDeviation_T lCompleteDataSD = 0.0;
+ double lSumOfUnconstrainedData, lSqErrorOfUnconstrainedData = 0.0;
+ double lTotalNumberOfData = NoOfConstrainededData +
+ NoOfUnconstrainedData;
+ // Mean and S.D. of unconstrained data
+ Utilities::sumUpElements (lSumOfUnconstrainedData,
+ iUnconstrainedDataHolder);
+ lCompleteDataMean = lSumOfUnconstrainedData / NoOfUnconstrainedData;
+ Utilities::getSquaredError (lSqErrorOfUnconstrainedData,
+ iUnconstrainedDataHolder, lCompleteDataMean);
+ lCompleteDataSD = sqrt(lSqErrorOfUnconstrainedData /
+ (NoOfUnconstrainedData-1));
+
+ // If there are constrained data
+ if (NoOfConstrainededData > 0) {
+ double lEstimatedMean, lEstimatedSD, lSqErrorOfConstrainedData =
+ DEFAULT_INITIALIZER_DOUBLE_NEGATIVE;
+
+ do {
+ if (lEstimatedMean != DEFAULT_INITIALIZER_DOUBLE_NEGATIVE) {
+ lCompleteDataMean = lEstimatedMean;
+ lCompleteDataSD = lEstimatedSD;
+ }
+
+ // TO-DO: Expectation step
+ expectedValueOfNormallyDistributedConstrainedData
+ (ioConstrainedDataHolder, lCompleteDataMean, lCompleteDataSD);
+ // Maximization step
+ // Mean
+ Utilities::sumUpElements (lEstimatedMean, ioConstrainedDataHolder);
+ lEstimatedMean = (lEstimatedMean + lSumOfUnconstrainedData) /
+ lTotalNumberOfData;
+ // S.D.
+ Utilities::getSquaredError (lSqErrorOfUnconstrainedData,
+ iUnconstrainedDataHolder, lEstimatedMean);
+ Utilities::getSquaredError (lSqErrorOfConstrainedData,
+ ioConstrainedDataHolder, lEstimatedMean);
+ lEstimatedSD = sqrt((lSqErrorOfUnconstrainedData +
+ lSqErrorOfConstrainedData) / (lTotalNumberOfData-1));
+ } while ( fabs(lCompleteDataMean - lEstimatedMean ) > iStoppingCriterion );
+ // If should mean and s.d. of unconstrained data be outputed
+ // lCompleteDataMean = lEstimatedMean; lCompleteDataSD = lEstimatedSD;
+ }
+ // Job finished as all are unconstrained or nothing to be unconstrained
+ }
+ else {
+ RMOL_LOG_ERROR ("At least one unconstrained data is required to "
+ << "correct constrained data with Expectation "
+ << "Maximization algorithm.");
+ }
+
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void ExpectationMaximization::
+ expectedValueOfNormallyDistributedConstrainedData
+ (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ Mean_T& iMean, StandardDeviation_T& iSD) {
+
+ }
+
+}
Added: trunk/rmol/rmol/bom/ExpectationMaximization.hpp
===================================================================
--- trunk/rmol/rmol/bom/ExpectationMaximization.hpp (rev 0)
+++ trunk/rmol/rmol/bom/ExpectationMaximization.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -0,0 +1,27 @@
+#ifndef __RMOL_BOM_EXPECTATION_MAXIMIZATION_HPP
+#define __RMOL_BOM_EXPECTATION_MAXIMIZATION_HPP
+
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// RMOL
+#include <rmol/RMOL_UNCONSTRAINER_Types.hpp>
+#include <rmol/RMOL_UTILITY_Types.hpp>
+
+namespace RMOL {
+
+ class ExpectationMaximization {
+ public :
+ static void unconstrainData
+ (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ UnconstrainedDataHolder_T& iUnconstrainedDataHolder,
+ StoppingCriterion_T& iStoppingCriterion);
+
+ static void expectedValueOfNormallyDistributedConstrainedData
+ (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ Mean_T&, StandardDeviation_T&);
+
+ };
+}
+#endif // __RMOL_BOM_EXPECTATION_MAXIMIZATION_HPP
Modified: trunk/rmol/rmol/bom/sources.mk
===================================================================
--- trunk/rmol/rmol/bom/sources.mk 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/bom/sources.mk 2009-09-30 16:59:52 UTC (rev 264)
@@ -22,10 +22,8 @@
$(top_srcdir)/rmol/bom/StatAggregatorStruct.hpp \
$(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \
$(top_srcdir)/rmol/bom/StudyStatManager.hpp \
- $(top_srcdir)/rmol/bom/HistoricalBooking.hpp \
- $(top_srcdir)/rmol/bom/HistoricalBookingHolder.hpp \
- $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.hpp \
- $(top_srcdir)/rmol/bom/QForecaster.hpp
+ $(top_srcdir)/rmol/bom/ExpectationMaximization.hpp \
+ $(top_srcdir)/rmol/bom/QForecaster.hpp
bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \
$(top_srcdir)/rmol/bom/Bucket.cpp \
$(top_srcdir)/rmol/bom/BucketHolder.cpp \
@@ -43,4 +41,5 @@
$(top_srcdir)/rmol/bom/MAForecast.cpp \
$(top_srcdir)/rmol/bom/StatAggregatorStruct.cpp \
$(top_srcdir)/rmol/bom/StudyStatManager.cpp \
+ $(top_srcdir)/rmol/bom/ExpectationMaximization.cpp \
$(top_srcdir)/rmol/bom/QForecaster.cpp
Modified: trunk/rmol/rmol/command/Unconstrainer.cpp
===================================================================
--- trunk/rmol/rmol/command/Unconstrainer.cpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/command/Unconstrainer.cpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -1,20 +1,44 @@
// //////////////////////////////////////////////////////////////////////
// Import section
// //////////////////////////////////////////////////////////////////////
+// STL
+#include <iostream>
+// #include <fstream>
// RMOL
+#include <rmol/service/Logger.hpp>
+#include <rmol/RMOL_UNCONSTRAINER_Types.hpp>
+#include <rmol/command/Utilities.hpp>
#include <rmol/command/Unconstrainer.hpp>
-// #include <rmol/bom/Bucket.hpp>
-// #include <rmol/bom/BucketHolder.hpp>
-// #include <rmol/bom/HistoricalBooking.hpp>
-// #include <rmol/bom/HistoricalBookingHolder.hpp>
-// #include <rmol/bom/HistoricalBookingHolderHolder.hpp>
+#include <rmol/bom/ExpectationMaximization.hpp>
-
namespace RMOL {
// //////////////////////////////////////////////////////////////////////
- void Unconstrainer::demandUnconstrainByExpectationMaximization () { }
+ void Unconstrainer::dataUnconstrainByExpectationMaximization
+ (ConstrainedDataHolder_T& ioConstrainedDataHolder,
+ UnconstrainedDataHolder_T& iUnconstrainedDataHolder,
+ StoppingCriterion_T& iStoppingCriterion) {
+
+ // Debug message
+ std::ostringstream oDebugStr;
+ oDebugStr << "Before unconstraining, the constrained Data are "
+ << Utilities::vectorToString(ioConstrainedDataHolder) << "."
+ << "Unconstrained Data are "
+ << Utilities::vectorToString(iUnconstrainedDataHolder)
+ << "." ;
+ // Unconstrain
+ ExpectationMaximization::unconstrainData
+ (ioConstrainedDataHolder, iUnconstrainedDataHolder, iStoppingCriterion);
+
+ // Debug message
+ oDebugStr << "After unconstraining, the constrained Data are "
+ << Utilities::vectorToString(ioConstrainedDataHolder) << ".";
+
+ RMOL_LOG_DEBUG (oDebugStr.str());
+
+ }
+
// //////////////////////////////////////////////////////////////////////
}
Modified: trunk/rmol/rmol/command/Unconstrainer.hpp
===================================================================
--- trunk/rmol/rmol/command/Unconstrainer.hpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/command/Unconstrainer.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -5,14 +5,11 @@
// Import section
// //////////////////////////////////////////////////////////////////////
// RMOL
-#include <rmol/RMOL_Types.hpp>
+#include <rmol/RMOL_UNCONSTRAINER_Types.hpp>
+#include <rmol/RMOL_UTILITY_Types.hpp>
namespace RMOL {
- /** Forward declarations. */
- class BucketHolder;
- struct HistoricalBookingHolderHolder;
-
/** Class wrapping the principal unconstraining algorithms and
some accessory algorithms. */
class Unconstrainer {
@@ -22,7 +19,9 @@
Expectation Maximization algorithm.<br>
Reference: K.T. Talluri and G.Van Ryzin,
The Theory and Practice of Revenue Management. */
- static void demandUnconstrainByExpectationMaximization ();
+ static void dataUnconstrainByExpectationMaximization
+ (ConstrainedDataHolder_T&, UnconstrainedDataHolder_T&, StoppingCriterion_T&);
+
};
}
#endif // __RMOL_COMMAND_UNCONSTRAINER_HPP
Modified: trunk/rmol/rmol/command/Utilities.cpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.cpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/command/Utilities.cpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -12,7 +12,7 @@
#include <functional>
// RMOL
#include <rmol/command/Utilities.hpp>
-
+#include <rmol/service/Logger.hpp>
namespace RMOL {
// /////////////////////////////////////////////////////////////////////
@@ -27,6 +27,16 @@
}
// /////////////////////////////////////////////////////////////////////
+ void Utilities::sumUpElements (double& oSum, std::vector<double>& iVector)
+ {
+ const unsigned int lSize = iVector.size();
+ if (lSize > 0) {
+ oSum = std::accumulate(iVector.begin(), iVector.end(),0);
+ }
+ else {RMOL_LOG_ERROR ("There is no element to sum up.");}
+ }
+
+ // /////////////////////////////////////////////////////////////////////
void Utilities::getMean (double& oMean, std::vector<double>& iVector) {
assert(!iVector.empty());
double lSum = std::accumulate(iVector.begin(), iVector.end(),0);
@@ -35,6 +45,24 @@
}
// /////////////////////////////////////////////////////////////////////
+ void Utilities::getSquaredError (double& oSquaredError,
+ std::vector<double>& iVector,
+ double& iMean) {
+ if (iMean < 0) {RMOL_LOG_ERROR ("Negative mean is not expected.");}
+ else {
+ const unsigned int lSize = iVector.size();
+ if (lSize > 0) {
+ oSquaredError = 0.0;
+ for (unsigned int j = 0; j < lSize; j++) {
+ const double lError = iVector.at(j) - iMean;
+ oSquaredError += lError * lError;
+ }
+ }
+ else {RMOL_LOG_ERROR ("No value to compute the squared error");}
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////////
void Utilities::getStandardDeviation (double& oSD,
std::vector<double>& iVector,
double& iMean) {
@@ -110,7 +138,22 @@
ioVector.at(k) = ioVector.at(k) + iVector.at(k);
}
}
+
// /////////////////////////////////////////////////////////////////////
+ static void appendAVectorToAnother (std::vector<double>& ioVector,
+ std::vector<double>& iVector) {
+ ioVector.insert(ioVector.end(), iVector.begin(), iVector.end());
+ }
+
+ // // /////////////////////////////////////////////////////////////////////
+ // static void overwriteAVectorWithAnotherFromAPosition
+ // (std::vector<double>& ioVector,
+ // std::vector<double>& iVector,
+ // std::vector<double>::iterator fromThisPosition) {
+ // ioVector.insert(ioVector.end(), iVector.begin(), iVector.end());
+ // }
+
+ // /////////////////////////////////////////////////////////////////////
std::string Utilities::vectorToString (std::vector<double>& iVector) {
std::ostringstream oStr;
for (unsigned int k = 0; k < iVector.size(); k++) {
Modified: trunk/rmol/rmol/command/Utilities.hpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.hpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/command/Utilities.hpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -5,6 +5,7 @@
// //////////////////////////////////////////////////////////////////////
// STL
#include <vector>
+#include <string>
namespace RMOL {
@@ -13,9 +14,17 @@
/** Returns the minimum element of a given vector*/
static void getMinimumElement (double& oMinValue, std::vector<double>&);
+ /** Return the sum of all elements of a given vector*/
+ static void sumUpElements (double& oSum, std::vector<double>&);
+
/** Return mean for the given elements of a vector. */
static void getMean (double& oMean, std::vector<double>&);
+ /** Return squared error. */
+ static void getSquaredError (double& oSquaredError,
+ std::vector<double>&,
+ double& iMean);
+
/** Return standard deviation for the given elements of a vector and
precomputed mean. */
static void getStandardDeviation (double& oSD, std::vector<double>&,
@@ -37,6 +46,10 @@
static void addTwoVectors (std::vector<double>& ioVector,
std::vector<double>& iVector);
+ /** Return a vector after appending another vector at the end. */
+ static void appendAVectorToAnother (std::vector<double>& ioVector,
+ std::vector<double>& iVector);
+
/** Return a string constructed by the elements of a vector. */
static std::string vectorToString (std::vector<double>& iVector);
Modified: trunk/rmol/rmol/core/sources.mk
===================================================================
--- trunk/rmol/rmol/core/sources.mk 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/core/sources.mk 2009-09-30 16:59:52 UTC (rev 264)
@@ -1,4 +1,6 @@
service_h_sources = $(top_srcdir)/rmol/RMOL_Types.hpp \
$(top_srcdir)/rmol/RMOL_Service.hpp \
- $(top_srcdir)/rmol/RMOL_FORECASTER_Types.hpp
+ $(top_srcdir)/rmol/RMOL_FORECASTER_Types.hpp \
+ $(top_srcdir)/rmol/RMOL_UNCONSTRAINER_Types.hpp \
+ $(top_srcdir)/rmol/RMOL_UTILITY_Types.hpp
service_cc_sources =
Modified: trunk/rmol/rmol/service/RMOL_Service.cpp
===================================================================
--- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-28 17:48:30 UTC (rev 263)
+++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-30 16:59:52 UTC (rev 264)
@@ -428,11 +428,11 @@
}
// ///////////////////////////////////////////////////////////////////////
- void demandUnconstrainingByExpectationMaximization () {
+ void dataUnconstrainingByExpectationMaximization () {
// DEBUG
std::ostringstream logStream;
- logStream << "Testing demand unconstraining by Expectation Maximization";
+ logStream << "Testing data unconstraining by Expectation Maximization";
RMOL_LOG_DEBUG (logStream.str());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-09-28 17:48:43
|
Revision: 263
http://rmol.svn.sourceforge.net/rmol/?rev=263&view=rev
Author: denis_arnaud
Date: 2009-09-28 17:48:30 +0000 (Mon, 28 Sep 2009)
Log Message:
-----------
[Test] Added a test case for addition of two STL valarrays.
Modified Paths:
--------------
trunk/rmol/test/Makefile.am
Added Paths:
-----------
trunk/rmol/test/valarrays.cpp
Property Changed:
----------------
trunk/rmol/test/
Property changes on: trunk/rmol/test
___________________________________________________________________
Modified: svn:ignore
- .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
ForecasterTestSuite
ForecasterTestSuite.log
ForecasterTestSuite_results.xml
+ .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
ForecasterTestSuite
ForecasterTestSuite.log
ForecasterTestSuite_results.xml
valarrays
Modified: trunk/rmol/test/Makefile.am
===================================================================
--- trunk/rmol/test/Makefile.am 2009-09-28 08:52:36 UTC (rev 262)
+++ trunk/rmol/test/Makefile.am 2009-09-28 17:48:30 UTC (rev 263)
@@ -9,8 +9,10 @@
EXTRA_DIST = testLib.sh
##
-check_PROGRAMS = OptimiseTestSuite SimulateTestSuite ForecasterTestSuite
-TESTS = $(check_PROGRAMS)
+EXTRA_TESTS = valarrays
+STD_CHECKS = OptimiseTestSuite SimulateTestSuite ForecasterTestSuite
+check_PROGRAMS = $(STD_CHECKS) $(EXTRA_TESTS)
+TESTS = $(STD_CHECKS)
XFAIL_TESTS = #IndexBuildingTestSuite
OptimiseTestSuite_SOURCES = OptimiseTestSuite.hpp OptimiseTestSuite.cpp
@@ -32,3 +34,8 @@
ForecasterTestSuite_LDFLAGS = $(BOOST_LIBS) $(CPPUNIT_LIBS) \
$(top_builddir)/test/com/libcppunitcore.la \
$(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la
+
+valarrays_SOURCES = valarrays.cpp
+valarrays_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS)
+valarrays_LDADD =
+valarrays_LDFLAGS = $(BOOST_LIBS)
Added: trunk/rmol/test/valarrays.cpp
===================================================================
--- trunk/rmol/test/valarrays.cpp (rev 0)
+++ trunk/rmol/test/valarrays.cpp 2009-09-28 17:48:30 UTC (rev 263)
@@ -0,0 +1,58 @@
+// //////////////////////////////////////////////////////////////
+// Test case for the STL valarray structure.
+// It is not very robust and well supported (see p547 of the
+// N. Josuttis' book: The C++ Standard Library - ISBN: 0201379260).
+// Alternatives may be:
+// * Boost.Array class (by the same N. Josuttis:
+// http://www.boost.org/doc/libs/1_37_0/doc/html/boost/array.html)
+// which however does not provide the + operator we are wanting here.
+// * Blitz Numerics Arrays (http://www.oonumerics.org/blitz/)
+// //////////////////////////////////////////////////////////////
+// STL
+#include <iostream>
+#include <valarray>
+#include <string>
+// Blitz
+// #include <blitz/array.h>
+
+// ///////////////////////////////////////////////////////////////
+typedef std::valarray<int> List_T;
+
+// ///////////////////////////////////////////////////////////////
+void display (const std::string& iMessage, const List_T& iList) {
+
+ std::cout << iMessage << std::endl;
+
+
+ for (unsigned int idx = 0; idx != iList.size(); ++idx) {
+ std::cout << "[" << idx << "]: " << iList[idx] << std::endl;
+ }
+}
+
+
+// /////////////////////// M A I N //////////////////////////////
+int main (int argc, char* agrv[]) {
+
+ // Initialise two vectors of integers
+ const unsigned int lSize = 10;
+ List_T v1(lSize), v2(lSize);
+ for (unsigned int i = 0; i != lSize; ++i) {
+ v1[i] = i;
+ v2[i] = lSize - i;
+ }
+
+ //
+ display ("v1", v1);
+ display ("v2", v2);
+
+ // Create a third vector being the sum of the two above
+ List_T v3 = v1 + v2;
+
+ //
+ display ("v3", v3);
+
+ // //// Blitz ////
+ // blitz::Array<int,1> bv1(lSize), bv2(lSize);
+
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-09-28 08:52:53
|
Revision: 262
http://rmol.svn.sourceforge.net/rmol/?rev=262&view=rev
Author: dkchoe
Date: 2009-09-28 08:52:36 +0000 (Mon, 28 Sep 2009)
Log Message:
-----------
removed const in typedef; updated optimizer test functions to reflect the new input argument ProtectionLevelVector
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_Types.hpp
trunk/rmol/test/OptimiseTestSuite.cpp
Modified: trunk/rmol/rmol/RMOL_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Types.hpp 2009-09-26 16:04:28 UTC (rev 261)
+++ trunk/rmol/rmol/RMOL_Types.hpp 2009-09-28 08:52:36 UTC (rev 262)
@@ -58,10 +58,10 @@
typedef double ProtectionLevel_T;
/** Define the number of products.*/
- typedef const unsigned int NumberOfProducts_T;
+ typedef unsigned int NumberOfProducts_T;
/** Define the number of products similar to a product.*/
- typedef const unsigned int NumberOfProductsSimilarToAProduct_T;
+ typedef unsigned int NumberOfProductsSimilarToAProduct_T;
/** Define the Bid-Price Vector.
<br> It is a vector of double. */
Modified: trunk/rmol/test/OptimiseTestSuite.cpp
===================================================================
--- trunk/rmol/test/OptimiseTestSuite.cpp 2009-09-26 16:04:28 UTC (rev 261)
+++ trunk/rmol/test/OptimiseTestSuite.cpp 2009-09-28 08:52:36 UTC (rev 262)
@@ -45,6 +45,7 @@
// Define bid price and booking Limit vectors
RMOL::BidPriceVector_T lBidPriceVector;
+ RMOL::ProtectionLevelVector_T lProtectionLevelVector;
RMOL::BookingLimitVector_T lBookingLimitVector;
if (hasInputFile) {
@@ -89,6 +90,7 @@
{
// Test the EMSR-a algorithm implementation
rmolService.heuristicOptimisationByEmsrA (lBidPriceVector,
+ lProtectionLevelVector,
lBookingLimitVector);
// Return a cumulated booking limit value to test
@@ -117,7 +119,8 @@
// Test the algorithm with the sample sell-up vector
rmolService.heuristicOptimisationByEmsrAwithSellup
- (sellupProbabilityVector, lBidPriceVector, lBookingLimitVector);
+ (sellupProbabilityVector, lProtectionLevelVector,
+ lBidPriceVector, lBookingLimitVector);
// Return a cumulated booking limit value to test
oExpectedBookingLimit = static_cast<int> (lBookingLimitVector.at(2));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-09-26 16:04:37
|
Revision: 261
http://rmol.svn.sourceforge.net/rmol/?rev=261&view=rev
Author: denis_arnaud
Date: 2009-09-26 16:04:28 +0000 (Sat, 26 Sep 2009)
Log Message:
-----------
[Branch] The DA branch (import from CVS) has been deleted, as all the content has been migrated into Subversion (long ago, already).
Removed Paths:
-------------
branches/DA/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-09-26 16:02:29
|
Revision: 260
http://rmol.svn.sourceforge.net/rmol/?rev=260&view=rev
Author: denis_arnaud
Date: 2009-09-26 16:02:21 +0000 (Sat, 26 Sep 2009)
Log Message:
-----------
[Branch] Removed the 0.23.0-working branch, as the 0.23.0 version has been released.
Removed Paths:
-------------
branches/rmol-0.23.0-working/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <qua...@us...> - 2009-09-25 13:04:29
|
Revision: 259
http://rmol.svn.sourceforge.net/rmol/?rev=259&view=rev
Author: quannaus
Date: 2009-09-25 13:04:14 +0000 (Fri, 25 Sep 2009)
Log Message:
-----------
Added ProtectionLevel_T in RMOL_Types, removed some unnessary print screen.
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_Service.hpp
trunk/rmol/rmol/RMOL_Types.hpp
trunk/rmol/rmol/bom/BucketHolder.cpp
trunk/rmol/rmol/bom/BucketHolder.hpp
trunk/rmol/rmol/bom/MCOptimiser.cpp
trunk/rmol/rmol/service/RMOL_Service.cpp
Modified: trunk/rmol/rmol/RMOL_Service.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Service.hpp 2009-09-25 08:49:35 UTC (rev 258)
+++ trunk/rmol/rmol/RMOL_Service.hpp 2009-09-25 13:04:14 UTC (rev 259)
@@ -66,6 +66,7 @@
/** Single resource optimization that uses Monte-Carlo algorithm and
returns a vector of cumulated booking limits. */
void optimalOptimisationByMCIntegration (const int K,
+ ProtectionLevelVector_T&,
BidPriceVector_T&,
BookingLimitVector_T&);
@@ -74,21 +75,25 @@
/** Single resource optimization that uses dynamic programming and
returns a vector of cumulated booking limits. */
- void optimalOptimisationByDP (BookingLimitVector_T&);
+ void optimalOptimisationByDP(ProtectionLevelVector_T&,BookingLimitVector_T&);
/** Single resource optimization using EMSR heuristic. */
void heuristicOptimisationByEmsr ();
/** Single resource optimization that uses EMSR heuristic and
returns a bid-price vector and a vector of cumulated booking limits. */
- void heuristicOptimisationByEmsr (BidPriceVector_T&, BookingLimitVector_T&);
+ void heuristicOptimisationByEmsr (BidPriceVector_T&,
+ ProtectionLevelVector_T&,
+ BookingLimitVector_T&);
/** Single resource optimization using EMSR-a heuristic. */
void heuristicOptimisationByEmsrA ();
/** Single resource optimization that uses EMSR-a heuristic and
returns a vector of cumulated booking limits. */
- void heuristicOptimisationByEmsrA (BidPriceVector_T&, BookingLimitVector_T&);
+ void heuristicOptimisationByEmsrA (BidPriceVector_T&,
+ ProtectionLevelVector_T&,
+ BookingLimitVector_T&);
/** Single resource optimization with sellup using EMSR-a heuristic. */
void heuristicOptimisationByEmsrAwithSellup (SellupProbabilityVector_T&);
@@ -96,6 +101,7 @@
/** Single resource optimization with sellup that uses EMSR-a heuristic and
returns a vector of cumulated booking limits. */
void heuristicOptimisationByEmsrAwithSellup (SellupProbabilityVector_T&,
+ ProtectionLevelVector_T&,
BidPriceVector_T&,
BookingLimitVector_T&);
@@ -104,7 +110,9 @@
/** Single resource optimization that uses EMSR-b heuristic and
returns a vector of cumulated booking limits. */
- void heuristicOptimisationByEmsrB (BidPriceVector_T&, BookingLimitVector_T&);
+ void heuristicOptimisationByEmsrB (BidPriceVector_T&,
+ ProtectionLevelVector_T&,
+ BookingLimitVector_T&);
/** Leg optimisation using Monte-Carlo Integration as a step in
network optimisation. */
@@ -112,7 +120,9 @@
/** Leg optimisation using Monte-Carlo Integration as a step in
network optimisation. */
- void legOptimisationByMC (BidPriceVector_T&, BookingLimitVector_T&);
+ void legOptimisationByMC (BidPriceVector_T&,
+ ProtectionLevelVector_T&,
+ BookingLimitVector_T&);
/** Demand unconstraining by Expectation Maximization */
void demandUnconstrainingByExpectationMaximization ();
Modified: trunk/rmol/rmol/RMOL_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Types.hpp 2009-09-25 08:49:35 UTC (rev 258)
+++ trunk/rmol/rmol/RMOL_Types.hpp 2009-09-25 13:04:14 UTC (rev 259)
@@ -53,6 +53,10 @@
<br>It is a double, as it allows for overbooking. */
typedef double BookingLimit_T;
+ /** Define the Protection Level.
+ <br>It is a double, as it allows for overbooking. */
+ typedef double ProtectionLevel_T;
+
/** Define the number of products.*/
typedef const unsigned int NumberOfProducts_T;
@@ -70,6 +74,10 @@
<br> It is a vector of double. */
typedef std::vector<double> BookingLimitVector_T;
+ /** Define the vector of protection levels.
+ <br> It is a vector of double. */
+ typedef std::vector<double> ProtectionLevelVector_T;
+
/** Define the vector of generated demand (for MC integration use).
<br> It is a vector of double. */
typedef std::vector<double> GeneratedDemandVector_T;
Modified: trunk/rmol/rmol/bom/BucketHolder.cpp
===================================================================
--- trunk/rmol/rmol/bom/BucketHolder.cpp 2009-09-25 08:49:35 UTC (rev 258)
+++ trunk/rmol/rmol/bom/BucketHolder.cpp 2009-09-25 13:04:14 UTC (rev 259)
@@ -265,15 +265,20 @@
// //////////////////////////////////////////////////////////////////////
void BucketHolder::
- fillup (BookingLimitVector_T& ioBookingLimitVector) const {
+ fillup (ProtectionLevelVector_T& ioProtectionLevelVector,
+ BookingLimitVector_T& ioBookingLimitVector) const {
BucketList_T::const_iterator itBucket = _bucketList.begin();
for (short j=1; itBucket != _bucketList.end(); itBucket++, j++) {
const Bucket* currentBucket_ptr = *itBucket;
assert (currentBucket_ptr != NULL);
+
+ const ProtectionLevel_T lCumulatedProtection =
+ currentBucket_ptr->getCumulatedProtection();
+ ioProtectionLevelVector.push_back (lCumulatedProtection);
const double lCumulatedBookingLimit =
currentBucket_ptr->getCumulatedBookingLimit();
- ioBookingLimitVector.push_back(lCumulatedBookingLimit);
+ ioBookingLimitVector.push_back (lCumulatedBookingLimit);
}
}
Modified: trunk/rmol/rmol/bom/BucketHolder.hpp
===================================================================
--- trunk/rmol/rmol/bom/BucketHolder.hpp 2009-09-25 08:49:35 UTC (rev 258)
+++ trunk/rmol/rmol/bom/BucketHolder.hpp 2009-09-25 13:04:14 UTC (rev 259)
@@ -47,8 +47,9 @@
current bucket is the first one, the function returns 0.0. */
const double getPreviousCumulatedProtection () const;
- /** Fill up the vector of cumulated booking limits. */
- void fillup (BookingLimitVector_T&) const;
+ /** Fill up the vector of cumulated booking limits and the vector
+ of cumulated protection levels. */
+ void fillup (ProtectionLevelVector_T&, BookingLimitVector_T&) const;
/** Get the current element (bucket/class). */
Bucket& getCurrentBucket () const;
Modified: trunk/rmol/rmol/bom/MCOptimiser.cpp
===================================================================
--- trunk/rmol/rmol/bom/MCOptimiser.cpp 2009-09-25 08:49:35 UTC (rev 258)
+++ trunk/rmol/rmol/bom/MCOptimiser.cpp 2009-09-25 13:04:14 UTC (rev 259)
@@ -140,9 +140,10 @@
const double ljdouble = std::floor (Kj * (pj - pj1) / pj);
lj = static_cast<int> (ljdouble);
- /** DEBUG
- RMOL_LOG_DEBUG ("p(j+1)/p(j) = " << pj1 / pj << ", lj = " << lj
- << ", Kj = " << Kj << " => " << Kj - lj << " points above y(j)");
+ /** DEBUG
+ RMOL_LOG_DEBUG ("p(j+1)/p(j) = " << pj1 / pj << ", lj = " << lj
+ << ", Kj = " << Kj << " => " << Kj - lj
+ << " points above y(j)");
*/
/** Consistency check. */
@@ -379,14 +380,11 @@
const double ljdouble = std::floor (Kj * (pj - pj1) / pj);
lj = static_cast<int> (ljdouble);
- // DEBUG
- std::cout << "l" << j << " = " << lj << std::endl;
-
- /** DEBUG
+ /** DEBUG
RMOL_LOG_DEBUG ("p(j+1)/p(j) = " << pj1 / pj << ", lj = " << lj
<< ", Kj = " << Kj << " => " << Kj - lj << " points above y(j)");
*/
-
+
/** Consistency check. */
assert (lj >= 1 && lj < Kj);
Modified: trunk/rmol/rmol/service/RMOL_Service.cpp
===================================================================
--- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-25 08:49:35 UTC (rev 258)
+++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-25 13:04:14 UTC (rev 259)
@@ -185,10 +185,10 @@
}
// //////////////////////////////////////////////////////////////////////
- void RMOL_Service::
- optimalOptimisationByMCIntegration(const int K,
- BidPriceVector_T& ioBidPriceVector,
- BookingLimitVector_T& ioBookingLimitVector){
+ void RMOL_Service::optimalOptimisationByMCIntegration
+ (const int K, ProtectionLevelVector_T& ioProtectionLevelVector,
+ BidPriceVector_T& ioBidPriceVector,
+ BookingLimitVector_T& ioBookingLimitVector){
assert (_rmolServiceContext != NULL);
const double iCapacity = _rmolServiceContext->getCapacity();
@@ -200,7 +200,7 @@
ioBidPriceVector);
// Fill up booking vector
- oBucketHolder_ptr->fillup (ioBookingLimitVector);
+ oBucketHolder_ptr->fillup (ioProtectionLevelVector, ioBookingLimitVector);
}
// //////////////////////////////////////////////////////////////////////
@@ -220,7 +220,8 @@
// //////////////////////////////////////////////////////////////////////
void RMOL_Service::
- optimalOptimisationByDP (BookingLimitVector_T& ioBookingLimitVector) {
+ optimalOptimisationByDP (ProtectionLevelVector_T& ioProtectionLevelVector,
+ BookingLimitVector_T& ioBookingLimitVector) {
assert (_rmolServiceContext != NULL);
const double iCapacity = _rmolServiceContext->getCapacity();
@@ -230,7 +231,7 @@
Optimiser::optimalOptimisationByDP (iCapacity, *oBucketHolder_ptr);
// Fill up booking vector
- oBucketHolder_ptr->fillup (ioBookingLimitVector);
+ oBucketHolder_ptr->fillup (ioProtectionLevelVector, ioBookingLimitVector);
}
// //////////////////////////////////////////////////////////////////////
@@ -273,6 +274,7 @@
// //////////////////////////////////////////////////////////////////////
void RMOL_Service::
heuristicOptimisationByEmsr (BidPriceVector_T& ioBidPriceVector,
+ ProtectionLevelVector_T& ioProtectionLevelVector,
BookingLimitVector_T& ioBookingLimitVector) {
assert (_rmolServiceContext != NULL);
const double iCapacity = _rmolServiceContext->getCapacity();
@@ -282,14 +284,7 @@
Optimiser::heuristicOptimisationByEmsr (iCapacity, *oBucketHolder_ptr,
ioBidPriceVector);
- // Update the booking limit vector.
- for (oBucketHolder_ptr->begin(); oBucketHolder_ptr->hasNotReachedEnd();
- oBucketHolder_ptr->iterate()) {
- Bucket& currentBucket = oBucketHolder_ptr->getCurrentBucket();
- const double lBookingLimit = currentBucket.getCumulatedBookingLimit();
- ioBookingLimitVector.push_back (lBookingLimit);
- }
-
+ oBucketHolder_ptr->fillup (ioProtectionLevelVector, ioBookingLimitVector);
}
// //////////////////////////////////////////////////////////////////////
@@ -308,6 +303,7 @@
// //////////////////////////////////////////////////////////////////////
void RMOL_Service::
heuristicOptimisationByEmsrA (BidPriceVector_T& ioBidPriceVector,
+ ProtectionLevelVector_T& ioProtectionLevelVector,
BookingLimitVector_T& ioBookingLimitVector) {
assert (_rmolServiceContext != NULL);
const double iCapacity = _rmolServiceContext->getCapacity();
@@ -317,7 +313,7 @@
Optimiser::heuristicOptimisationByEmsrA (iCapacity, *oBucketHolder_ptr);
// Fill up booking vector
- oBucketHolder_ptr->fillup (ioBookingLimitVector);
+ oBucketHolder_ptr->fillup (ioProtectionLevelVector, ioBookingLimitVector);
}
// //////////////////////////////////////////////////////////////////////
@@ -343,6 +339,7 @@
void RMOL_Service::heuristicOptimisationByEmsrAwithSellup
(SellupProbabilityVector_T& iSellupProbabilityVector,
BidPriceVector_T& ioBidPriceVector,
+ ProtectionLevelVector_T& ioProtectionLevelVector,
BookingLimitVector_T& ioBookingLimitVector) {
assert (_rmolServiceContext != NULL);
@@ -357,7 +354,7 @@
iSellupProbabilityVector);
// Fill up booking limit vector
- ioBucketHolder_ptr->fillup (ioBookingLimitVector);
+ ioBucketHolder_ptr->fillup (ioProtectionLevelVector, ioBookingLimitVector);
}
// //////////////////////////////////////////////////////////////////////
@@ -376,6 +373,7 @@
// //////////////////////////////////////////////////////////////////////
void RMOL_Service::
heuristicOptimisationByEmsrB (BidPriceVector_T& ioBidPriceVector,
+ ProtectionLevelVector_T& ioProtectionLevelVector,
BookingLimitVector_T& ioBookingLimitVector) {
assert (_rmolServiceContext != NULL);
const double iCapacity = _rmolServiceContext->getCapacity();
@@ -385,7 +383,7 @@
Optimiser::heuristicOptimisationByEmsrB (iCapacity, *oBucketHolder_ptr);
// Fill up booking vector
- oBucketHolder_ptr->fillup (ioBookingLimitVector);
+ oBucketHolder_ptr->fillup (ioProtectionLevelVector, ioBookingLimitVector);
}
// ///////////////////////////////////////////////////////////////////////
@@ -415,6 +413,7 @@
// ///////////////////////////////////////////////////////////////////////
void RMOL_Service::
legOptimisationByMC (BidPriceVector_T& ioBidPriceVector,
+ ProtectionLevelVector_T& ioProtectionLevelVector,
BookingLimitVector_T& ioBookingLimitVector) {
assert (_rmolServiceContext != NULL);
const ResourceCapacity_T iCapacity = _rmolServiceContext->getCapacity();
@@ -425,7 +424,7 @@
ioBidPriceVector);
// Fill up booking vector
- oBucketHolder_ptr->fillup (ioBookingLimitVector);
+ oBucketHolder_ptr->fillup (ioProtectionLevelVector, ioBookingLimitVector);
}
// ///////////////////////////////////////////////////////////////////////
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-09-25 08:49:46
|
Revision: 258
http://rmol.svn.sourceforge.net/rmol/?rev=258&view=rev
Author: dkchoe
Date: 2009-09-25 08:49:35 +0000 (Fri, 25 Sep 2009)
Log Message:
-----------
Q-eq demand mean & s.d. calculation and partition has been tested using a test program; Added more typedefs
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
trunk/rmol/rmol/RMOL_Service.hpp
trunk/rmol/rmol/RMOL_Types.hpp
trunk/rmol/rmol/bom/QForecaster.cpp
trunk/rmol/rmol/bom/QForecaster.hpp
trunk/rmol/rmol/command/Forecaster.cpp
trunk/rmol/rmol/command/Forecaster.hpp
trunk/rmol/rmol/command/Utilities.cpp
trunk/rmol/rmol/command/Utilities.hpp
trunk/rmol/rmol/service/RMOL_Service.cpp
trunk/rmol/test/Makefile.am
Added Paths:
-----------
trunk/rmol/test/ForecasterTestSuite.cpp
trunk/rmol/test/ForecasterTestSuite.hpp
Property Changed:
----------------
trunk/rmol/test/
Modified: trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -22,11 +22,14 @@
inputs resulted the parameters themselves.*/
typedef std::vector< std::vector<double> > ForecastedDemandParameterList_T;
+ /** Define a holder of forecasted demand mean and standard deviation.*/
+ typedef std::vector<double > ForecastedDemandParameters_T;
+
/** Define a vector of fares. */
typedef std::vector<double> PriceHolder_T;
-// /** Define historical data vector*/
-// typedef std::vector<double> HistoricalDataHolder_T;
+ /** Define historical data vector*/
+ typedef std::vector<double> HistoricalDataHolder_T;
/** Define vector of historical data vector*/
typedef std::vector< std::vector<double> > HistoricalDataHolderHolder_T;
@@ -34,5 +37,8 @@
/** Define a holder for Q-equivalent demand parameters. */
typedef std::vector<double> QEquivalentDemandParameterHolder_T;
+ /** Define a holder for Q-equivalent demands. */
+ typedef std::vector<double> QEquivalentDemandHolder_T;
+
}
#endif // __RMOL_RMOL_FORECASTER_TYPES_HPP
Modified: trunk/rmol/rmol/RMOL_Service.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Service.hpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/RMOL_Service.hpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -117,12 +117,8 @@
/** Demand unconstraining by Expectation Maximization */
void demandUnconstrainingByExpectationMaximization ();
- /** Demand forecast using Q-Forecasting [used in unit tests] */
- void demandForecastByQForecasting (HistoricalDataHolderHolder_T&,
- PriceHolder_T&);
-
/** Demand forecast using Q-Forecasting */
- void demandForecastByQForecasting (ForecastedDemandParameterList_T,
+ void demandForecastByQForecasting (ForecastedDemandParameterList_T&,
HistoricalDataHolderHolder_T&,
PriceHolder_T&,
SellupFactorHolder_T&);
Modified: trunk/rmol/rmol/RMOL_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Types.hpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/RMOL_Types.hpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -53,6 +53,12 @@
<br>It is a double, as it allows for overbooking. */
typedef double BookingLimit_T;
+ /** Define the number of products.*/
+ typedef const unsigned int NumberOfProducts_T;
+
+ /** Define the number of products similar to a product.*/
+ typedef const unsigned int NumberOfProductsSimilarToAProduct_T;
+
/** Define the Bid-Price Vector.
<br> It is a vector of double. */
typedef std::vector<double> BidPriceVector_T;
@@ -71,9 +77,12 @@
/** Define the holder of the generated demand vectors. */
typedef std::vector<GeneratedDemandVector_T> GeneratedDemandVectorHolder_T;
- /** Define the sellup probability vector applicable to EMSR*/
- typedef std::vector<double> SellupProbabilityVector_T;
+ /** Define the sellup probability.*/
+ typedef double SellupProbability_T;
+ /** Define the sellup probability vector.*/
+ typedef std::vector<SellupProbability_T> SellupProbabilityVector_T;
+
/** Define the holder of sellup factors (used for computing Q-eq bookings)*/
typedef std::vector<double> SellupFactorHolder_T;
Modified: trunk/rmol/rmol/bom/QForecaster.cpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -5,11 +5,14 @@
#include <cmath>
#include <algorithm>
#include <numeric>
-// RMOL Bom
-#include <rmol/bom/Bucket.hpp>
-#include <rmol/bom/BucketHolder.hpp>
+#include <iostream>
+#include <fstream>
+// RMOL
+// #include <rmol/bom/Bucket.hpp>
+// #include <rmol/bom/BucketHolder.hpp>
#include <rmol/bom/QForecaster.hpp>
#include <rmol/command/Utilities.hpp>
+#include <rmol/service/Logger.hpp>
namespace RMOL {
@@ -41,7 +44,7 @@
for (unsigned short j = 0; j < iPriceHolder.size(); j++){
const double lYield = iPriceHolder.at(j);
const double probSellup =
- exp(-iSellupFactorHolder.at(j) * lYield / (iQYield));
+ exp(-iSellupFactorHolder.at(j) * (lYield / iQYield - 1));
ioSellupProbabilityVector.push_back(probSellup);
}
}
@@ -51,31 +54,43 @@
(QEquivalentDemandParameterHolder_T& ioQEquivalentDemandParameterHolder,
HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder,
SellupProbabilityVector_T& iSellupProbabilityVector) {
+
+ // Debug
+ std::ostringstream oDebugStr;
+ oDebugStr << "\n";
+
// 1. Calculate Q-equivalent demand parameters
// Initialize a holder for Q-equivalent Demands
// std::vector<double> aZeroVector (iSellupProbabilityVector.size(), 0);
// std::vector<double>& lQEquivalentDemandHolder = aZeroVector;
- std::vector<double> lQEquivalentDemandHolder;
+ // Initialize 0 vector with the size of a data holder
+ QEquivalentDemandHolder_T lQEquivalentDemandHolder
+ (iHistoricalDataHolderHolder.at(0).size(), 0);
for (unsigned int j = 0; j < iHistoricalDataHolderHolder.size(); j++) {
// Retrieve HistoricalDataHolder which are the data of the same product
// over different dates
- std::vector<double>& lHistoricalDataHolder =
+ HistoricalDataHolder_T lHistoricalDataHolder =
iHistoricalDataHolderHolder.at(j);
double lSellupProbability = iSellupProbabilityVector.at(j);
// Apply sellup probability to historical data
- Utilities::MultiplyAValueToAVector (lHistoricalDataHolder,
+ Utilities::multiplyAValueToAVector (lHistoricalDataHolder,
1/lSellupProbability);
+ oDebugStr << "Q-equivalent demand of a product for each date "
+ << Utilities::vectorToString (lHistoricalDataHolder);
// Collect historical data by date
- Utilities::AddTwoVectors (lQEquivalentDemandHolder,
+ Utilities::addTwoVectors (lQEquivalentDemandHolder,
lHistoricalDataHolder);
}
+ oDebugStr << "Q-equivalent demand of a day "
+ << Utilities::vectorToString (lQEquivalentDemandHolder);
// 2. Compute Q-equivalent demand mean and standard deviation
Utilities::getMeanAndStandardDeviation (ioQEquivalentDemandParameterHolder,
lQEquivalentDemandHolder);
+ RMOL_LOG_DEBUG (oDebugStr.str());
}
// //////////////////////////////////////////////////////////////////////
@@ -84,35 +99,35 @@
QEquivalentDemandParameterHolder_T& iQEquivalentDemandParameterHolder,
SellupProbabilityVector_T& iSellupProbabilityVector) {
- unsigned int noOfClasses = iSellupProbabilityVector.size();
+ NumberOfProducts_T noOfClasses = iSellupProbabilityVector.size();
// Sort sellup probabilities in increasing order and copy into a vector
- std::vector<double> lSortedSellupProbabilityVector(noOfClasses);
+ SellupProbabilityVector_T lSortedSellupProbabilityVector(noOfClasses);
std::partial_sort_copy (iSellupProbabilityVector.begin(),
- iSellupProbabilityVector.end(),
- lSortedSellupProbabilityVector.begin(),
- lSortedSellupProbabilityVector.end());
+ iSellupProbabilityVector.end(),
+ lSortedSellupProbabilityVector.begin(),
+ lSortedSellupProbabilityVector.end());
// Compute the probability to sell-up to class i but not i-1 (class
// with the next higher fare) and copy into a vector
- std::vector<double> lSellupProbabilityDifferenceVector(noOfClasses);
+ SellupProbabilityVector_T lSellupProbabilityDifferenceVector(noOfClasses);
adjacent_difference (lSortedSellupProbabilityVector.begin(),
- lSortedSellupProbabilityVector.end(),
- lSellupProbabilityDifferenceVector.begin());
+ lSortedSellupProbabilityVector.end(),
+ lSellupProbabilityDifferenceVector.begin());
// Partition Q-equivalent demand mean and S.D. into each class
ioForecastedDemandParameterList.clear();
- for (unsigned short k=0; k < noOfClasses; k++) {
+ for (unsigned int k=0; k < noOfClasses; k++) {
// Locate the current sell-up probability in the sorted one
- std::vector<double>::iterator pos =
+ SellupProbabilityVector_T::iterator pos =
std::lower_bound (lSortedSellupProbabilityVector.begin(),
lSortedSellupProbabilityVector.end(),
iSellupProbabilityVector.at(k));
- int posOfCurrentSellupProbInSortedVector =
+ const int posOfCurrentSellupProbInSortedVector =
std::distance(lSortedSellupProbabilityVector.begin(), pos);
// Find the corresponding sell-up probability difference
- double correspondingSellupProbability =
+ SellupProbability_T correspondingSellupProbability =
lSellupProbabilityDifferenceVector.at(
posOfCurrentSellupProbInSortedVector);
@@ -121,10 +136,10 @@
// class S.D. = Q-eq S.D. * sell-up prob difference
ioForecastedDemandParameterList.push_back
(iQEquivalentDemandParameterHolder);
- std::vector<double>& forecastedDemandParameters =
- ioForecastedDemandParameterList.at(k);
- Utilities::MultiplyAValueToAVector (forecastedDemandParameters,
- correspondingSellupProbability);
+ ForecastedDemandParameters_T& lForecastedDemandParameters =
+ ioForecastedDemandParameterList.at(k);
+ Utilities::multiplyAValueToAVector (lForecastedDemandParameters,
+ correspondingSellupProbability);
}
}
Modified: trunk/rmol/rmol/bom/QForecaster.hpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -6,28 +6,16 @@
// //////////////////////////////////////////////////////////////////////
// RMOL Bom
#include <rmol/bom/BomAbstract.hpp>
+#include <rmol/RMOL_Types.hpp>
#include <rmol/RMOL_FORECASTER_Types.hpp>
namespace RMOL {
- // Forward declaration
- class BucketHolder;
-
/** Accessary Class for Sellup considered forecast methods. */
class QForecaster : public BomAbstract {
public:
- // /** Calculate sell-up probability for given sell-up factor,
- // and yield ratio between the sell-up occurs.<br>
- // The formular was proposed by Belobaba and Hopperstad:
- // Algorithms for Revenue Management in Unrestricted Fare Markets,
- // AGIFORS, Auckland, New Zealand, Jan 2004 */
- // static void calculateSellupProbability (BucketHolder&,
- // const double iQYield,
- // const SellupFactorHolder_T&,
- // SellupProbabilityVector_T&);
-
/** The same method as the above but taking price data directly
instead of through BucketHolder. */
static void calculateSellupProbability (SellupProbabilityVector_T&,
Modified: trunk/rmol/rmol/command/Forecaster.cpp
===================================================================
--- trunk/rmol/rmol/command/Forecaster.cpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/command/Forecaster.cpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -2,15 +2,19 @@
// Import section
// //////////////////////////////////////////////////////////////////////
#include <math.h>
+#include <string>
+#include <iostream>
+#include <fstream>
// RMOL
-#include <rmol/bom/Bucket.hpp>
-#include <rmol/bom/BucketHolder.hpp>
-#include <rmol/bom/HistoricalBooking.hpp>
-#include <rmol/bom/HistoricalBookingHolder.hpp>
-#include <rmol/bom/HistoricalBookingHolderHolder.hpp>
+// #include <rmol/bom/Bucket.hpp>
+// #include <rmol/bom/BucketHolder.hpp>
+// #include <rmol/bom/HistoricalBooking.hpp>
+// #include <rmol/bom/HistoricalBookingHolder.hpp>
+// #include <rmol/bom/HistoricalBookingHolderHolder.hpp>
#include <rmol/bom/QForecaster.hpp>
#include <rmol/command/Forecaster.hpp>
#include <rmol/command/Utilities.hpp>
+#include <rmol/service/Logger.hpp>
namespace RMOL {
@@ -41,7 +45,7 @@
// //////////////////////////////////////////////////////////////////////
void Forecaster::demandForecastByQForecasting
- (ForecastedDemandParameterList_T oForecastedDemandParameterList,
+ (ForecastedDemandParameterList_T& ioForecastedDemandParameterList,
HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder,
PriceHolder_T& iPriceHolder,
SellupFactorHolder_T& iSellupFactorHolder) {
@@ -50,30 +54,50 @@
// 2. Partition to each class
// E(alpha x Q)=alpha x mu_Q, S.D.(alpha x Q) = |alpha| X sigma_Q
+ // Debug
+ std::ostringstream oDebugStr;
+ oDebugStr << "Prices are "
+ << Utilities::vectorToString(iPriceHolder) << "\n"
+ << "Sell up factors are "
+ << Utilities::vectorToString(iSellupFactorHolder) << "\n";
+
// Find the class with the lowest yield
double lQYield;
Utilities::getMinimumElement (lQYield, iPriceHolder);
+ // Debug
+ oDebugStr << "The minimum yield is " << lQYield << "\n";
// Initialize a holder for sell-up probabilities
SellupProbabilityVector_T lSellupProbabilityVector;
-
// Compute sell-up probability for each class/bucket & store it in a vector
QForecaster::calculateSellupProbability
(lSellupProbabilityVector, lQYield, iPriceHolder, iSellupFactorHolder);
+ // Debug
+ oDebugStr << "Sell-up Probabilities are "
+ << Utilities::vectorToString (lSellupProbabilityVector) << "\n";
// Initialize a holder for Q-equivalent Demand Parameters
QEquivalentDemandParameterHolder_T lQEquivalentDemandParameterHolder;
-
// Calculate Q-equivalent demand distribution parameters.
QForecaster::calculateQEquivalentDemandParameters
(lQEquivalentDemandParameterHolder, iHistoricalDataHolderHolder,
lSellupProbabilityVector);
+ // Debug
+ oDebugStr << "Q-equivalent demand parameters [mean, SD] = "
+ << Utilities::vectorToString (lQEquivalentDemandParameterHolder)
+ << "\n";
// Calculate Q-equivalent demand distribution parameters and
// partition it to each class/bucket
- //QForecaster::partitionQEquivalentDemandParameters
- // (oForecastedDemandParameterList, lQEquivalentDemandParameterHolder,
- // lSellupProbabilityVector);
-
+ QForecaster::partitionQEquivalentDemandParameters
+ (ioForecastedDemandParameterList, lQEquivalentDemandParameterHolder,
+ lSellupProbabilityVector);
+ // debug
+ for (unsigned int k = 0; k < ioForecastedDemandParameterList.size(); k++) {
+ std::vector<double> lMeanAndSDOfAClass = ioForecastedDemandParameterList.at(k);
+ oDebugStr << "Q-equivalent distribution parameters per class "
+ << Utilities::vectorToString (lMeanAndSDOfAClass);
+ }
+ RMOL_LOG_DEBUG(oDebugStr.str());
}
}
Modified: trunk/rmol/rmol/command/Forecaster.hpp
===================================================================
--- trunk/rmol/rmol/command/Forecaster.hpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/command/Forecaster.hpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -19,29 +19,6 @@
class Forecaster {
public:
- // // /**
- // // An accessory algorithm for demand forecasting.
-
- // // Calculate Q-equivalent bookings for the given group of
- // // classes/buckets/fare points using the given
- // // sell-up factors.
-
- // // Q-equivalent bookings are, by definition,
-
- // // SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i}
- // // where
- // // ProbSellup_{bucket i} =
- // // EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets}))
- // // */
- // // static void qEquivalentBookingCalculation
- // // (BucketHolder&,
- // // SellupFactorHolder_T&,
- // // HistoricalBookingHolderHolder&,
- // // HolderOfQEquivalentBookingsPerSimilarFlight_T&);
-
- // /**
- // An accessory algorithm for demand forecasting.
-
// Calculate Q-equivalent demands for the given group of
// classes/buckets/fare points using the given
// sell-up factors.
@@ -65,7 +42,7 @@
NOTES: Inputs are supposed to be appropriately ordered so that
i-th element of the PriceHolder is the price associated to the
i-th element of the HistoricalDataHolderHolder. */
- static void demandForecastByQForecasting (ForecastedDemandParameterList_T,
+ static void demandForecastByQForecasting (ForecastedDemandParameterList_T&,
HistoricalDataHolderHolder_T&,
PriceHolder_T&,
SellupFactorHolder_T&);
Modified: trunk/rmol/rmol/command/Utilities.cpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.cpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/command/Utilities.cpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -4,6 +4,8 @@
// //////////////////////////////////////////////////////////////////////
//STL
#include <algorithm>
+#include <string>
+#include <sstream>
#include <numeric>
#include <math.h>
#include <assert.h>
@@ -59,14 +61,17 @@
ioMean_SD.clear();
// Mean
- double lSum = std::accumulate(iVector.begin(), iVector.end(), 0);
- double lMean = lSum/lSize;
+ double lMean = 0;
+ for (unsigned int k = 0; k < lSize; k++) {
+ lMean += iVector.at(k);
+ }
+ lMean /= lSize;
ioMean_SD.push_back(lMean);
//Standard Deviation
double lSD = 0;
for (unsigned int j = 0; j < lSize; j++) {
- const double lDeviation = iVector.at(j);
+ const double lDeviation = iVector.at(j) - lMean;
lSD += lDeviation * lDeviation;
}
lSD /= (lSize - 1);
@@ -74,7 +79,7 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::AddAValueToAVector (std::vector<double>& ioVector,
+ void Utilities::addAValueToAVector (std::vector<double>& ioVector,
double iValue){
const unsigned int lSize = ioVector.size();
assert(lSize > 0);
@@ -85,7 +90,7 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::MultiplyAValueToAVector (std::vector<double>& ioVector,
+ void Utilities::multiplyAValueToAVector (std::vector<double>& ioVector,
double iValue) {
const unsigned int lSize = ioVector.size();
assert(lSize > 0);
@@ -96,12 +101,21 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::AddTwoVectors (std::vector<double>& ioVector,
- std::vector<double>& iVector) {
- std::transform (ioVector.begin(), ioVector.end(),
- iVector.begin(),
- ioVector.begin(),
- std::plus<double>());
+ void Utilities::addTwoVectors (std::vector<double>& ioVector,
+ std::vector<double>& iVector) {
+ unsigned int lSize = ioVector.size();
+ // assert(lSize == iVector.size());
+
+ for (unsigned int k = 0; k < lSize; k++) {
+ ioVector.at(k) = ioVector.at(k) + iVector.at(k);
}
-
+ }
+ // /////////////////////////////////////////////////////////////////////
+ std::string Utilities::vectorToString (std::vector<double>& iVector) {
+ std::ostringstream oStr;
+ for (unsigned int k = 0; k < iVector.size(); k++) {
+ oStr << iVector.at(k) << ", ";
+ }
+ return oStr.str() + "\n";
+ }
}
Modified: trunk/rmol/rmol/command/Utilities.hpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.hpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/command/Utilities.hpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -26,17 +26,20 @@
std::vector<double>&);
/** Return the input vector after adding a value. */
- static void AddAValueToAVector (std::vector<double>& ioVector,
+ static void addAValueToAVector (std::vector<double>& ioVector,
double iValue);
/** Return the input vector after multiplying a value. */
- static void MultiplyAValueToAVector (std::vector<double>& ioVector,
+ static void multiplyAValueToAVector (std::vector<double>& ioVector,
double iValue);
/** Return first input vector after adding 2nd input vector to it. */
- static void AddTwoVectors (std::vector<double>& ioVector,
+ static void addTwoVectors (std::vector<double>& ioVector,
std::vector<double>& iVector);
-
+
+ /** Return a string constructed by the elements of a vector. */
+ static std::string vectorToString (std::vector<double>& iVector);
+
};
}
Modified: trunk/rmol/rmol/service/RMOL_Service.cpp
===================================================================
--- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -440,62 +440,16 @@
// ///////////////////////////////////////////////////////////////////////
void RMOL_Service::demandForecastByQForecasting
- (HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder,
- PriceHolder_T& iPriceHolder) {
-
- // Declare forecaster output holder
- ForecastedDemandParameterList_T lForecastedDemandParameterList;
-
-// // Make an element of a ForecastedDemandParameterList_T. It is needed
-// // to use the reference of lForecastedDemandParameterList as an
-// // input argument.
-// double lMean = 0.0;
-// double lSD = 0.0;
-// std::vector<double> lForecastedDemandParameters;
-// lForecastedDemandParameters.push_back(lMean);
-// lForecastedDemandParameters.push_back(lSD);
-
-// // Instantiate the forecaster output holder with the element created above
-// lForecastedDemandParameterList.insert
-// (std::map<std::string, std::vector<double> >::
-// value_type("YNCELHR", lForecastedDemandParameters));
-
-// ForecastedDemandParameterList_T& lForecastedDemandParameterList_ref =
-// lForecastedDemandParameterList;
-
-// // Run Q-Forecasting algorithm
-// Forecaster::demandForecastByQForecasting (oForecastedDemandParameterList,
-// iHistoricalDataHolderHolder,
-// iPriceHolder);
-
- // DEBUG
-// RMOL_LOG_DEBUG (oBucketHolder_ptr->display());
- std::ostringstream logStream;
- logStream << "Testing Demand Forecasting by Q-Forecasting";
- RMOL_LOG_DEBUG (logStream.str());
-
- }
-
- // ///////////////////////////////////////////////////////////////////////
- void RMOL_Service::demandForecastByQForecasting
- (ForecastedDemandParameterList_T oForecastedDemandParameterList,
+ (ForecastedDemandParameterList_T& ioForecastedDemandParameterList,
HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder,
PriceHolder_T& iPriceHolder,
SellupFactorHolder_T& iSellupFactorHolder) {
-// assert (_rmolServiceContext != NULL);
-// const BucketHolder* oBucketHolder_ptr =
-// _rmolServiceContext->getBucketHolder();
-// assert (oBucketHolder_ptr != NULL);
- // TO-DO
- Forecaster::demandForecastByQForecasting (oForecastedDemandParameterList,
+ Forecaster::demandForecastByQForecasting (ioForecastedDemandParameterList,
iHistoricalDataHolderHolder,
iPriceHolder,
- iSellupFactorHolder);
-
- // Fill in the forecasted demand parameters
+ iSellupFactorHolder);
-
}
Property changes on: trunk/rmol/test
___________________________________________________________________
Modified: svn:ignore
- .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
+ .deps
.libs
Makefile
Makefile.in
optimise
simulate
sim.gnumeric
OptimiseTestSuite
OptimiseTestSuite.log
OptimiseTestSuite_results.xml
SimulateTestSuite
SimulateTestSuite_results.xml
rmol.log
ForecasterTestSuite
ForecasterTestSuite.log
ForecasterTestSuite_results.xml
Added: trunk/rmol/test/ForecasterTestSuite.cpp
===================================================================
--- trunk/rmol/test/ForecasterTestSuite.cpp (rev 0)
+++ trunk/rmol/test/ForecasterTestSuite.cpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -0,0 +1,162 @@
+// STL
+#include <sstream>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <vector>
+#include <cmath>
+// CPPUNIT
+#include <test/com/CppUnitCore.hpp>
+// RMOL
+#include <rmol/RMOL_Service.hpp>
+#include <rmol/RMOL_Types.hpp>
+#include <rmol/RMOL_FORECASTER_Types.hpp>
+// RMOL Test Suite
+#include <test/ForecasterTestSuite.hpp>
+
+// //////////////////////////////////////////////////////////////////////
+int testForecasterHelper (const unsigned short forecastingMethodFlag) {
+ int passedTests = 0;
+ try {
+
+ // Output log File
+ std::string lLogFilename ("ForecasterTestSuite.log");
+
+ // Methods of forecasting (0 = Q-Forecasting)
+ const unsigned short METHOD_FLAG = forecastingMethodFlag;
+
+ // Set the log parameters
+ std::ofstream logOutputFile;
+ // Open and clean the log outputfile
+ logOutputFile.open (lLogFilename.c_str());
+ logOutputFile.clear();
+ std::ostringstream oDebugStr;
+
+ // Initialise the RMOL service
+ RMOL::RMOL_Service rmolService (logOutputFile);
+
+ // A sample historical demand data to be processed by forecaster
+ // Class | Q | M | B | Y |
+ // Price | 100 | 200 | 300 | 400 |
+ // Historical uncensored demand data at a DCP
+ // | 10 | 5 | 0 | 0 | <- 2008/01/01
+ // | 0 | 10 | 0 | 0 | <- 2008/01/08
+ // | 0 | 12 | 0 | 0 | <- 2008/01/15
+ // | 0 | 0 | 5 | 2 | <- 2008/01/22
+ // The order of the vectors: M, Q, Y, B
+
+ // Sample historical data vector
+ RMOL::HistoricalDataHolderHolder_T lHistoricalDataHolderHolder;
+ std::vector<double> azeroVector(3,0); // 3 copies of 0 element
+ std::vector<double> sampleHistoricalDataHolder;
+ // Historical data of M class
+ sampleHistoricalDataHolder.push_back(5);
+ sampleHistoricalDataHolder.push_back(10);
+ sampleHistoricalDataHolder.push_back(12);
+ sampleHistoricalDataHolder.push_back(0);
+ lHistoricalDataHolderHolder.push_back(sampleHistoricalDataHolder);
+ // Historical data of Q class
+ sampleHistoricalDataHolder = azeroVector;
+ sampleHistoricalDataHolder.insert
+ (sampleHistoricalDataHolder.begin(), 1, 10);
+ lHistoricalDataHolderHolder.push_back(sampleHistoricalDataHolder);
+ // Historical data of Y class
+ sampleHistoricalDataHolder = azeroVector;
+ sampleHistoricalDataHolder.insert
+ (sampleHistoricalDataHolder.end(), 1, 2);
+ lHistoricalDataHolderHolder.push_back(sampleHistoricalDataHolder);
+ // Historical data of B class
+ sampleHistoricalDataHolder = azeroVector;
+ sampleHistoricalDataHolder.insert
+ (sampleHistoricalDataHolder.end(), 1, 5);
+ lHistoricalDataHolderHolder.push_back(sampleHistoricalDataHolder);
+
+ // Sample price vector
+ RMOL::PriceHolder_T lPriceVector;
+ lPriceVector.push_back(200);
+ lPriceVector.push_back(100);
+ lPriceVector.push_back(400);
+ lPriceVector.push_back(300);
+
+ // Sample Sellup Factor Vector
+ // that makes sell up probability of [Q,M,B,Y] = [1, 0.5, 0.4, 0.2]
+ RMOL::SellupFactorHolder_T lSellupFactorHolder;
+ lSellupFactorHolder.push_back(log(2));
+ lSellupFactorHolder.push_back(1);
+ lSellupFactorHolder.push_back(log(5)/3);
+ lSellupFactorHolder.push_back(log(2.5)/2);
+
+ // Forecaster output container
+ RMOL::ForecastedDemandParameterList_T lForecastedDemandParameterList;
+ switch (METHOD_FLAG) {
+
+ case 0 : // Calculate Q-equivalent demand
+ {
+ rmolService.demandForecastByQForecasting (lForecastedDemandParameterList,
+ lHistoricalDataHolderHolder,
+ lPriceVector,
+ lSellupFactorHolder);
+ // Verify the known mean is returned
+ oDebugStr << "Case 0: Tested Q-Forecasting algorithm for the given example\n"
+ << "Before the test, the flag is " << passedTests << "\n";
+ for (unsigned int k = 0; k < lForecastedDemandParameterList.size(); k++) {
+ std::vector<double> demandParametersOfAClass =
+ lForecastedDemandParameterList.at(k);
+ if (k == 1 && demandParametersOfAClass.at(0) == 10.8125) {passedTests = 1;};
+ }
+ oDebugStr << "After the test, the flag is " << passedTests << "\n";
+ break;
+ }
+ case 1 :
+ {
+ oDebugStr << "Case 1: Tested "
+ << "Before the test, the flag is " << passedTests << "\n";
+ //
+ oDebugStr << "After the test, the flag is " << passedTests << "\n";
+ break;
+ }
+
+
+ default :
+ {
+ rmolService.demandForecastByQForecasting (lForecastedDemandParameterList,
+ lHistoricalDataHolderHolder,
+ lPriceVector,
+ lSellupFactorHolder);
+ oDebugStr << "Default case Tested Q-Forecasting algorithm for the given example\n"
+ << "Before the test, the flag is " << passedTests << "\n";
+ for (unsigned int k = 0; k < lForecastedDemandParameterList.size(); k++) {
+ std::vector<double> demandParametersOfAClass =
+ lForecastedDemandParameterList.at(k);
+ if (k == 1 && demandParametersOfAClass.at(0) == 10.8125) {passedTests = 1;};
+ }
+ oDebugStr << "After the test, the flag is " << passedTests << "\n";
+ }
+ }
+ logOutputFile << oDebugStr.str() << "\n";
+ logOutputFile.close();
+
+ } catch (const std::exception& stde) {
+ std::cerr << "Standard exception: " << stde.what() << std::endl;
+
+ } catch (...) {
+ std::cerr << "Unknown exception" << std::endl;
+ }
+
+ return passedTests;
+}
+
+// //////////////////////////////////////////////////////////////////////
+void ForecasterTestSuite::testQForecaster() {
+ const int lTestSuccessFlag = testForecasterHelper(0);
+ CPPUNIT_ASSERT (lTestSuccessFlag == 1);
+}
+
+// //////////////////////////////////////////////////////////////////////
+ForecasterTestSuite::ForecasterTestSuite () {
+ _describeKey << "Running test on RMOL Forecast function";
+}
+
+// /////////////// M A I N /////////////////
+CPPUNIT_MAIN()
+
Added: trunk/rmol/test/ForecasterTestSuite.hpp
===================================================================
--- trunk/rmol/test/ForecasterTestSuite.hpp (rev 0)
+++ trunk/rmol/test/ForecasterTestSuite.hpp 2009-09-25 08:49:35 UTC (rev 258)
@@ -0,0 +1,22 @@
+// STL
+#include <sstream>
+// CPPUNIT
+#include <cppunit/extensions/HelperMacros.h>
+
+class ForecasterTestSuite : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE (ForecasterTestSuite);
+ CPPUNIT_TEST (testQForecaster);
+ CPPUNIT_TEST_SUITE_END ();
+public:
+
+ /** Test Q-forecaster. */
+ void testQForecaster();
+
+ /** Constructor. */
+ ForecasterTestSuite ();
+
+protected:
+ std::stringstream _describeKey;
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION (ForecasterTestSuite);
Modified: trunk/rmol/test/Makefile.am
===================================================================
--- trunk/rmol/test/Makefile.am 2009-09-22 08:47:08 UTC (rev 257)
+++ trunk/rmol/test/Makefile.am 2009-09-25 08:49:35 UTC (rev 258)
@@ -9,7 +9,7 @@
EXTRA_DIST = testLib.sh
##
-check_PROGRAMS = OptimiseTestSuite SimulateTestSuite
+check_PROGRAMS = OptimiseTestSuite SimulateTestSuite ForecasterTestSuite
TESTS = $(check_PROGRAMS)
XFAIL_TESTS = #IndexBuildingTestSuite
@@ -25,3 +25,10 @@
SimulateTestSuite_LDADD =
SimulateTestSuite_LDFLAGS = $(BOOST_LIBS) $(GSL_LIBS) $(CPPUNIT_LIBS) \
$(top_builddir)/test/com/libcppunitcore.la
+
+ForecasterTestSuite_SOURCES = ForecasterTestSuite.hpp ForecasterTestSuite.cpp
+ForecasterTestSuite_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS)
+ForecasterTestSuite_LDADD =
+ForecasterTestSuite_LDFLAGS = $(BOOST_LIBS) $(CPPUNIT_LIBS) \
+ $(top_builddir)/test/com/libcppunitcore.la \
+ $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-09-22 08:47:17
|
Revision: 257
http://rmol.svn.sourceforge.net/rmol/?rev=257&view=rev
Author: dkchoe
Date: 2009-09-22 08:47:08 +0000 (Tue, 22 Sep 2009)
Log Message:
-----------
[Q-Forecaster] Cleaned up the code (Replaced pointers with references)
Modified Paths:
--------------
trunk/rmol/rmol/bom/QForecaster.cpp
trunk/rmol/rmol/bom/QForecaster.hpp
trunk/rmol/rmol/command/Forecaster.cpp
trunk/rmol/rmol/command/Utilities.cpp
trunk/rmol/rmol/command/Utilities.hpp
Modified: trunk/rmol/rmol/bom/QForecaster.cpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-21 15:12:10 UTC (rev 256)
+++ trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-22 08:47:08 UTC (rev 257)
@@ -35,33 +35,34 @@
// //////////////////////////////////////////////////////////////////////
void QForecaster::calculateSellupProbability
- (SellupProbabilityVector_T* ioSellupProbabilityVector, double* iPtrQYield,
+ (SellupProbabilityVector_T& ioSellupProbabilityVector, double& iQYield,
PriceHolder_T& iPriceHolder, SellupFactorHolder_T& iSellupFactorHolder) {
- ioSellupProbabilityVector->clear();
+ ioSellupProbabilityVector.clear();
for (unsigned short j = 0; j < iPriceHolder.size(); j++){
const double lYield = iPriceHolder.at(j);
const double probSellup =
- exp(-iSellupFactorHolder.at(j) * lYield / (*iPtrQYield));
- ioSellupProbabilityVector->push_back(probSellup);
+ exp(-iSellupFactorHolder.at(j) * lYield / (iQYield));
+ ioSellupProbabilityVector.push_back(probSellup);
}
}
// //////////////////////////////////////////////////////////////////////
void QForecaster::calculateQEquivalentDemandParameters
- (QEquivalentDemandParameterHolder_T* ioQEquivalentDemandParameterHolder,
+ (QEquivalentDemandParameterHolder_T& ioQEquivalentDemandParameterHolder,
HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder,
- SellupProbabilityVector_T* lSellupProbabilityVector) {
+ SellupProbabilityVector_T& iSellupProbabilityVector) {
// 1. Calculate Q-equivalent demand parameters
// Initialize a holder for Q-equivalent Demands
- std::vector<double> aZeroVector (lSellupProbabilityVector->size(), 0);
- std::vector<double>& lQEquivalentDemandHolder = aZeroVector;
+ // std::vector<double> aZeroVector (iSellupProbabilityVector.size(), 0);
+ // std::vector<double>& lQEquivalentDemandHolder = aZeroVector;
+ std::vector<double> lQEquivalentDemandHolder;
for (unsigned int j = 0; j < iHistoricalDataHolderHolder.size(); j++) {
// Retrieve HistoricalDataHolder which are the data of the same product
// over different dates
std::vector<double>& lHistoricalDataHolder =
iHistoricalDataHolderHolder.at(j);
- double lSellupProbability = lSellupProbabilityVector->at(j);
+ double lSellupProbability = iSellupProbabilityVector.at(j);
// Apply sellup probability to historical data
Utilities::MultiplyAValueToAVector (lHistoricalDataHolder,
@@ -79,16 +80,16 @@
// //////////////////////////////////////////////////////////////////////
void QForecaster::partitionQEquivalentDemandParameters
- (ForecastedDemandParameterList_T oForecastedDemandParameterList,
- QEquivalentDemandParameterHolder_T* iQEquivalentDemandParameterHolder,
- SellupProbabilityVector_T* iSellupProbabilityVector) {
+ (ForecastedDemandParameterList_T& ioForecastedDemandParameterList,
+ QEquivalentDemandParameterHolder_T& iQEquivalentDemandParameterHolder,
+ SellupProbabilityVector_T& iSellupProbabilityVector) {
- unsigned int noOfClasses = iSellupProbabilityVector->size();
+ unsigned int noOfClasses = iSellupProbabilityVector.size();
// Sort sellup probabilities in increasing order and copy into a vector
std::vector<double> lSortedSellupProbabilityVector(noOfClasses);
- std::partial_sort_copy (iSellupProbabilityVector->begin(),
- iSellupProbabilityVector->end(),
+ std::partial_sort_copy (iSellupProbabilityVector.begin(),
+ iSellupProbabilityVector.end(),
lSortedSellupProbabilityVector.begin(),
lSortedSellupProbabilityVector.end());
@@ -100,13 +101,13 @@
lSellupProbabilityDifferenceVector.begin());
// Partition Q-equivalent demand mean and S.D. into each class
- oForecastedDemandParameterList.clear();
+ ioForecastedDemandParameterList.clear();
for (unsigned short k=0; k < noOfClasses; k++) {
// Locate the current sell-up probability in the sorted one
std::vector<double>::iterator pos =
std::lower_bound (lSortedSellupProbabilityVector.begin(),
lSortedSellupProbabilityVector.end(),
- iSellupProbabilityVector->at(k));
+ iSellupProbabilityVector.at(k));
int posOfCurrentSellupProbInSortedVector =
std::distance(lSortedSellupProbabilityVector.begin(), pos);
@@ -118,10 +119,10 @@
// Compute mean and S.D. of each class
// class mean = Q-eq mean * sell-up prob difference
// class S.D. = Q-eq S.D. * sell-up prob difference
- oForecastedDemandParameterList.push_back
- (*iQEquivalentDemandParameterHolder);
+ ioForecastedDemandParameterList.push_back
+ (iQEquivalentDemandParameterHolder);
std::vector<double>& forecastedDemandParameters =
- oForecastedDemandParameterList.at(k);
+ ioForecastedDemandParameterList.at(k);
Utilities::MultiplyAValueToAVector (forecastedDemandParameters,
correspondingSellupProbability);
}
Modified: trunk/rmol/rmol/bom/QForecaster.hpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-21 15:12:10 UTC (rev 256)
+++ trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-22 08:47:08 UTC (rev 257)
@@ -30,24 +30,24 @@
/** The same method as the above but taking price data directly
instead of through BucketHolder. */
- static void calculateSellupProbability (SellupProbabilityVector_T*,
- double* iPtrQYield,
+ static void calculateSellupProbability (SellupProbabilityVector_T&,
+ double& iQYield,
PriceHolder_T&,
SellupFactorHolder_T&);
/** Calculate Q-equivalent demand distribution parameters and
partition it to each class/bucket. */
static void calculateQEquivalentDemandParameters
- (QEquivalentDemandParameterHolder_T*,
+ (QEquivalentDemandParameterHolder_T&,
HistoricalDataHolderHolder_T&,
- SellupProbabilityVector_T*);
+ SellupProbabilityVector_T&);
/** Calculate Q-equivalent demand distribution parameters and
partition it to each class/bucket. */
static void partitionQEquivalentDemandParameters
- (ForecastedDemandParameterList_T,
- QEquivalentDemandParameterHolder_T*,
- SellupProbabilityVector_T*);
+ (ForecastedDemandParameterList_T&,
+ QEquivalentDemandParameterHolder_T&,
+ SellupProbabilityVector_T&);
};
}
Modified: trunk/rmol/rmol/command/Forecaster.cpp
===================================================================
--- trunk/rmol/rmol/command/Forecaster.cpp 2009-09-21 15:12:10 UTC (rev 256)
+++ trunk/rmol/rmol/command/Forecaster.cpp 2009-09-22 08:47:08 UTC (rev 257)
@@ -51,29 +51,29 @@
// E(alpha x Q)=alpha x mu_Q, S.D.(alpha x Q) = |alpha| X sigma_Q
// Find the class with the lowest yield
- double* ptrQYield;
- Utilities::getMinimumElement (ptrQYield, iPriceHolder);
+ double lQYield;
+ Utilities::getMinimumElement (lQYield, iPriceHolder);
// Initialize a holder for sell-up probabilities
- SellupProbabilityVector_T* lSellupProbabilityVector;
+ SellupProbabilityVector_T lSellupProbabilityVector;
// Compute sell-up probability for each class/bucket & store it in a vector
QForecaster::calculateSellupProbability
- (lSellupProbabilityVector, ptrQYield, iPriceHolder, iSellupFactorHolder);
+ (lSellupProbabilityVector, lQYield, iPriceHolder, iSellupFactorHolder);
// Initialize a holder for Q-equivalent Demand Parameters
- QEquivalentDemandParameterHolder_T* lQEquivalentDemandParameterHolder;
+ QEquivalentDemandParameterHolder_T lQEquivalentDemandParameterHolder;
// Calculate Q-equivalent demand distribution parameters.
QForecaster::calculateQEquivalentDemandParameters
- (lQEquivalentDemandParameterHolder, iHistoricalDataHolderHolder,
- lSellupProbabilityVector);
+ (lQEquivalentDemandParameterHolder, iHistoricalDataHolderHolder,
+ lSellupProbabilityVector);
// Calculate Q-equivalent demand distribution parameters and
// partition it to each class/bucket
- QForecaster::partitionQEquivalentDemandParameters
- (oForecastedDemandParameterList, lQEquivalentDemandParameterHolder,
- lSellupProbabilityVector);
+ //QForecaster::partitionQEquivalentDemandParameters
+ // (oForecastedDemandParameterList, lQEquivalentDemandParameterHolder,
+ // lSellupProbabilityVector);
}
}
Modified: trunk/rmol/rmol/command/Utilities.cpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.cpp 2009-09-21 15:12:10 UTC (rev 256)
+++ trunk/rmol/rmol/command/Utilities.cpp 2009-09-22 08:47:08 UTC (rev 257)
@@ -14,13 +14,13 @@
namespace RMOL {
// /////////////////////////////////////////////////////////////////////
- void Utilities::getMinimumElement (double* oMinValue,
+ void Utilities::getMinimumElement (double& oMinValue,
std::vector<double>& iVector) {
assert(!iVector.empty());
std::vector<double>::iterator pos = min_element (iVector.begin(),
iVector.end());
- *oMinValue = *pos;
+ oMinValue = *pos;
}
@@ -51,17 +51,17 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::getMeanAndStandardDeviation (std::vector<double>* ioMean_SD,
+ void Utilities::getMeanAndStandardDeviation (std::vector<double>& ioMean_SD,
std::vector<double>& iVector) {
const unsigned int lSize = iVector.size();
assert(lSize > 0);
- ioMean_SD->clear();
+ ioMean_SD.clear();
// Mean
double lSum = std::accumulate(iVector.begin(), iVector.end(), 0);
double lMean = lSum/lSize;
- ioMean_SD->push_back(lMean);
+ ioMean_SD.push_back(lMean);
//Standard Deviation
double lSD = 0;
@@ -70,7 +70,7 @@
lSD += lDeviation * lDeviation;
}
lSD /= (lSize - 1);
- ioMean_SD->push_back(sqrt(lSD));
+ ioMean_SD.push_back(sqrt(lSD));
}
// /////////////////////////////////////////////////////////////////////
Modified: trunk/rmol/rmol/command/Utilities.hpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.hpp 2009-09-21 15:12:10 UTC (rev 256)
+++ trunk/rmol/rmol/command/Utilities.hpp 2009-09-22 08:47:08 UTC (rev 257)
@@ -11,7 +11,7 @@
struct Utilities {
/** Returns the minimum element of a given vector*/
- static void getMinimumElement (double* oMinValue, std::vector<double>&);
+ static void getMinimumElement (double& oMinValue, std::vector<double>&);
/** Return mean for the given elements of a vector. */
static void getMean (double& oMean, std::vector<double>&);
@@ -22,7 +22,7 @@
double& iMean);
/** Return mean & standard deviation for given elements of a vector. */
- static void getMeanAndStandardDeviation (std::vector<double>* ioMean_SD,
+ static void getMeanAndStandardDeviation (std::vector<double>& ioMean_SD,
std::vector<double>&);
/** Return the input vector after adding a value. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-09-21 15:12:16
|
Revision: 256
http://rmol.svn.sourceforge.net/rmol/?rev=256&view=rev
Author: dkchoe
Date: 2009-09-21 15:12:10 +0000 (Mon, 21 Sep 2009)
Log Message:
-----------
[Q-Forecaster] Added a function that partitions Q-eq demand to each class
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
trunk/rmol/rmol/bom/QForecaster.cpp
Modified: trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-18 16:10:41 UTC (rev 255)
+++ trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-21 15:12:10 UTC (rev 256)
@@ -12,15 +12,15 @@
// //////// Type definitions /////////
- /** Define the map of a class code - segment (origine/destination)
- and a vector of (unconstrained) demand of the similar flight-dates. */
- typedef std::map<std::string, std::vector<double> >
- SimilarFlightsDemandList_T;
+ // /** Define the map of a class code - segment (origine/destination)
+ // and a vector of (unconstrained) demand of the similar flight-dates. */
+ // typedef std::map<std::string, std::vector<double> >
+ // SimilarFlightsDemandList_T;
/** Define the holder of forecasted demand parameters (mean, std. deviation)
per booking class. The order of the parameters corresponds to the vector
inputs resulted the parameters themselves.*/
- typedef std::vector<double> ForecastedDemandParameterList_T;
+ typedef std::vector< std::vector<double> > ForecastedDemandParameterList_T;
/** Define a vector of fares. */
typedef std::vector<double> PriceHolder_T;
Modified: trunk/rmol/rmol/bom/QForecaster.cpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-18 16:10:41 UTC (rev 255)
+++ trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-21 15:12:10 UTC (rev 256)
@@ -3,6 +3,8 @@
// //////////////////////////////////////////////////////////////////////
// STL
#include <cmath>
+#include <algorithm>
+#include <numeric>
// RMOL Bom
#include <rmol/bom/Bucket.hpp>
#include <rmol/bom/BucketHolder.hpp>
@@ -77,11 +79,52 @@
// //////////////////////////////////////////////////////////////////////
void QForecaster::partitionQEquivalentDemandParameters
- (ForecastedDemandParameterList_T,
- QEquivalentDemandParameterHolder_T*,
- SellupProbabilityVector_T*) {
-
+ (ForecastedDemandParameterList_T oForecastedDemandParameterList,
+ QEquivalentDemandParameterHolder_T* iQEquivalentDemandParameterHolder,
+ SellupProbabilityVector_T* iSellupProbabilityVector) {
+ unsigned int noOfClasses = iSellupProbabilityVector->size();
+
+ // Sort sellup probabilities in increasing order and copy into a vector
+ std::vector<double> lSortedSellupProbabilityVector(noOfClasses);
+ std::partial_sort_copy (iSellupProbabilityVector->begin(),
+ iSellupProbabilityVector->end(),
+ lSortedSellupProbabilityVector.begin(),
+ lSortedSellupProbabilityVector.end());
+
+ // Compute the probability to sell-up to class i but not i-1 (class
+ // with the next higher fare) and copy into a vector
+ std::vector<double> lSellupProbabilityDifferenceVector(noOfClasses);
+ adjacent_difference (lSortedSellupProbabilityVector.begin(),
+ lSortedSellupProbabilityVector.end(),
+ lSellupProbabilityDifferenceVector.begin());
+
+ // Partition Q-equivalent demand mean and S.D. into each class
+ oForecastedDemandParameterList.clear();
+ for (unsigned short k=0; k < noOfClasses; k++) {
+ // Locate the current sell-up probability in the sorted one
+ std::vector<double>::iterator pos =
+ std::lower_bound (lSortedSellupProbabilityVector.begin(),
+ lSortedSellupProbabilityVector.end(),
+ iSellupProbabilityVector->at(k));
+ int posOfCurrentSellupProbInSortedVector =
+ std::distance(lSortedSellupProbabilityVector.begin(), pos);
+
+ // Find the corresponding sell-up probability difference
+ double correspondingSellupProbability =
+ lSellupProbabilityDifferenceVector.at(
+ posOfCurrentSellupProbInSortedVector);
+
+ // Compute mean and S.D. of each class
+ // class mean = Q-eq mean * sell-up prob difference
+ // class S.D. = Q-eq S.D. * sell-up prob difference
+ oForecastedDemandParameterList.push_back
+ (*iQEquivalentDemandParameterHolder);
+ std::vector<double>& forecastedDemandParameters =
+ oForecastedDemandParameterList.at(k);
+ Utilities::MultiplyAValueToAVector (forecastedDemandParameters,
+ correspondingSellupProbability);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-09-18 16:10:49
|
Revision: 255
http://rmol.svn.sourceforge.net/rmol/?rev=255&view=rev
Author: dkchoe
Date: 2009-09-18 16:10:41 +0000 (Fri, 18 Sep 2009)
Log Message:
-----------
Methods that compute Q-equivalent demand distribution parameters have been added. Partition to each classes are to be done; Methods that compute Q-equivalent demand distribution parameters have been added. Partition to each classes are to be done.
Modified Paths:
--------------
trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
trunk/rmol/rmol/RMOL_Types.hpp
trunk/rmol/rmol/bom/QForecaster.cpp
trunk/rmol/rmol/bom/QForecaster.hpp
trunk/rmol/rmol/command/Forecaster.cpp
trunk/rmol/rmol/command/Forecaster.hpp
trunk/rmol/rmol/command/Utilities.cpp
trunk/rmol/rmol/command/Utilities.hpp
Modified: trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -30,6 +30,9 @@
/** Define vector of historical data vector*/
typedef std::vector< std::vector<double> > HistoricalDataHolderHolder_T;
+
+ /** Define a holder for Q-equivalent demand parameters. */
+ typedef std::vector<double> QEquivalentDemandParameterHolder_T;
}
#endif // __RMOL_RMOL_FORECASTER_TYPES_HPP
Modified: trunk/rmol/rmol/RMOL_Types.hpp
===================================================================
--- trunk/rmol/rmol/RMOL_Types.hpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/RMOL_Types.hpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -88,8 +88,8 @@
// typedef std::vector<HistoricalBookingHolder>
// HistoricalBookingHolderHolder_T;
- /** Define the holder of Q-equivalent booking values*/
- typedef std::vector<double> HolderOfQEquivalentBookingsPerSimilarFlight_T;
+ // /** Define the holder of Q-equivalent booking values*/
+ // typedef std::vector<double> HolderOfQEquivalentBookingsPerSimilarFlight_T;
}
#endif // __RMOL_RMOL_TYPES_HPP
Modified: trunk/rmol/rmol/bom/QForecaster.cpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -11,63 +11,78 @@
namespace RMOL {
- // //////////////////////////////////////////////////////////////////////
- void QForecaster::calculateSellupProbability
- (BucketHolder& iBucketHolder,
- const double iQYield,
- const SellupFactorHolder_T& iSellupFactorHolder,
- SellupProbabilityVector_T& ioSellupProbabilityVector) {
- // Compute sell-up probability for each bucket and store it in a vector
- short j = 0;
- for (iBucketHolder.begin();
- iBucketHolder.hasNotReachedEnd();
- iBucketHolder.iterate()) {
- Bucket& lCurrentBucket = iBucketHolder.getCurrentBucket();
- const double lYield = lCurrentBucket.getAverageYield();
- const double probSellup =
- exp(-iSellupFactorHolder.at(j) *lYield/iQYield);
- ioSellupProbabilityVector.push_back(probSellup);
- j++;
- }
- }
+ // // //////////////////////////////////////////////////////////////////////
+ // void QForecaster::calculateSellupProbability
+ // (BucketHolder& iBucketHolder,
+ // const double iQYield,
+ // const SellupFactorHolder_T& iSellupFactorHolder,
+ // SellupProbabilityVector_T& ioSellupProbabilityVector) {
+ // // Compute sell-up probability for each bucket and store it in a vector
+ // short j = 0;
+ // for (iBucketHolder.begin();
+ // iBucketHolder.hasNotReachedEnd();
+ // iBucketHolder.iterate()) {
+ // Bucket& lCurrentBucket = iBucketHolder.getCurrentBucket();
+ // const double lYield = lCurrentBucket.getAverageYield();
+ // const double probSellup =
+ // exp(-iSellupFactorHolder.at(j) *lYield/iQYield);
+ // ioSellupProbabilityVector.push_back(probSellup);
+ // j++;
+ // }
+ // }
// //////////////////////////////////////////////////////////////////////
void QForecaster::calculateSellupProbability
- (SellupProbabilityVector_T& ioSellupProbabilityVector, const double iQYield,
+ (SellupProbabilityVector_T* ioSellupProbabilityVector, double* iPtrQYield,
PriceHolder_T& iPriceHolder, SellupFactorHolder_T& iSellupFactorHolder) {
- ioSellupProbabilityVector.clear();
- for (unsigned short j=0; j < iPriceHolder.size(); j++){
+ ioSellupProbabilityVector->clear();
+ for (unsigned short j = 0; j < iPriceHolder.size(); j++){
const double lYield = iPriceHolder.at(j);
const double probSellup =
- exp(-iSellupFactorHolder.at(j) *lYield/iQYield);
- ioSellupProbabilityVector.push_back(probSellup);
+ exp(-iSellupFactorHolder.at(j) * lYield / (*iPtrQYield));
+ ioSellupProbabilityVector->push_back(probSellup);
}
}
// //////////////////////////////////////////////////////////////////////
- void QForecaster::calculateQEquivalentDemandParametersAndPartition
- (ForecastedDemandParameterList_T oForecastedDemandParameterList,
+ void QForecaster::calculateQEquivalentDemandParameters
+ (QEquivalentDemandParameterHolder_T* ioQEquivalentDemandParameterHolder,
HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder,
- SellupProbabilityVector_T& lSellupProbabilityVector) {
+ SellupProbabilityVector_T* lSellupProbabilityVector) {
// 1. Calculate Q-equivalent demand parameters
// Initialize a holder for Q-equivalent Demands
- std::vector<double> lQEquivalentDemandHolder
- (lSellupProbabilityVector.size(), 0);
+ std::vector<double> aZeroVector (lSellupProbabilityVector->size(), 0);
+ std::vector<double>& lQEquivalentDemandHolder = aZeroVector;
for (unsigned int j = 0; j < iHistoricalDataHolderHolder.size(); j++) {
// Retrieve HistoricalDataHolder which are the data of the same product
// over different dates
std::vector<double>& lHistoricalDataHolder =
iHistoricalDataHolderHolder.at(j);
- double lSellupProbability = lSellupProbabilityVector.at(j);
+ double lSellupProbability = lSellupProbabilityVector->at(j);
+
+ // Apply sellup probability to historical data
Utilities::MultiplyAValueToAVector (lHistoricalDataHolder,
1/lSellupProbability);
- // TODO: Collect historical data by date
- Utilities::AddTwoVectors(lQEquivalentDemandHolder, lHistoricalDataHolder);
+
+ // Collect historical data by date
+ Utilities::AddTwoVectors (lQEquivalentDemandHolder,
+ lHistoricalDataHolder);
}
- // 2. Partition the Q-eq demand to each class/bucket
+ // 2. Compute Q-equivalent demand mean and standard deviation
+ Utilities::getMeanAndStandardDeviation (ioQEquivalentDemandParameterHolder,
+ lQEquivalentDemandHolder);
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void QForecaster::partitionQEquivalentDemandParameters
+ (ForecastedDemandParameterList_T,
+ QEquivalentDemandParameterHolder_T*,
+ SellupProbabilityVector_T*) {
+
}
+
}
Modified: trunk/rmol/rmol/bom/QForecaster.hpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -18,30 +18,37 @@
public:
- /** Calculate sell-up probability for given sell-up factor,
- and yield ratio between the sell-up occurs.<br>
- The formular was proposed by Belobaba and Hopperstad:
- Algorithms for Revenue Management in Unrestricted Fare Markets,
- AGIFORS, Auckland, New Zealand, Jan 2004 */
- static void calculateSellupProbability (BucketHolder&,
- const double iQYield,
- const SellupFactorHolder_T&,
- SellupProbabilityVector_T&);
+ // /** Calculate sell-up probability for given sell-up factor,
+ // and yield ratio between the sell-up occurs.<br>
+ // The formular was proposed by Belobaba and Hopperstad:
+ // Algorithms for Revenue Management in Unrestricted Fare Markets,
+ // AGIFORS, Auckland, New Zealand, Jan 2004 */
+ // static void calculateSellupProbability (BucketHolder&,
+ // const double iQYield,
+ // const SellupFactorHolder_T&,
+ // SellupProbabilityVector_T&);
/** The same method as the above but taking price data directly
instead of through BucketHolder. */
- static void calculateSellupProbability (SellupProbabilityVector_T&,
- const double iQYield,
+ static void calculateSellupProbability (SellupProbabilityVector_T*,
+ double* iPtrQYield,
PriceHolder_T&,
SellupFactorHolder_T&);
/** Calculate Q-equivalent demand distribution parameters and
partition it to each class/bucket. */
- static void calculateQEquivalentDemandParametersAndPartition
- (ForecastedDemandParameterList_T,
- HistoricalDataHolderHolder_T&,
- SellupProbabilityVector_T&);
+ static void calculateQEquivalentDemandParameters
+ (QEquivalentDemandParameterHolder_T*,
+ HistoricalDataHolderHolder_T&,
+ SellupProbabilityVector_T*);
+ /** Calculate Q-equivalent demand distribution parameters and
+ partition it to each class/bucket. */
+ static void partitionQEquivalentDemandParameters
+ (ForecastedDemandParameterList_T,
+ QEquivalentDemandParameterHolder_T*,
+ SellupProbabilityVector_T*);
+
};
}
#endif // __RMOL_BOM_QFORECASTER_HPP
Modified: trunk/rmol/rmol/command/Forecaster.cpp
===================================================================
--- trunk/rmol/rmol/command/Forecaster.cpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/command/Forecaster.cpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -14,30 +14,30 @@
namespace RMOL {
- // //////////////////////////////////////////////////////////////////////
- void Forecaster::qEquivalentBookingCalculation
- (BucketHolder& ioBucketHolder,
- SellupFactorHolder_T& iSellupFactorHolder,
- HistoricalBookingHolderHolder& iHistoricalBookingHolderHolder,
- HolderOfQEquivalentBookingsPerSimilarFlight_T&
- oQEquivalentBookingsPerSimilarFlight){
+ // // //////////////////////////////////////////////////////////////////////
+ // void Forecaster::qEquivalentBookingCalculation
+ // (BucketHolder& ioBucketHolder,
+ // SellupFactorHolder_T& iSellupFactorHolder,
+ // HistoricalBookingHolderHolder& iHistoricalBookingHolderHolder,
+ // HolderOfQEquivalentBookingsPerSimilarFlight_T&
+ // oQEquivalentBookingsPerSimilarFlight){
- // Get the lowest yield of the given buckets
- const double qYield = ioBucketHolder.getLowestAverageYield ();
+ // // Get the lowest yield of the given buckets
+ // const double qYield = ioBucketHolder.getLowestAverageYield ();
- // Initialize a vector for sell-up probabilities
- std::vector<double> lSellupProbabilityVector;
+ // // Initialize a vector for sell-up probabilities
+ // std::vector<double> lSellupProbabilityVector;
- // Compute sell-up probability for each bucket and store it in a vector
- QForecaster::calculateSellupProbability
- (ioBucketHolder, qYield, iSellupFactorHolder, lSellupProbabilityVector);
+ // // Compute sell-up probability for each bucket and store it in a vector
+ // QForecaster::calculateSellupProbability
+ // (ioBucketHolder, qYield, iSellupFactorHolder, lSellupProbabilityVector);
- // Compute total Q-equivalent bookings
- // QEquivalentBookingCalculator::calculateQEquivalentBooking
- // (iHistoricalBookingHolderHolder,
- // lSellupProbabilityVector,
- // oQEquivalentBookingsPerSimilarFlight);
- }
+ // // Compute total Q-equivalent bookings
+ // // QEquivalentBookingCalculator::calculateQEquivalentBooking
+ // // (iHistoricalBookingHolderHolder,
+ // // lSellupProbabilityVector,
+ // // oQEquivalentBookingsPerSimilarFlight);
+ // }
// //////////////////////////////////////////////////////////////////////
void Forecaster::demandForecastByQForecasting
@@ -51,21 +51,29 @@
// E(alpha x Q)=alpha x mu_Q, S.D.(alpha x Q) = |alpha| X sigma_Q
// Find the class with the lowest yield
- double lQYield;
- Utilities::getMinimumElement (lQYield, iPriceHolder);
+ double* ptrQYield;
+ Utilities::getMinimumElement (ptrQYield, iPriceHolder);
- // Initialize a vector for sell-up probabilities
- std::vector<double> lSellupProbabilityVector;
+ // Initialize a holder for sell-up probabilities
+ SellupProbabilityVector_T* lSellupProbabilityVector;
// Compute sell-up probability for each class/bucket & store it in a vector
QForecaster::calculateSellupProbability
- (lSellupProbabilityVector, lQYield, iPriceHolder, iSellupFactorHolder);
+ (lSellupProbabilityVector, ptrQYield, iPriceHolder, iSellupFactorHolder);
+ // Initialize a holder for Q-equivalent Demand Parameters
+ QEquivalentDemandParameterHolder_T* lQEquivalentDemandParameterHolder;
+
+ // Calculate Q-equivalent demand distribution parameters.
+ QForecaster::calculateQEquivalentDemandParameters
+ (lQEquivalentDemandParameterHolder, iHistoricalDataHolderHolder,
+ lSellupProbabilityVector);
+
// Calculate Q-equivalent demand distribution parameters and
// partition it to each class/bucket
- QForecaster::calculateQEquivalentDemandParametersAndPartition
- (oForecastedDemandParameterList,
- iHistoricalDataHolderHolder, lSellupProbabilityVector);
+ QForecaster::partitionQEquivalentDemandParameters
+ (oForecastedDemandParameterList, lQEquivalentDemandParameterHolder,
+ lSellupProbabilityVector);
}
}
Modified: trunk/rmol/rmol/command/Forecaster.hpp
===================================================================
--- trunk/rmol/rmol/command/Forecaster.hpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/command/Forecaster.hpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -11,54 +11,53 @@
namespace RMOL {
/** Forward declarations. */
- class BucketHolder;
- struct HistoricalBookingHolderHolder;
- // class StudyStatManager;
+ // // class BucketHolder;
+ // // struct HistoricalBookingHolderHolder;
/** Class wrapping the principal forecasting algorithms and
some accessory algorithms for demand forecasting. */
class Forecaster {
public:
- /**
- An accessory algorithm for demand forecasting.
+ // // /**
+ // // An accessory algorithm for demand forecasting.
- Calculate Q-equivalent bookings for the given group of
- classes/buckets/fare points using the given
- sell-up factors.
+ // // Calculate Q-equivalent bookings for the given group of
+ // // classes/buckets/fare points using the given
+ // // sell-up factors.
- Q-equivalent bookings are, by definition,
+ // // Q-equivalent bookings are, by definition,
- SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i}
- where
- ProbSellup_{bucket i} =
- EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets}))
- */
- static void qEquivalentBookingCalculation
- (BucketHolder&,
- SellupFactorHolder_T&,
- HistoricalBookingHolderHolder&,
- HolderOfQEquivalentBookingsPerSimilarFlight_T&);
+ // // SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i}
+ // // where
+ // // ProbSellup_{bucket i} =
+ // // EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets}))
+ // // */
+ // // static void qEquivalentBookingCalculation
+ // // (BucketHolder&,
+ // // SellupFactorHolder_T&,
+ // // HistoricalBookingHolderHolder&,
+ // // HolderOfQEquivalentBookingsPerSimilarFlight_T&);
- /**
- An accessory algorithm for demand forecasting.
+ // /**
+ // An accessory algorithm for demand forecasting.
- Calculate Q-equivalent demands for the given group of
- classes/buckets/fare points using the given
- sell-up factors.
+ // Calculate Q-equivalent demands for the given group of
+ // classes/buckets/fare points using the given
+ // sell-up factors.
- Q-equivalent demands are, by definition,
+ // Q-equivalent demands are, by definition,
- SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i}
- where
- ProbSellup_{bucket i} =
- EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets}))
+ // SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i}
+ // where
+ // ProbSellup_{bucket i} =
+ // EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets}))
- static void qEquivalentDemandCalculation
- (SellupFactorHolder_T&,
- HistoricalDataHolderHolder&,
- HolderOfQEquivalentDemandsPerSimilarFlight_T&);
- */
+ // static void qEquivalentDemandCalculation
+ // (SellupFactorHolder_T&,
+ // HistoricalDataHolderHolder&,
+ // HolderOfQEquivalentDemandsPerSimilarFlight_T&);
+ // */
/** A forecasting method developed by Belobaba and Hopperstad:
Algorithms for Revenue Management in Unrestricted Fare Markets,
Modified: trunk/rmol/rmol/command/Utilities.cpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.cpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/command/Utilities.cpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -7,24 +7,25 @@
#include <numeric>
#include <math.h>
#include <assert.h>
+#include <functional>
// RMOL
#include <rmol/command/Utilities.hpp>
namespace RMOL {
// /////////////////////////////////////////////////////////////////////
- void Utilities::getMinimumElement (double oMinValue,
+ void Utilities::getMinimumElement (double* oMinValue,
std::vector<double>& iVector) {
assert(!iVector.empty());
std::vector<double>::iterator pos = min_element (iVector.begin(),
iVector.end());
- oMinValue = *pos;
+ *oMinValue = *pos;
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::getMean (double oMean, std::vector<double>& iVector) {
+ void Utilities::getMean (double& oMean, std::vector<double>& iVector) {
assert(!iVector.empty());
double lSum = std::accumulate(iVector.begin(), iVector.end(),0);
oMean = lSum/iVector.size();
@@ -32,8 +33,9 @@
}
// /////////////////////////////////////////////////////////////////////
- void Utilities::getStandardDeviation (double oSD, std::vector<double>& iVector,
- double iMean) {
+ void Utilities::getStandardDeviation (double& oSD,
+ std::vector<double>& iVector,
+ double& iMean) {
assert(iMean > 0);
const unsigned int lSize = iVector.size();
@@ -49,8 +51,31 @@
}
// /////////////////////////////////////////////////////////////////////
+ void Utilities::getMeanAndStandardDeviation (std::vector<double>* ioMean_SD,
+ std::vector<double>& iVector) {
+ const unsigned int lSize = iVector.size();
+ assert(lSize > 0);
+
+ ioMean_SD->clear();
+
+ // Mean
+ double lSum = std::accumulate(iVector.begin(), iVector.end(), 0);
+ double lMean = lSum/lSize;
+ ioMean_SD->push_back(lMean);
+
+ //Standard Deviation
+ double lSD = 0;
+ for (unsigned int j = 0; j < lSize; j++) {
+ const double lDeviation = iVector.at(j);
+ lSD += lDeviation * lDeviation;
+ }
+ lSD /= (lSize - 1);
+ ioMean_SD->push_back(sqrt(lSD));
+ }
+
+ // /////////////////////////////////////////////////////////////////////
void Utilities::AddAValueToAVector (std::vector<double>& ioVector,
- double iValue){
+ double iValue){
const unsigned int lSize = ioVector.size();
assert(lSize > 0);
@@ -71,10 +96,12 @@
}
// /////////////////////////////////////////////////////////////////////
- static void AddTwoVectors (std::vector<double>& ioVector,
+ void Utilities::AddTwoVectors (std::vector<double>& ioVector,
std::vector<double>& iVector) {
- // std::transform (ioVector.begin(), ioVector.end(), iVector.begin(), iVector.end(),)
+ std::transform (ioVector.begin(), ioVector.end(),
+ iVector.begin(),
+ ioVector.begin(),
+ std::plus<double>());
}
-
}
Modified: trunk/rmol/rmol/command/Utilities.hpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.hpp 2009-09-17 16:30:38 UTC (rev 254)
+++ trunk/rmol/rmol/command/Utilities.hpp 2009-09-18 16:10:41 UTC (rev 255)
@@ -11,16 +11,20 @@
struct Utilities {
/** Returns the minimum element of a given vector*/
- static void getMinimumElement (double oMinValue, std::vector<double>&);
+ static void getMinimumElement (double* oMinValue, std::vector<double>&);
/** Return mean for the given elements of a vector. */
- static void getMean (double oMean, std::vector<double>&);
+ static void getMean (double& oMean, std::vector<double>&);
/** Return standard deviation for the given elements of a vector and
- the precomputed mean. */
- static void getStandardDeviation (double oSD, std::vector<double>&,
- double iMean);
+ precomputed mean. */
+ static void getStandardDeviation (double& oSD, std::vector<double>&,
+ double& iMean);
+ /** Return mean & standard deviation for given elements of a vector. */
+ static void getMeanAndStandardDeviation (std::vector<double>* ioMean_SD,
+ std::vector<double>&);
+
/** Return the input vector after adding a value. */
static void AddAValueToAVector (std::vector<double>& ioVector,
double iValue);
@@ -29,7 +33,7 @@
static void MultiplyAValueToAVector (std::vector<double>& ioVector,
double iValue);
- /** Return an input vector after adding the other input vector. */
+ /** Return first input vector after adding 2nd input vector to it. */
static void AddTwoVectors (std::vector<double>& ioVector,
std::vector<double>& iVector);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-09-17 16:30:45
|
Revision: 254
http://rmol.svn.sourceforge.net/rmol/?rev=254&view=rev
Author: denis_arnaud
Date: 2009-09-17 16:30:38 +0000 (Thu, 17 Sep 2009)
Log Message:
-----------
[Branch 0.23.0] Deleted the deprecated/temporary 0.23.0 release branch corresponding to Ticket #1 (corresponding updates have been integrated within the main branch and within the trunk).
Removed Paths:
-------------
branches/rmol/0.23.0/Ticket_1_01/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-09-17 16:29:00
|
Revision: 253
http://rmol.svn.sourceforge.net/rmol/?rev=253&view=rev
Author: denis_arnaud
Date: 2009-09-17 16:28:51 +0000 (Thu, 17 Sep 2009)
Log Message:
-----------
[Branch 0.23.0] Retrofitted the patch for Ticket #1, so that the RPM can be generated.
Modified Paths:
--------------
branches/rmol/0.23.0/main/rmol/bom/sources.mk
Property Changed:
----------------
branches/rmol/0.23.0/main/
branches/rmol/0.23.0/main/rmol/RMOL_Service.hpp
branches/rmol/0.23.0/main/rmol/RMOL_Types.hpp
branches/rmol/0.23.0/main/rmol/batches/rmol.cpp
branches/rmol/0.23.0/main/rmol/core/sources.mk
branches/rmol/0.23.0/main/rmol/factory/FacBomAbstract.cpp
branches/rmol/0.23.0/main/rmol/factory/FacBomAbstract.hpp
branches/rmol/0.23.0/main/rmol/factory/FacRmolServiceContext.cpp
branches/rmol/0.23.0/main/rmol/factory/FacRmolServiceContext.hpp
branches/rmol/0.23.0/main/rmol/service/RMOL_Service.cpp
branches/rmol/0.23.0/main/rmol/service/RMOL_ServiceContext.cpp
branches/rmol/0.23.0/main/rmol/service/RMOL_ServiceContext.hpp
branches/rmol/0.23.0/main/samples/
branches/rmol/0.23.0/main/test/OptimiseTestSuite.cpp
branches/rmol/0.23.0/main/test/SimulateTestSuite.cpp
Property changes on: branches/rmol/0.23.0/main
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/rmol/0.23.0/Ticket_1_01:250
Property changes on: branches/rmol/0.23.0/main/rmol/RMOL_Service.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/RMOL_Types.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/batches/rmol.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Modified: branches/rmol/0.23.0/main/rmol/bom/sources.mk
===================================================================
--- branches/rmol/0.23.0/main/rmol/bom/sources.mk 2009-09-17 16:27:06 UTC (rev 252)
+++ branches/rmol/0.23.0/main/rmol/bom/sources.mk 2009-09-17 16:28:51 UTC (rev 253)
@@ -22,6 +22,9 @@
$(top_srcdir)/rmol/bom/StatAggregatorStruct.hpp \
$(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \
$(top_srcdir)/rmol/bom/StudyStatManager.hpp \
+ $(top_srcdir)/rmol/bom/HistoricalBooking.hpp \
+ $(top_srcdir)/rmol/bom/HistoricalBookingHolder.hpp \
+ $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.hpp \
$(top_srcdir)/rmol/bom/SellupProbabilityCalculator.hpp \
$(top_srcdir)/rmol/bom/QEquivalentBookingCalculator.hpp
bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \
Property changes on: branches/rmol/0.23.0/main/rmol/core/sources.mk
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/factory/FacBomAbstract.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/factory/FacBomAbstract.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/factory/FacRmolServiceContext.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/factory/FacRmolServiceContext.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/service/RMOL_Service.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/service/RMOL_ServiceContext.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/rmol/service/RMOL_ServiceContext.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/samples
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/test/OptimiseTestSuite.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: branches/rmol/0.23.0/main/test/SimulateTestSuite.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <den...@us...> - 2009-09-17 16:27:16
|
Revision: 252
http://rmol.svn.sourceforge.net/rmol/?rev=252&view=rev
Author: denis_arnaud
Date: 2009-09-17 16:27:06 +0000 (Thu, 17 Sep 2009)
Log Message:
-----------
[Dev] Fixed the bom/source.mk file, so that a tar-ball can be generated.
Modified Paths:
--------------
trunk/rmol/rmol/bom/sources.mk
Property Changed:
----------------
trunk/rmol/
trunk/rmol/rmol/RMOL_Service.hpp
trunk/rmol/rmol/RMOL_Types.hpp
trunk/rmol/rmol/batches/rmol.cpp
trunk/rmol/rmol/core/sources.mk
trunk/rmol/rmol/factory/FacBomAbstract.cpp
trunk/rmol/rmol/factory/FacBomAbstract.hpp
trunk/rmol/rmol/factory/FacRmolServiceContext.cpp
trunk/rmol/rmol/factory/FacRmolServiceContext.hpp
trunk/rmol/rmol/service/RMOL_Service.cpp
trunk/rmol/rmol/service/RMOL_ServiceContext.cpp
trunk/rmol/rmol/service/RMOL_ServiceContext.hpp
trunk/rmol/samples/
trunk/rmol/test/OptimiseTestSuite.cpp
trunk/rmol/test/SimulateTestSuite.cpp
Property changes on: trunk/rmol
___________________________________________________________________
Modified: svn:ignore
- autom4te.cache
INSTALL
Makefile
Makefile.in
aclocal.m4
config.log
config.status
configure
libtool
rmol-config
rmol-doc-0.*.0.tar.bz2
rmol-doc-0.*.0.tar.gz
rmol.pc
rmol.m4
rmol.spec
config.guess
config.h
config.h.in
config.sub
configure.log
rmol-0.*.0.tar.bz2
rmol-0.*.0.tar.gz
stamp-h1
autogen-quan.sh
+ autom4te.cache
INSTALL
Makefile
Makefile.in
aclocal.m4
config.log
config.status
configure
libtool
rmol-config
rmol-doc-0.*.0.tar.*
rmol-doc-99.99.99.tar.*
rmol.pc
rmol.m4
rmol.spec
config.guess
config.h
config.h.in
config.sub
configure.log
rmol-0.*.0.tar.*
rmol-99.99.99.tar.*
stamp-h1
autogen-quan.sh
Added: svn:mergeinfo
+ /branches/rmol/0.23.0/Ticket_1_01:250
Property changes on: trunk/rmol/rmol/RMOL_Service.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/RMOL_Types.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/batches/rmol.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Modified: trunk/rmol/rmol/bom/sources.mk
===================================================================
--- trunk/rmol/rmol/bom/sources.mk 2009-09-17 16:05:07 UTC (rev 251)
+++ trunk/rmol/rmol/bom/sources.mk 2009-09-17 16:27:06 UTC (rev 252)
@@ -22,7 +22,10 @@
$(top_srcdir)/rmol/bom/StatAggregatorStruct.hpp \
$(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \
$(top_srcdir)/rmol/bom/StudyStatManager.hpp \
- $(top_srcdir)/rmol/bom/QForecaster.hpp
+ $(top_srcdir)/rmol/bom/HistoricalBooking.hpp \
+ $(top_srcdir)/rmol/bom/HistoricalBookingHolder.hpp \
+ $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.hpp \
+ $(top_srcdir)/rmol/bom/QForecaster.hpp
bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \
$(top_srcdir)/rmol/bom/Bucket.cpp \
$(top_srcdir)/rmol/bom/BucketHolder.cpp \
@@ -40,4 +43,4 @@
$(top_srcdir)/rmol/bom/MAForecast.cpp \
$(top_srcdir)/rmol/bom/StatAggregatorStruct.cpp \
$(top_srcdir)/rmol/bom/StudyStatManager.cpp \
- $(top_srcdir)/rmol/bom/QForecaster.cpp
\ No newline at end of file
+ $(top_srcdir)/rmol/bom/QForecaster.cpp
Property changes on: trunk/rmol/rmol/core/sources.mk
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/factory/FacBomAbstract.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/factory/FacBomAbstract.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/factory/FacRmolServiceContext.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/factory/FacRmolServiceContext.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/service/RMOL_Service.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/service/RMOL_ServiceContext.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/rmol/service/RMOL_ServiceContext.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/samples
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/test/OptimiseTestSuite.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
Property changes on: trunk/rmol/test/SimulateTestSuite.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dk...@us...> - 2009-09-17 16:05:24
|
Revision: 251
http://rmol.svn.sourceforge.net/rmol/?rev=251&view=rev
Author: dkchoe
Date: 2009-09-17 16:05:07 +0000 (Thu, 17 Sep 2009)
Log Message:
-----------
[Q-Forecaster] Added sell-probability calculator; Updated Q-eq demand calculator (to be continued)
Modified Paths:
--------------
trunk/rmol/rmol/bom/QForecaster.cpp
trunk/rmol/rmol/bom/QForecaster.hpp
trunk/rmol/rmol/command/Forecaster.cpp
trunk/rmol/rmol/command/Utilities.cpp
trunk/rmol/rmol/command/Utilities.hpp
Modified: trunk/rmol/rmol/bom/QForecaster.cpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-17 16:03:43 UTC (rev 250)
+++ trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-17 16:05:07 UTC (rev 251)
@@ -7,6 +7,7 @@
#include <rmol/bom/Bucket.hpp>
#include <rmol/bom/BucketHolder.hpp>
#include <rmol/bom/QForecaster.hpp>
+#include <rmol/command/Utilities.hpp>
namespace RMOL {
@@ -29,4 +30,44 @@
j++;
}
}
+
+ // //////////////////////////////////////////////////////////////////////
+ void QForecaster::calculateSellupProbability
+ (SellupProbabilityVector_T& ioSellupProbabilityVector, const double iQYield,
+ PriceHolder_T& iPriceHolder, SellupFactorHolder_T& iSellupFactorHolder) {
+ ioSellupProbabilityVector.clear();
+ for (unsigned short j=0; j < iPriceHolder.size(); j++){
+ const double lYield = iPriceHolder.at(j);
+ const double probSellup =
+ exp(-iSellupFactorHolder.at(j) *lYield/iQYield);
+ ioSellupProbabilityVector.push_back(probSellup);
+ }
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void QForecaster::calculateQEquivalentDemandParametersAndPartition
+ (ForecastedDemandParameterList_T oForecastedDemandParameterList,
+ HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder,
+ SellupProbabilityVector_T& lSellupProbabilityVector) {
+ // 1. Calculate Q-equivalent demand parameters
+ // Initialize a holder for Q-equivalent Demands
+ std::vector<double> lQEquivalentDemandHolder
+ (lSellupProbabilityVector.size(), 0);
+
+ for (unsigned int j = 0; j < iHistoricalDataHolderHolder.size(); j++) {
+ // Retrieve HistoricalDataHolder which are the data of the same product
+ // over different dates
+ std::vector<double>& lHistoricalDataHolder =
+ iHistoricalDataHolderHolder.at(j);
+ double lSellupProbability = lSellupProbabilityVector.at(j);
+ Utilities::MultiplyAValueToAVector (lHistoricalDataHolder,
+ 1/lSellupProbability);
+ // TODO: Collect historical data by date
+ Utilities::AddTwoVectors(lQEquivalentDemandHolder, lHistoricalDataHolder);
+ }
+
+ // 2. Partition the Q-eq demand to each class/bucket
+
+ }
+
}
Modified: trunk/rmol/rmol/bom/QForecaster.hpp
===================================================================
--- trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-17 16:03:43 UTC (rev 250)
+++ trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-17 16:05:07 UTC (rev 251)
@@ -6,6 +6,7 @@
// //////////////////////////////////////////////////////////////////////
// RMOL Bom
#include <rmol/bom/BomAbstract.hpp>
+#include <rmol/RMOL_FORECASTER_Types.hpp>
namespace RMOL {
@@ -26,7 +27,21 @@
const double iQYield,
const SellupFactorHolder_T&,
SellupProbabilityVector_T&);
+
+ /** The same method as the above but taking price data directly
+ instead of through BucketHolder. */
+ static void calculateSellupProbability (SellupProbabilityVector_T&,
+ const double iQYield,
+ PriceHolder_T&,
+ SellupFactorHolder_T&);
+
+ /** Calculate Q-equivalent demand distribution parameters and
+ partition it to each class/bucket. */
+ static void calculateQEquivalentDemandParametersAndPartition
+ (ForecastedDemandParameterList_T,
+ HistoricalDataHolderHolder_T&,
+ SellupProbabilityVector_T&);
+
};
-
}
#endif // __RMOL_BOM_QFORECASTER_HPP
Modified: trunk/rmol/rmol/command/Forecaster.cpp
===================================================================
--- trunk/rmol/rmol/command/Forecaster.cpp 2009-09-17 16:03:43 UTC (rev 250)
+++ trunk/rmol/rmol/command/Forecaster.cpp 2009-09-17 16:05:07 UTC (rev 251)
@@ -50,20 +50,22 @@
// 2. Partition to each class
// E(alpha x Q)=alpha x mu_Q, S.D.(alpha x Q) = |alpha| X sigma_Q
- // TODO: Find the class with the lowest yield
- const double iQYield = Utilities::minimumElementOfAVector(iPriceHolder);
+ // Find the class with the lowest yield
+ double lQYield;
+ Utilities::getMinimumElement (lQYield, iPriceHolder);
- // // TODO: Initialize a vector for sell-up probabilities
- // std::vector<double> lSellupProbabilityVector;
+ // Initialize a vector for sell-up probabilities
+ std::vector<double> lSellupProbabilityVector;
- // // TODO: Compute sell-up probability for each class/bucket & store it in a vector
- // QForecaster::calculateSellupProbability
- // (lSellupProbabilityVector, iQYield, iPriceHolder, iSellupFactorHolder);
+ // Compute sell-up probability for each class/bucket & store it in a vector
+ QForecaster::calculateSellupProbability
+ (lSellupProbabilityVector, lQYield, iPriceHolder, iSellupFactorHolder);
- // // TODO: Q-equivalent demand calculation
- // QForecaster::calculateQEquivalentDemandParametersAndPartition
- // (oForecastedDemandParameterList,
- // iHistoricalDataHolderHolder, lSellupProbabilityVector);
+ // Calculate Q-equivalent demand distribution parameters and
+ // partition it to each class/bucket
+ QForecaster::calculateQEquivalentDemandParametersAndPartition
+ (oForecastedDemandParameterList,
+ iHistoricalDataHolderHolder, lSellupProbabilityVector);
}
}
Modified: trunk/rmol/rmol/command/Utilities.cpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.cpp 2009-09-17 16:03:43 UTC (rev 250)
+++ trunk/rmol/rmol/command/Utilities.cpp 2009-09-17 16:05:07 UTC (rev 251)
@@ -4,6 +4,8 @@
// //////////////////////////////////////////////////////////////////////
//STL
#include <algorithm>
+#include <numeric>
+#include <math.h>
#include <assert.h>
// RMOL
#include <rmol/command/Utilities.hpp>
@@ -11,13 +13,68 @@
namespace RMOL {
// /////////////////////////////////////////////////////////////////////
- const double Utilities::minimumElementOfAVector (std::vector<double> iVector) {
+ void Utilities::getMinimumElement (double oMinValue,
+ std::vector<double>& iVector) {
assert(!iVector.empty());
std::vector<double>::iterator pos = min_element (iVector.begin(),
iVector.end());
- return *pos;
+ oMinValue = *pos;
}
+ // /////////////////////////////////////////////////////////////////////
+ void Utilities::getMean (double oMean, std::vector<double>& iVector) {
+ assert(!iVector.empty());
+ double lSum = std::accumulate(iVector.begin(), iVector.end(),0);
+ oMean = lSum/iVector.size();
+
+ }
+
+ // /////////////////////////////////////////////////////////////////////
+ void Utilities::getStandardDeviation (double oSD, std::vector<double>& iVector,
+ double iMean) {
+ assert(iMean > 0);
+
+ const unsigned int lSize = iVector.size();
+ assert(lSize > 0);
+
+ double lSD = 0;
+ for (unsigned int j = 0; j < lSize; j++) {
+ const double lElement = iVector.at(j);
+ lSD += (lElement - iMean) * (lElement - iMean);
+ }
+ lSD /= (lSize - 1);
+ oSD = sqrt(lSD);
+ }
+
+ // /////////////////////////////////////////////////////////////////////
+ void Utilities::AddAValueToAVector (std::vector<double>& ioVector,
+ double iValue){
+ const unsigned int lSize = ioVector.size();
+ assert(lSize > 0);
+
+ for (unsigned int j = 0; j < lSize; j++) {
+ ioVector[j] = ioVector.at(j) + iValue;
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////////
+ void Utilities::MultiplyAValueToAVector (std::vector<double>& ioVector,
+ double iValue) {
+ const unsigned int lSize = ioVector.size();
+ assert(lSize > 0);
+
+ for (unsigned int j = 0; j < lSize; j++) {
+ ioVector[j] = ioVector.at(j) * iValue;
+ }
+ }
+
+ // /////////////////////////////////////////////////////////////////////
+ static void AddTwoVectors (std::vector<double>& ioVector,
+ std::vector<double>& iVector) {
+ // std::transform (ioVector.begin(), ioVector.end(), iVector.begin(), iVector.end(),)
+ }
+
+
}
Modified: trunk/rmol/rmol/command/Utilities.hpp
===================================================================
--- trunk/rmol/rmol/command/Utilities.hpp 2009-09-17 16:03:43 UTC (rev 250)
+++ trunk/rmol/rmol/command/Utilities.hpp 2009-09-17 16:05:07 UTC (rev 251)
@@ -9,7 +9,30 @@
namespace RMOL {
struct Utilities {
- static const double minimumElementOfAVector(std::vector<double>);
+
+ /** Returns the minimum element of a given vector*/
+ static void getMinimumElement (double oMinValue, std::vector<double>&);
+
+ /** Return mean for the given elements of a vector. */
+ static void getMean (double oMean, std::vector<double>&);
+
+ /** Return standard deviation for the given elements of a vector and
+ the precomputed mean. */
+ static void getStandardDeviation (double oSD, std::vector<double>&,
+ double iMean);
+
+ /** Return the input vector after adding a value. */
+ static void AddAValueToAVector (std::vector<double>& ioVector,
+ double iValue);
+
+ /** Return the input vector after multiplying a value. */
+ static void MultiplyAValueToAVector (std::vector<double>& ioVector,
+ double iValue);
+
+ /** Return an input vector after adding the other input vector. */
+ static void AddTwoVectors (std::vector<double>& ioVector,
+ std::vector<double>& iVector);
+
};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|