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...> - 2010-12-12 21:08:11
|
Revision: 350 http://rmol.svn.sourceforge.net/rmol/?rev=350&view=rev Author: denis_arnaud Date: 2010-12-12 21:08:05 +0000 (Sun, 12 Dec 2010) Log Message: ----------- [Dev] Fixed compilation errors with g++ 4.5.1 (e.g., missing math-related headers). Modified Paths: -------------- trunk/rmol/rmol/command/Utilities.cpp Modified: trunk/rmol/rmol/command/Utilities.cpp =================================================================== --- trunk/rmol/rmol/command/Utilities.cpp 2010-12-03 19:49:52 UTC (rev 349) +++ trunk/rmol/rmol/command/Utilities.cpp 2010-12-12 21:08:05 UTC (rev 350) @@ -6,6 +6,8 @@ #include <cassert> #include <string> #include <numeric> +#include <algorithm> +#include <cmath> // StdAir #include <stdair/service/Logger.hpp> // RMOL @@ -18,8 +20,8 @@ std::vector<double>& iVector) { assert(!iVector.empty()); - std::vector<double>::iterator pos = min_element (iVector.begin(), - iVector.end()); + std::vector<double>::iterator pos = std::min_element (iVector.begin(), + iVector.end()); oMinValue = *pos; } @@ -81,7 +83,7 @@ lSD += (lElement - iMean) * (lElement - iMean); } lSD /= (lSize - 1); - oSD = sqrt(lSD); + oSD = std::sqrt (lSD); } // ///////////////////////////////////////////////////////////////////// @@ -145,8 +147,8 @@ } // ///////////////////////////////////////////////////////////////////// - static void appendAVectorToAnother (std::vector<double>& ioVector, - std::vector<double>& iVector) { + void appendAVectorToAnother (std::vector<double>& ioVector, + std::vector<double>& iVector) { ioVector.insert(ioVector.end(), iVector.begin(), iVector.end()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-12-03 19:49:59
|
Revision: 349 http://rmol.svn.sourceforge.net/rmol/?rev=349&view=rev Author: denis_arnaud Date: 2010-12-03 19:49:52 +0000 (Fri, 03 Dec 2010) Log Message: ----------- [StdAir API] Adapted the code to the new StdAir API. Modified Paths: -------------- trunk/rmol/rmol/RMOL_Service.hpp trunk/rmol/rmol/basic/BasConst_RMOL_Service.hpp trunk/rmol/rmol/factory/FacRmolServiceContext.hpp trunk/rmol/rmol/service/RMOL_ServiceContext.cpp trunk/rmol/rmol/service/RMOL_ServiceContext.hpp trunk/rmol/test/rmol/bomsforforecaster.cpp Modified: trunk/rmol/rmol/RMOL_Service.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Service.hpp 2010-11-21 14:00:45 UTC (rev 348) +++ trunk/rmol/rmol/RMOL_Service.hpp 2010-12-03 19:49:52 UTC (rev 349) @@ -7,7 +7,7 @@ // STL #include <string> // StdAir -#include <stdair/STDAIR_Types.hpp> +#include <stdair/stdair_basic_types.hpp> #include <stdair/basic/BasLogParams.hpp> // RMOL #include <rmol/RMOL_Types.hpp> Modified: trunk/rmol/rmol/basic/BasConst_RMOL_Service.hpp =================================================================== --- trunk/rmol/rmol/basic/BasConst_RMOL_Service.hpp 2010-11-21 14:00:45 UTC (rev 348) +++ trunk/rmol/rmol/basic/BasConst_RMOL_Service.hpp 2010-12-03 19:49:52 UTC (rev 349) @@ -7,7 +7,7 @@ // STL #include <vector> // StdAir -#include <stdair/STDAIR_Types.hpp> +#include <stdair/stdair_basic_types.hpp> // RMOL #include <rmol/RMOL_Types.hpp> Modified: trunk/rmol/rmol/factory/FacRmolServiceContext.hpp =================================================================== --- trunk/rmol/rmol/factory/FacRmolServiceContext.hpp 2010-11-21 14:00:45 UTC (rev 348) +++ trunk/rmol/rmol/factory/FacRmolServiceContext.hpp 2010-12-03 19:49:52 UTC (rev 349) @@ -5,7 +5,7 @@ // Import section // ////////////////////////////////////////////////////////////////////// // StdAir -#include <stdair/STDAIR_Types.hpp> +#include <stdair/stdair_basic_types.hpp> // RMOL #include <rmol/RMOL_Types.hpp> #include <rmol/factory/FacServiceAbstract.hpp> Modified: trunk/rmol/rmol/service/RMOL_ServiceContext.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_ServiceContext.cpp 2010-11-21 14:00:45 UTC (rev 348) +++ trunk/rmol/rmol/service/RMOL_ServiceContext.cpp 2010-12-03 19:49:52 UTC (rev 349) @@ -109,7 +109,8 @@ // ////////////////////////////////////////////////////////////////////// GeneratedDemandVector_T* RMOL_ServiceContext:: - generateDemand (const int K, const double& iMean, const double& iDeviation) { + generateDemand (const int K, const stdair::MeanValue_T& iMean, + const stdair::StdDevValue_T& iDeviation) { // Build a vector of K generated numbers from the given distribution // N(iMean, iDeviation) and add this vector to the // GeneratedDemandVector holder. Modified: trunk/rmol/rmol/service/RMOL_ServiceContext.hpp =================================================================== --- trunk/rmol/rmol/service/RMOL_ServiceContext.hpp 2010-11-21 14:00:45 UTC (rev 348) +++ trunk/rmol/rmol/service/RMOL_ServiceContext.hpp 2010-12-03 19:49:52 UTC (rev 349) @@ -9,7 +9,8 @@ // Boost #include <boost/shared_ptr.hpp> // StdAir -#include <stdair/STDAIR_Types.hpp> +#include <stdair/stdair_basic_types.hpp> +#include <stdair/stdair_maths_types.hpp> // RMOL #include <rmol/RMOL_Types.hpp> #include <rmol/service/ServiceAbstract.hpp> @@ -55,15 +56,16 @@ public: /** Set up the StudyStatManager. */ void setUpStudyStatManager (); + - private: // /////// Construction / initialisation //////// /** Constructors. */ RMOL_ServiceContext (); RMOL_ServiceContext (const RMOL_ServiceContext&); RMOL_ServiceContext (const stdair::AirlineCode_T&); - RMOL_ServiceContext (const stdair::AirlineCode_T&, const ResourceCapacity_T); + RMOL_ServiceContext (const stdair::AirlineCode_T&, + const ResourceCapacity_T); void init (const ResourceCapacity_T); /** Initialise the StudyStatManager. */ @@ -97,8 +99,8 @@ /** Generate demand for a given (Gaussian) distribution. */ GeneratedDemandVector_T* generateDemand (const int K, - const double& iMean, - const double& iDeviation); + const stdair::MeanValue_T&, + const stdair::StdDevValue_T&); /** Sum the two generated demand vectors . */ GeneratedDemandVector_T* generateDemand (GeneratedDemandVector_T*, Modified: trunk/rmol/test/rmol/bomsforforecaster.cpp =================================================================== --- trunk/rmol/test/rmol/bomsforforecaster.cpp 2010-11-21 14:00:45 UTC (rev 348) +++ trunk/rmol/test/rmol/bomsforforecaster.cpp 2010-12-03 19:49:52 UTC (rev 349) @@ -4,6 +4,7 @@ // STL #include <cassert> #include <fstream> +#include <limits> // StdAir #include <stdair/service/Logger.hpp> // RMOL @@ -12,43 +13,43 @@ namespace RMOL { /**-------------- BOM: Booking class/bucket data ----------------------- */ - struct BookingClassData { + struct BookingClassData { - // Attributes - double _bookingCount; - double _fare; - double _sellupFactor; - bool _censorshipFlag; + // Attributes + double _bookingCount; + double _fare; + double _sellupFactor; + bool _censorshipFlag; - // Constructer - BookingClassData (const double iBookingCount, const double iFare, - const double iSellupFactor, const bool iCensorshipFlag) - : _bookingCount(iBookingCount), _fare(iFare), + // Constructer + BookingClassData (const double iBookingCount, const double iFare, + const double iSellupFactor, const bool iCensorshipFlag) + : _bookingCount(iBookingCount), _fare(iFare), _sellupFactor(iSellupFactor), _censorshipFlag(iCensorshipFlag) { - } + } - // Getters - double getFare () const { - return _fare; - } + // Getters + double getFare () const { + return _fare; + } - bool getCensorshipFlag () const { - return _censorshipFlag; - } + bool getCensorshipFlag () const { + 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(); - } + // 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 { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-11-21 14:00:51
|
Revision: 348 http://rmol.svn.sourceforge.net/rmol/?rev=348&view=rev Author: denis_arnaud Date: 2010-11-21 14:00:45 +0000 (Sun, 21 Nov 2010) Log Message: ----------- [Test] Fixed a small compilation warning. Modified Paths: -------------- trunk/rmol/test/rmol/bomsforforecaster.cpp Modified: trunk/rmol/test/rmol/bomsforforecaster.cpp =================================================================== --- trunk/rmol/test/rmol/bomsforforecaster.cpp 2010-10-03 19:44:14 UTC (rev 347) +++ trunk/rmol/test/rmol/bomsforforecaster.cpp 2010-11-21 14:00:45 UTC (rev 348) @@ -64,7 +64,7 @@ // Constructor BookingClassDataSet () : _numberOfClass(0), _minimumFare(0), - _censorshipFlag(false), _bookingClassDataList(NULL) { + _censorshipFlag(false) { } // Add BookingClassData This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-10-03 19:44:20
|
Revision: 347 http://rmol.svn.sourceforge.net/rmol/?rev=347&view=rev Author: denis_arnaud Date: 2010-10-03 19:44:14 +0000 (Sun, 03 Oct 2010) Log Message: ----------- [Test] The test on the StdAir-based architecture is now fully working, and is located in the test/architecture sub-directory. Modified Paths: -------------- trunk/rmol/configure.ac trunk/rmol/test/architecture/Makefile.am trunk/rmol/test/architecture/stdair.cpp Property Changed: ---------------- trunk/rmol/test/architecture/ Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2010-10-03 18:21:15 UTC (rev 346) +++ trunk/rmol/configure.ac 2010-10-03 19:44:14 UTC (rev 347) @@ -366,7 +366,8 @@ po/Makefile.in test/Makefile test/samples/Makefile - test/random/Makefile + test/architecture/Makefile + test/gsl_vs_boost/Makefile test/valarrays/Makefile test/rmol/Makefile win32/Makefile) Property changes on: trunk/rmol/test/architecture ___________________________________________________________________ Modified: svn:ignore - .deps .libs Makefile Makefile.in stdair + .deps .libs Makefile Makefile.in stdair stdair.log Modified: trunk/rmol/test/architecture/Makefile.am =================================================================== --- trunk/rmol/test/architecture/Makefile.am 2010-10-03 18:21:15 UTC (rev 346) +++ trunk/rmol/test/architecture/Makefile.am 2010-10-03 19:44:14 UTC (rev 347) @@ -12,9 +12,8 @@ check_PROGRAMS = stdair stdair_SOURCES = stdair.cpp -stdair_CXXFLAGS= $(BOOST_CFLAGS) +stdair_CXXFLAGS = $(BOOST_CFLAGS) $(STDAIR_CFLAGS) stdair_LDADD = -stdair_LDFLAGS = $(BOOST_LIBS) \ - $(top_builddir)/stdair/core/libstdair.la \ +stdair_LDFLAGS = $(BOOST_LIBS) $(STDAIR_LIBS) \ $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la Modified: trunk/rmol/test/architecture/stdair.cpp =================================================================== --- trunk/rmol/test/architecture/stdair.cpp 2010-10-03 18:21:15 UTC (rev 346) +++ trunk/rmol/test/architecture/stdair.cpp 2010-10-03 19:44:14 UTC (rev 347) @@ -3,234 +3,205 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> -#include <iostream> +#include <fstream> #include <string> // STDAIR -#include <stdair/bom/BomStructureRoot.hpp> -#include <stdair/bom/BomStructureDummy.hpp> -#include <stdair/bom/BomContentDummy.hpp> +#include <stdair/STDAIR_Types.hpp> +#include <stdair/STDAIR_Service.hpp> +#include <stdair/bom/BomManager.hpp> +#include <stdair/bom/BomRoot.hpp> #include <stdair/bom/Inventory.hpp> +#include <stdair/bom/InventoryTypes.hpp> #include <stdair/bom/FlightDate.hpp> +#include <stdair/bom/FlightDateTypes.hpp> #include <stdair/bom/LegDate.hpp> +#include <stdair/bom/LegDateTypes.hpp> +#include <stdair/bom/LegCabin.hpp> +#include <stdair/bom/LegCabinTypes.hpp> #include <stdair/bom/SegmentDate.hpp> -#include <stdair/bom/BomContentRoot.hpp> -#include <stdair/bom/BomIterator.hpp> -#include <stdair/factory/FacBomContent.hpp> +#include <stdair/bom/SegmentDateTypes.hpp> +#include <stdair/bom/SegmentCabin.hpp> +#include <stdair/bom/SegmentCabinTypes.hpp> +#include <stdair/bom/BookingClass.hpp> +#include <stdair/bom/BookingClassTypes.hpp> +#include <stdair/factory/FacBomManager.hpp> +#include <stdair/service/Logger.hpp> // RMOL -#include <rmol/bom/Inventory.hpp> -#include <rmol/bom/FlightDate.hpp> -#include <rmol/bom/LegDate.hpp> #include <rmol/bom/SegmentDate.hpp> -#include <rmol/service/Logger.hpp> // ////////////////////////////////////////////////////////////////////// -RMOL::Inventory& initialise () { +stdair::Inventory& initialise () { // DEBUG - RMOL_LOG_DEBUG ("Welcome to Rmol"); + STDAIR_LOG_DEBUG ("Welcome to Rmol"); // 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>(); - + stdair::BomRoot& lBomRoot = + stdair::FacBom<stdair::BomRoot>::instance().create(); // Step 0.1: Inventory level // Create an Inventory (BA) const stdair::AirlineCode_T lAirlineCode ("BA"); - const RMOL::InventoryKey_T lInventoryKey (lAirlineCode); + const stdair::InventoryKey lInventoryKey (lAirlineCode); - RMOL::Inventory& lInventory = - stdair::FacBomContent::instance().create<RMOL::Inventory> (lBomContentRoot, - lInventoryKey); + stdair::Inventory& lInventory = + stdair::FacBom<stdair::Inventory>::instance().create (lInventoryKey); + stdair::FacBomManager::instance().addToList (lBomRoot, lInventory); // Display the inventory - RMOL_LOG_DEBUG ("Inventory: " << lInventory.toString()); + STDAIR_LOG_DEBUG ("Inventory: " << lInventory.toString()); // Step 0.2: Flight-date level // Create a FlightDate (BA15/10-JUN-2010) const stdair::FlightNumber_T lFlightNumber = 15; const stdair::Date_T lDate (2010, 6, 10); - const RMOL::FlightDateKey_T lFlightDateKey (lFlightNumber, lDate); + const stdair::FlightDateKey lFlightDateKey (lFlightNumber, lDate); - RMOL::FlightDate& lFlightDate = - stdair::FacBomContent::instance().create<RMOL::FlightDate> (lInventory, - lFlightDateKey); + stdair::FlightDate& lFlightDate = + stdair::FacBom<stdair::FlightDate>::instance().create (lFlightDateKey); + stdair::FacBomManager::instance().addToList (lInventory, lFlightDate); // Display the flight-date - RMOL_LOG_DEBUG ("FlightDate: " << lFlightDate.toString()); + STDAIR_LOG_DEBUG ("FlightDate: " << lFlightDate.toString()); // Step 0.3: Segment-date level // Create a first SegmentDate (LHR-SYD) const stdair::AirportCode_T lLHR ("LHR"); const stdair::AirportCode_T lSYD ("SYD"); - RMOL::SegmentDateKey_T lSegmentDateKey (lLHR, lSYD); + stdair::SegmentDateKey lSegmentDateKey (lLHR, lSYD); - RMOL::SegmentDate& lLHRSYDSegment = - stdair::FacBomContent::instance().create<RMOL::SegmentDate>(lFlightDate, - lSegmentDateKey); + stdair::SegmentDate& lLHRSYDSegment = + stdair::FacBom<stdair::SegmentDate>::instance().create (lSegmentDateKey); + stdair::FacBomManager::instance().addToList (lFlightDate, lLHRSYDSegment); // Display the segment-date - RMOL_LOG_DEBUG ("SegmentDate: " << lLHRSYDSegment.toString()); + STDAIR_LOG_DEBUG ("SegmentDate: " << lLHRSYDSegment.toString()); // Create a second SegmentDate (LHR-BKK) const stdair::AirportCode_T lBKK ("BKK"); - lSegmentDateKey = RMOL::SegmentDateKey_T (lLHR, lBKK); + lSegmentDateKey = stdair::SegmentDateKey (lLHR, lBKK); - RMOL::SegmentDate& lLHRBKKSegment = - stdair::FacBomContent::instance().create<RMOL::SegmentDate>(lFlightDate, - lSegmentDateKey); + stdair::SegmentDate& lLHRBKKSegment = + stdair::FacBom<stdair::SegmentDate>::instance().create (lSegmentDateKey); + stdair::FacBomManager::instance().addToList (lFlightDate, lLHRBKKSegment); // Display the segment-date - RMOL_LOG_DEBUG ("SegmentDate: " << lLHRBKKSegment.toString()); + STDAIR_LOG_DEBUG ("SegmentDate: " << lLHRBKKSegment.toString()); // Create a third SegmentDate (BKK-SYD) - lSegmentDateKey = RMOL::SegmentDateKey_T (lBKK, lSYD); + lSegmentDateKey = stdair::SegmentDateKey (lBKK, lSYD); - RMOL::SegmentDate& lBKKSYDSegment = - stdair::FacBomContent::instance().create<RMOL::SegmentDate>(lFlightDate, - lSegmentDateKey); + stdair::SegmentDate& lBKKSYDSegment = + stdair::FacBom<stdair::SegmentDate>::instance().create (lSegmentDateKey); + stdair::FacBomManager::instance().addToList (lFlightDate, lBKKSYDSegment); // Display the segment-date - RMOL_LOG_DEBUG ("SegmentDate: " << lBKKSYDSegment.toString()); + STDAIR_LOG_DEBUG ("SegmentDate: " << lBKKSYDSegment.toString()); // Step 0.4: Leg-date level // Create a first LegDate (LHR) - RMOL::LegDateKey_T lLegDateKey (lLHR); + stdair::LegDateKey lLegDateKey (lLHR); - RMOL::LegDate& lLHRLeg = - stdair::FacBomContent::instance().create<RMOL::LegDate> (lFlightDate, - lLegDateKey); + stdair::LegDate& lLHRLeg = + stdair::FacBom<stdair::LegDate>::instance().create (lLegDateKey); + stdair::FacBomManager::instance().addToList (lFlightDate, lLHRLeg); // Display the leg-date - RMOL_LOG_DEBUG ("LegDate: " << lLHRLeg.toString()); + STDAIR_LOG_DEBUG ("LegDate: " << lLHRLeg.toString()); // Create a second LegDate (BKK) - lLegDateKey = RMOL::LegDateKey_T (lBKK); + lLegDateKey = stdair::LegDateKey (lBKK); - RMOL::LegDate& lBKKLeg = - stdair::FacBomContent::instance().create<RMOL::LegDate> (lFlightDate, - lLegDateKey); + stdair::LegDate& lBKKLeg = + stdair::FacBom<stdair::LegDate>::instance().create (lLegDateKey); + stdair::FacBomManager::instance().addToList (lFlightDate, lBKKLeg); // Display the leg-date - RMOL_LOG_DEBUG ("LegDate: " << lBKKLeg.toString()); + STDAIR_LOG_DEBUG ("LegDate: " << lBKKLeg.toString()); // Step 0.5: Initialisation results // Display the full structure and content - RMOL_LOG_DEBUG ("Full Inventory: " << lInventory.toString()); + STDAIR_LOG_DEBUG ("Full Inventory: " << lInventory.toString()); return lInventory; } // //////////////////////////////////////////////////////////////// -void testIteratorInventory (const RMOL::Inventory& iInventory) { - RMOL_LOG_DEBUG ("Test iterator."); - - // Browse the list with a for-loop - RMOL_LOG_DEBUG ("Browse the list"); - for (RMOL::Inventory::list_const_iterator itInv = - iInventory.flightDateListConstIteratorBegin(); - itInv != iInventory.flightDateListConstIteratorEnd(); ++itInv) { - RMOL_LOG_DEBUG ("Current flight-date: " << *itInv); +void testIteratorInventory (const stdair::Inventory& iInventory) { + // Browse the list of flight-dates + STDAIR_LOG_DEBUG ("Browse the flight-date list"); + const stdair::FlightDateList_T& lFlightDateList = + stdair::BomManager::getList<stdair::FlightDate> (iInventory); + for (stdair::FlightDateList_T::const_iterator itFD = lFlightDateList.begin(); + itFD != lFlightDateList.end(); ++itFD) { + const stdair::FlightDate* lFD_ptr = *itFD; + assert (lFD_ptr != NULL); + STDAIR_LOG_DEBUG ("Current flight-date: " << *lFD_ptr); } - - // Browse the map with a for-loop - 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; - RMOL_LOG_DEBUG ("Current flight-date: " - << lCurrentFlightDate_ptr->toString()); - } - - 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; - RMOL_LOG_DEBUG ("Current flight-date: " - << lCurrentFlightDate_ptr->toString()); - } - - RMOL_LOG_DEBUG ("Test operators: "); - - RMOL::Inventory::list_const_iterator itBegin = - iInventory.flightDateListConstIteratorBegin(); - RMOL::Inventory::list_const_iterator itEnd = - iInventory.flightDateListConstIteratorEnd(); - - 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))); - RMOL_LOG_DEBUG ( *(itEnd - 1)); - RMOL_LOG_DEBUG ( *(itEnd -=1)); } // //////////////////////////////////////////////////////////////// -void testIteratorFlightDate (const RMOL::FlightDate& iFlightDate) { - RMOL_LOG_DEBUG ("Test iterator."); - - // Browse the list with a for-loop - RMOL_LOG_DEBUG ("Browse the segment-date list"); - for (RMOL::FlightDate::segment_date_list_const_iterator itSD = - iFlightDate.segmentDateListConstIteratorBegin(); - itSD != iFlightDate.segmentDateListConstIteratorEnd(); ++itSD) { - RMOL_LOG_DEBUG ("Current segment-date: " << *itSD); +void testIteratorFlightDate (const stdair::FlightDate& iFlightDate) { + // Browse the list of segment-dates + STDAIR_LOG_DEBUG ("Browse the segment-date list"); + const stdair::SegmentDateList_T& lSegmentDateList = + stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate); + for (stdair::SegmentDateList_T::const_iterator itSD = + lSegmentDateList.begin(); + itSD != lSegmentDateList.end(); ++itSD) { + const stdair::SegmentDate* lSD_ptr = *itSD; + assert (lSD_ptr != NULL); + STDAIR_LOG_DEBUG ("Current segment-date: " << *lSD_ptr); } - - // Browse the map with a for-loop - 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; - RMOL_LOG_DEBUG ("Current segment-date: " - << lCurrentSegmentDate_ptr->toString()); - } - // Browse the list with a for-loop - RMOL_LOG_DEBUG ("Browse the leg-date list"); - for (RMOL::FlightDate::leg_date_list_const_iterator itLD = - iFlightDate.legDateListConstIteratorBegin(); - itLD != iFlightDate.legDateListConstIteratorEnd(); ++itLD) { - RMOL_LOG_DEBUG ("Current leg-date: " << *itLD); + // Browse the list of leg-dates + STDAIR_LOG_DEBUG ("Browse the leg-date list"); + const stdair::LegDateList_T& lLegDateList = + stdair::BomManager::getList<stdair::LegDate> (iFlightDate); + for (stdair::LegDateList_T::const_iterator itLD = + lLegDateList.begin(); + itLD != lLegDateList.end(); ++itLD) { + const stdair::LegDate* lLD_ptr = *itLD; + assert (lLD_ptr != NULL); + STDAIR_LOG_DEBUG ("Current leg-date: " << *lLD_ptr); } - - // Browse the map with a for-loop - 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; - RMOL_LOG_DEBUG ("Current leg-date: " - << lCurrentLegDate_ptr->toString()); - } } // ////////////// M A I N /////////////// int main (int argc, char* argv[]) { + // Output log File + std::string lLogFilename ("stdair.log"); + + // Set the log parameters + std::ofstream logOutputFile; + // Open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + stdair::STDAIR_Service stdairService (lLogParams); + // - RMOL::Inventory& lInventory = initialise(); + stdair::Inventory& lInventory = initialise(); // testIteratorInventory (lInventory); // Browse the list with a for-loop - RMOL_LOG_DEBUG ("Browse the list"); - for (RMOL::Inventory::list_const_iterator itInv = - lInventory.flightDateListConstIteratorBegin(); - itInv != lInventory.flightDateListConstIteratorEnd(); ++itInv) { - const RMOL::FlightDate& lFlightDate = *itInv; - - RMOL_LOG_DEBUG ("Current flight-date: " << lFlightDate); - testIteratorFlightDate (lFlightDate); + STDAIR_LOG_DEBUG ("Browse the list of flight-dates"); + const stdair::FlightDateList_T& lFlightDateList = + stdair::BomManager::getList<stdair::FlightDate> (lInventory); + for (stdair::FlightDateList_T::const_iterator itFD = lFlightDateList.begin(); + itFD != lFlightDateList.end(); ++itFD) { + const stdair::FlightDate* lFD_ptr = *itFD; + assert (lFD_ptr != NULL); + STDAIR_LOG_DEBUG ("Current flight-date: " << *lFD_ptr); + testIteratorFlightDate (*lFD_ptr); } return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-10-03 18:21:22
|
Revision: 346 http://rmol.svn.sourceforge.net/rmol/?rev=346&view=rev Author: denis_arnaud Date: 2010-10-03 18:21:15 +0000 (Sun, 03 Oct 2010) Log Message: ----------- [Test] Renamed the stdair test sub-directory, as it was in the way. Modified Paths: -------------- trunk/rmol/test/architecture/stdair.cpp Added Paths: ----------- trunk/rmol/test/architecture/ Removed Paths: ------------- trunk/rmol/test/stdair/ Modified: trunk/rmol/test/architecture/stdair.cpp =================================================================== --- trunk/rmol/test/stdair/stdair.cpp 2010-10-03 18:00:51 UTC (rev 345) +++ trunk/rmol/test/architecture/stdair.cpp 2010-10-03 18:21:15 UTC (rev 346) @@ -1,9 +1,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <cassert> // STL +#include <cassert> #include <iostream> #include <string> // STDAIR @@ -27,7 +26,7 @@ // ////////////////////////////////////////////////////////////////////// RMOL::Inventory& initialise () { // DEBUG - RMOL_LOG_DEBUG ("Welcome to Air-Schedule"); + RMOL_LOG_DEBUG ("Welcome to Rmol"); // Step 0.0: initialisation // Create the root of the Bom tree (i.e., a BomContentRoot object) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-10-03 18:00:58
|
Revision: 345 http://rmol.svn.sourceforge.net/rmol/?rev=345&view=rev Author: denis_arnaud Date: 2010-10-03 18:00:51 +0000 (Sun, 03 Oct 2010) Log Message: ----------- [Test] The test on GSL vs. Boost.Rnadom has been renamed into a more explicit name. Modified Paths: -------------- trunk/rmol/test/gsl_vs_boost/Makefile.am Added Paths: ----------- trunk/rmol/test/gsl_vs_boost/ Removed Paths: ------------- trunk/rmol/test/random/ Modified: trunk/rmol/test/gsl_vs_boost/Makefile.am =================================================================== --- trunk/rmol/test/random/Makefile.am 2010-09-27 16:38:06 UTC (rev 340) +++ trunk/rmol/test/gsl_vs_boost/Makefile.am 2010-10-03 18:00:51 UTC (rev 345) @@ -1,4 +1,4 @@ -## test/random sub-directory +## test/gsl_vs_boost sub-directory include $(top_srcdir)/Makefile.common MAINTAINERCLEANFILES = Makefile.in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-10-03 16:45:56
|
Revision: 344 http://rmol.svn.sourceforge.net/rmol/?rev=344&view=rev Author: denis_arnaud Date: 2010-10-03 16:45:49 +0000 (Sun, 03 Oct 2010) Log Message: ----------- [Test] The small simulation test has been transfered into the DSim project, within the boost/random sub-directory. Modified Paths: -------------- trunk/rmol/test/rmol/Makefile.am Removed Paths: ------------- trunk/rmol/test/rmol/SimulateTestSuite.cpp trunk/rmol/test/rmol/SimulateTestSuite.hpp Property Changed: ---------------- trunk/rmol/test/rmol/ Property changes on: trunk/rmol/test/rmol ___________________________________________________________________ Modified: svn:ignore - .deps .libs Makefile Makefile.in optimise simulate sim.gnumeric OptimiseTestSuite OptimiseTestSuite.log OptimiseTestSuite_results.xml SimulateTestSuite SimulateTestSuite.log SimulateTestSuite_results.xml rmol.log ForecasterTestSuite ForecasterTestSuite.log ForecasterTestSuite_results.xml UnconstrainerTestSuite UnconstrainerTestSuite.log UnconstrainerTestSuite_results.xml bomsforforecaster bomsforforecaster.log + .deps .libs Makefile Makefile.in optimise simulate sim.gnumeric OptimiseTestSuite OptimiseTestSuite.log OptimiseTestSuite_results.xml ForecasterTestSuite ForecasterTestSuite.log ForecasterTestSuite_results.xml UnconstrainerTestSuite UnconstrainerTestSuite.log UnconstrainerTestSuite_results.xml bomsforforecaster bomsforforecaster.log Modified: trunk/rmol/test/rmol/Makefile.am =================================================================== --- trunk/rmol/test/rmol/Makefile.am 2010-09-29 15:17:31 UTC (rev 343) +++ trunk/rmol/test/rmol/Makefile.am 2010-10-03 16:45:49 UTC (rev 344) @@ -11,8 +11,7 @@ EXTRA_TESTS = bomsforforecaster -STD_CHECKS = OptimiseTestSuite SimulateTestSuite \ - ForecasterTestSuite UnconstrainerTestSuite +STD_CHECKS = OptimiseTestSuite ForecasterTestSuite UnconstrainerTestSuite check_PROGRAMS = $(STD_CHECKS) $(EXTRA_TESTS) TESTS = $(STD_CHECKS) XFAIL_TESTS = #OptimiseTestSuite @@ -25,14 +24,6 @@ $(EXTRACC_LIBS) $(STDAIR_LIBS) \ $(top_builddir)/rmol/core/librmol.la -SimulateTestSuite_SOURCES = SimulateTestSuite.hpp SimulateTestSuite.cpp -SimulateTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ - $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) -SimulateTestSuite_LDADD = -SimulateTestSuite_LDFLAGS = $(CPPUNIT_LIBS) $(EXTRACC_LIBS) \ - $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) \ - $(STDAIR_LIBS) - ForecasterTestSuite_SOURCES = ForecasterTestSuite.hpp ForecasterTestSuite.cpp ForecasterTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) Deleted: trunk/rmol/test/rmol/SimulateTestSuite.cpp =================================================================== --- trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-09-29 15:17:31 UTC (rev 343) +++ trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-10-03 16:45:49 UTC (rev 344) @@ -1,394 +0,0 @@ -// STL -#include <iostream> -#include <sstream> -// Boost Date-Time -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/date_time/gregorian/gregorian.hpp> -// Boost Random -#include <boost/random/linear_congruential.hpp> -#include <boost/random/normal_distribution.hpp> -#include <boost/random/poisson_distribution.hpp> -#include <boost/random/exponential_distribution.hpp> -#include <boost/random/variate_generator.hpp> -// Boost Math -#include <boost/math/distributions/normal.hpp> -#include <boost/math/distributions/weibull.hpp> -// Boost Accumulators -#include <boost/accumulators/accumulators.hpp> -#include <boost/accumulators/statistics.hpp> -// Extra-CPPUnit -#include <extracppunit/CppUnitCore.hpp> -// RMOL Test Suite -#include <test/rmol/SimulateTestSuite.hpp> - -// using namespace boost; -namespace ba = boost::accumulators; - -// ////////// Type definitions ////////// -/** Type definition for a random number generator base (mt19937). */ -typedef boost::minstd_rand base_generator_type; - -/** Type definition for the random generator seed. - <br>That seed must be unsigned, otherwise the wrong overload may be - selected when using mt19937 as the base_generator_type. */ -typedef unsigned int random_generator_seed_type; - -/** Type definiton for the normal distribution (characteristics). */ -typedef boost::normal_distribution<> normal_dist_type; - -/** Type definiton for the Poisson distribution (characteristics). */ -typedef boost::poisson_distribution<> poisson_dist_type; - -/** Type definiton for the exponential distribution (characteristics). */ -typedef boost::exponential_distribution<> exponential_dist_type; - -/** Type definition for the normal distribution random generator. */ -typedef boost::variate_generator<base_generator_type&, - normal_dist_type> normal_gen_type; - -/** Type definition for the Poisson distribution random generator. */ -typedef boost::variate_generator<base_generator_type&, - poisson_dist_type> poisson_gen_type; - -/** Type definition for the exponential distribution random generator. */ -typedef boost::variate_generator<base_generator_type&, - exponential_dist_type> exponential_gen_type; - -/** Type definition to gather statistics. */ -typedef ba::accumulator_set<double, - ba::stats<ba::tag::min, ba::tag::max, - ba::tag::mean (ba::immediate), - ba::tag::sum, - ba::tag::lazy_variance> > stat_acc_type; - -class simulation_exception : public std::exception { -public: - /** Constructor. */ - simulation_exception (const std::string& iWhat) throw() : _what () {} - ~simulation_exception () throw() {} - /** Gives the reason of the exception. */ - const char* what() const throw() { return _what.c_str(); } -private: - std::string _what; -}; - -// /////////////////////////////////////////////////// -double calculateDailyRate (const boost::gregorian::date iStartDate, - const boost::gregorian::date iCurrentDate, - const boost::gregorian::date iEndDate, - const double iFinalDemandMean) { - - /** - Note that the following method of pro-rating the daily rate, from - the final annual demand, may appear cumbersome, as: - 1. We discretise a continuous distribution, just to get a typical - S-curve booking pattern. - 2. We normalise that distribution, so as to get the corresponding - cdf (cumulative distribution function) equal to 1 on [0, infinite[. - 3. Moreover, in reality, we should first fit the parameters of that - S-curve distribution with the corresponding observations. - - Therefore, in the final version, we'll certainly use directly the - discrete distributions corresponding to the observations (historical - date) made beforehand. But as those observations may be difficult - to obtain, the following method is just handy for now. - */ - - /** - The result is the daily rate, expressed as a number of events (per day). - (lambda => mu = 1/ lambda), e.g., lambda = 10 => mu = 0.1 (= 2.4h, - i.e., in average, an event occurs every 2.4h). - */ - double lambda = 0.0001; - - // The first day open to reservation, there is no reservation (lambda = 0) - if (iStartDate == iCurrentDate) { - return lambda; - } - - // Simulation length-time (expressed as a number of days) - const boost::gregorian::date_duration lSimulationLength = - iEndDate - iStartDate; - const int lSimulationLengthInDays = - static_cast<const int> (lSimulationLength.days()); - - // DEBUG - return (iFinalDemandMean / lSimulationLengthInDays); - - // Current length-time (expressed as a number of days) - const boost::gregorian::date_duration lCurrentDuration = - iCurrentDate - iStartDate; - const double lCurrentDurationInDays = - static_cast<const double> (lCurrentDuration.days()); - - /** Ratio on the x-absciss for the Weibull distribution - (see ref: http://www.boost.org/doc/libs/1_44_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/weibull.html). */ - const double lXRatio = 2.0 / lSimulationLengthInDays; - - /** The daily rate is pro-rated/weighted according to the - Weibull distribution (see above for the Boost reference). - The a and b parameters are taken equal to respectively 2 and 3. */ - boost::math::weibull weibull_distribution (2, 3); - const double lCurrentDurationInWeibullX = lCurrentDurationInDays * lXRatio; - const double lPreviousDurationInWeibullX = - (lCurrentDurationInDays - 1.0) * lXRatio; - - /** - There's also a normalisation factor, so as the CDF be equal - to one when x is equal to lSimulationLengthInDays. - Hence, we're looking for a normalisation constant (let's name it nc) - such as: f_pdf (x) = nc . Weibull_pdf (lXRatio . x). - We get: - nc = lXRatio / Weibull_cdf (lXRatio . lSimulationLengthInDays), and: - f_cdf (x) = Weibull_cdf (lXRatio . x) - / Weibull_cdf (lXRatio . lSimulationLengthInDays). - */ - const double lSimulationLengthInWeibullX = lSimulationLengthInDays * lXRatio; - const double lNormalisationConstant = - 1 / boost::math::cdf (weibull_distribution, lSimulationLengthInWeibullX); - // gsl_cdf_weibull_P (lSimulationLengthInWeibullX, 2, 3); - - const double lDailyIncrementalRate = lNormalisationConstant - * (boost::math::cdf (weibull_distribution, lCurrentDurationInWeibullX) - - boost::math::cdf (weibull_distribution, lPreviousDurationInWeibullX)); - - lambda = iFinalDemandMean * lDailyIncrementalRate; - - return lambda; -} - -// ////////////////////////////////////////////////////////////////////// -void testSimulateHelper() { - - // Output log File - std::string lLogFilename ("SimulateTestSuite.log"); - - // Set the log parameters - std::ofstream logOutputFile; - - // Open and clean the log outputfile - logOutputFile.open (lLogFilename.c_str()); - logOutputFile.clear(); - - // Time duration representing a full day - // (i.e., 24h or 1,440 minutes or 86,400 seconds) - const boost::posix_time::time_duration kDay = boost::posix_time::hours(24); - const int kDayInSeconds = static_cast<const int> (kDay.total_seconds()); - const boost::gregorian::date_duration kDayDuration (1); - - // Simulation length (time length) / date range for the simulation - const boost::gregorian::date kStartDate (2007, boost::gregorian::Jan, 1); - const boost::gregorian::date kEndDate (2008, boost::gregorian::Jan, 1); - - // Length of the Simulation (number of runs) - int K = 10; - - // Final demand (i.e., number of passengers) for the given simulated - // flight-date - const double lFinalDemandMean = 300.0; - const double lFinalDemandStandardDeviation = 17.32; - - // Initialisation of random generators - /** Base for the random generator. */ - base_generator_type lGenerator (42u); - - // Statistical accumulators for the respective numbers to watch - stat_acc_type lLambdaSumAcc; - stat_acc_type lTotalEventNumberAcc; - stat_acc_type lGaussianVariateAcc; - - // Total number of events - int lTotalEventNumber = 0; - - // Consistency check: check that the sum of the daily lambdas equals to the - // final demand mean - double lLambdaSum = 0.0; - - // Perform K simulations - for (int i=0; i != K; i++) { - // Re-initialisaton of the current date - boost::gregorian::date lCurrentDate = kStartDate; - - // Generate 1 year of draws - - // Reset the total number of events for the current simulation - lTotalEventNumber = 0; - - // Reset the sum of lambdas - lLambdaSum = 0.0; - - // DEBUG - /* - std::cout << "Start date: " << kStartDate << "; End date: " << kEndDate - << std::endl; - */ - - while (lCurrentDate < kEndDate) { - // Calculate the daily rate of events (bookings) - const double lambda = calculateDailyRate (kStartDate, lCurrentDate, - kEndDate, lFinalDemandMean); - // const double mu = 1 / lambda; - - // DEBUG - /* - std::cout << "Current date: " << lCurrentDate - << "; Final demand mean: " << lFinalDemandMean - << "; Lambda: " << lambda << "; mu: " << mu << std::endl; - */ - - /** Poisson distribution. */ - poisson_dist_type lPoissonDistribution (lambda); - - /** Random generator for the Poisson distribution. */ - poisson_gen_type lPoissonDistributionGenerator (lGenerator, - lPoissonDistribution); - - /** Exponential distribution - <br>Note: Boost.Math exponential distribution takes lambda as - the parameter, whereas the GSL (GNU Scientific Library) takes - mu (== 1/lambda). */ - exponential_dist_type lExponentialDistribution (lambda); - - /** Random generator for the exponential distribution. */ - exponential_gen_type lExponentialDistributionGenerator (lGenerator, - lExponentialDistribution); - - // - lLambdaSum += lambda; - - // Current time - boost::posix_time::time_duration lCurrentTime (0, 0, 0, 0); - - // Current number of events - int lDailyEventNumber = 0; - - // Repeat until the current time exceeds 24h (i.e., 86,400 seconds) - while (lCurrentTime <= kDay) { - // Generate a random variate, expressed in (fractional) day - const double lExponentialVariateInDays = - lExponentialDistributionGenerator(); - - // Convert the variate in a number of seconds - const int lExponentialVariateInSeconds = - static_cast<const int> (lExponentialVariateInDays * kDayInSeconds); - - // Convert the variate in a (Boost typedef) time duration - const boost::posix_time::time_duration lExponentialVariate = - boost::posix_time::seconds (lExponentialVariateInSeconds); - - // Add an event - lDailyEventNumber++; lTotalEventNumber++; - - // Add the inter-arrival time to the current time - lCurrentTime += lExponentialVariate; - - // const double lPoissonVariate = lPoissonDistributionGenerator(); - - /* DEBUG - logOutputFile << lCurrentDate << "; " << lTotalEventNumber << "; " - << lDailyEventNumber << "; " << lCurrentTime << "; " - << std::endl; - */ - } - - // When the booking day is over, there's an additional event - // (the first one made after the booking date) - lTotalEventNumber--; lDailyEventNumber--; - - // DEBUG - /** - logOutputFile << i << "; " << lCurrentDate << "; " << lambda << "; " - << lDailyEventNumber << "; " << lTotalEventNumber << "; " - << std::endl; - */ - - // Add a day - lCurrentDate += kDayDuration; - } - - // Generate a Gaussian variate, just in order to compare the final - // distributions (Gaussian and accumulated Poissonian). - /** Normal distribution. */ - normal_dist_type lNormalDistribution (lFinalDemandMean, - lFinalDemandStandardDeviation); - - /** Random generator for the normal distribution. */ - normal_gen_type lNormalDistributionGenerator (lGenerator, - lNormalDistribution); - - const double lGaussianVariate = lNormalDistributionGenerator(); - - // DEBUG - logOutputFile << "Simulation#; Sum of Lambdas; Total nb of events; " - << "Random draw (following normal law);" << std::endl; - logOutputFile << i << "; " << lLambdaSum << "; " - << lTotalEventNumber << "; " - << lGaussianVariate << "; " << std::endl; - - // Update the statistics - lLambdaSumAcc (lLambdaSum); - lTotalEventNumberAcc (lTotalEventNumber); - lGaussianVariateAcc (lGaussianVariate); - } - - // DEBUG - logOutputFile << "Statistics for sum of Lambdas (min, max, mean, variance);" - << std::endl; - logOutputFile << ba::min (lLambdaSumAcc) << ", " - << ba::max (lLambdaSumAcc) << ", " - << ba::mean (lLambdaSumAcc) << ", " - << ba::variance (lLambdaSumAcc) << "; " << std::endl; - logOutputFile<<"Statistics for total nb of events (min, max, mean, variance);" - << std::endl; - logOutputFile << ba::min (lTotalEventNumberAcc) << ", " - << ba::max (lTotalEventNumberAcc) << ", " - << ba::mean (lTotalEventNumberAcc) << ", " - << ba::variance (lTotalEventNumberAcc) << "; " << std::endl; - logOutputFile << "Statistics for random draws (min, max, mean, variance);" - << std::endl; - logOutputFile << ba::min (lGaussianVariateAcc) << ", " - << ba::max (lGaussianVariateAcc) << ", " - << ba::mean (lGaussianVariateAcc) << ", " - << ba::variance (lGaussianVariateAcc) << "; " - << std::endl; - - // Checking that the number of daily events follows a distribution - if (ba::mean (lTotalEventNumberAcc) - < lFinalDemandMean - lFinalDemandStandardDeviation - || ba::mean (lTotalEventNumberAcc) - > lFinalDemandMean + lFinalDemandStandardDeviation) { - throw simulation_exception ("The mean of the total number of events is not in the expected range"); - } - - // Checking that the random draws follow a normal distribution - if (ba::mean (lGaussianVariateAcc) - < lFinalDemandMean - lFinalDemandStandardDeviation - || ba::mean (lGaussianVariateAcc) - > lFinalDemandMean + lFinalDemandStandardDeviation) { - throw simulation_exception ("The mean of the total number of events is not in the expected range"); - } - - // TODO: check that the average number of events corresponds to the given - // input - - // Close the log file - logOutputFile.close(); -} - -// ////////////////////////////////////////////////////////////////////// -void SimulateTestSuite::testSimulate() { - CPPUNIT_ASSERT_NO_THROW (testSimulateHelper();); -} - -// ////////////////////////////////////////////////////////////////////// -// void SimulateTestSuite::errorCase () { -// CPPUNIT_ASSERT (false); -// } - -// ////////////////////////////////////////////////////////////////////// -SimulateTestSuite::SimulateTestSuite () { - _describeKey << "Running test on RMOL Simulation function"; -} - -// /////////////// M A I N ///////////////// -CPPUNIT_MAIN() Deleted: trunk/rmol/test/rmol/SimulateTestSuite.hpp =================================================================== --- trunk/rmol/test/rmol/SimulateTestSuite.hpp 2010-09-29 15:17:31 UTC (rev 343) +++ trunk/rmol/test/rmol/SimulateTestSuite.hpp 2010-10-03 16:45:49 UTC (rev 344) @@ -1,25 +0,0 @@ -// STL -#include <sstream> -// CPPUNIT -#include <cppunit/extensions/HelperMacros.h> - -class SimulateTestSuite : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE (SimulateTestSuite); - CPPUNIT_TEST (testSimulate); - // CPPUNIT_TEST (errorCase); - CPPUNIT_TEST_SUITE_END (); -public: - - /** Test the Simulation functionality. */ - void testSimulate (); - - /** Test some error detection functionalities. */ - // void errorCase (); - - /** Constructor. */ - SimulateTestSuite (); - -protected: - std::stringstream _describeKey; -}; -CPPUNIT_TEST_SUITE_REGISTRATION (SimulateTestSuite); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-29 15:17:38
|
Revision: 343 http://rmol.svn.sourceforge.net/rmol/?rev=343&view=rev Author: denis_arnaud Date: 2010-09-29 15:17:31 +0000 (Wed, 29 Sep 2010) Log Message: ----------- [Test] Improved the single-day simulation test (with actual checks on gathered statistics). Modified Paths: -------------- trunk/rmol/configure.ac trunk/rmol/test/rmol/Makefile.am trunk/rmol/test/rmol/SimulateTestSuite.cpp Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2010-09-29 11:58:51 UTC (rev 342) +++ trunk/rmol/configure.ac 2010-09-29 15:17:31 UTC (rev 343) @@ -164,6 +164,7 @@ AC_SUBST(BOOST_ASIO_LIB) AC_SUBST(BOOST_MPI_LIB) AC_SUBST(BOOST_MPI_PYTHON_LIB) +AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) # -------------------------------------------------------------------- # Support for MySQL (C client API): http://www.mysql.org @@ -437,6 +438,7 @@ o BOOST_ASIO_LIB .. : ${BOOST_ASIO_LIB} o BOOST_MPI_LIB ... : ${BOOST_MPI_LIB} o BOOST_MPIPY_LIB . : ${BOOST_MPI_PYTHON_LIB} + o BOOST_UTEST_LIB . : ${BOOST_UNIT_TEST_FRAMEWORK_LIB} - MySQL ............. : o MYSQL_version ... : ${MYSQL_VERSION} Modified: trunk/rmol/test/rmol/Makefile.am =================================================================== --- trunk/rmol/test/rmol/Makefile.am 2010-09-29 11:58:51 UTC (rev 342) +++ trunk/rmol/test/rmol/Makefile.am 2010-09-29 15:17:31 UTC (rev 343) @@ -29,8 +29,9 @@ SimulateTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) SimulateTestSuite_LDADD = -SimulateTestSuite_LDFLAGS = $(BOOST_LIBS) $(CPPUNIT_LIBS) \ - $(EXTRACC_LIBS) $(STDAIR_LIBS) +SimulateTestSuite_LDFLAGS = $(CPPUNIT_LIBS) $(EXTRACC_LIBS) \ + $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) \ + $(STDAIR_LIBS) ForecasterTestSuite_SOURCES = ForecasterTestSuite.hpp ForecasterTestSuite.cpp ForecasterTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ Modified: trunk/rmol/test/rmol/SimulateTestSuite.cpp =================================================================== --- trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-09-29 11:58:51 UTC (rev 342) +++ trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-09-29 15:17:31 UTC (rev 343) @@ -13,11 +13,17 @@ // Boost Math #include <boost/math/distributions/normal.hpp> #include <boost/math/distributions/weibull.hpp> +// Boost Accumulators +#include <boost/accumulators/accumulators.hpp> +#include <boost/accumulators/statistics.hpp> // Extra-CPPUnit #include <extracppunit/CppUnitCore.hpp> // RMOL Test Suite #include <test/rmol/SimulateTestSuite.hpp> +// using namespace boost; +namespace ba = boost::accumulators; + // ////////// Type definitions ////////// /** Type definition for a random number generator base (mt19937). */ typedef boost::minstd_rand base_generator_type; @@ -48,6 +54,24 @@ typedef boost::variate_generator<base_generator_type&, exponential_dist_type> exponential_gen_type; +/** Type definition to gather statistics. */ +typedef ba::accumulator_set<double, + ba::stats<ba::tag::min, ba::tag::max, + ba::tag::mean (ba::immediate), + ba::tag::sum, + ba::tag::lazy_variance> > stat_acc_type; + +class simulation_exception : public std::exception { +public: + /** Constructor. */ + simulation_exception (const std::string& iWhat) throw() : _what () {} + ~simulation_exception () throw() {} + /** Gives the reason of the exception. */ + const char* what() const throw() { return _what.c_str(); } +private: + std::string _what; +}; + // /////////////////////////////////////////////////// double calculateDailyRate (const boost::gregorian::date iStartDate, const boost::gregorian::date iCurrentDate, @@ -57,12 +81,12 @@ /** Note that the following method of pro-rating the daily rate, from the final annual demand, may appear cumbersome, as: - 1. We discretise a continuous distribution, just to get a typical - S-curve booking pattern. - 2. We normalise that distribution, so as to get the corresponding - cdf (cumulative distribution function) equal to 1 on [0, infinite[. - 3. Moreover, in reality, we should first fit the parameters of that - S-curve distribution with the corresponding observations. + 1. We discretise a continuous distribution, just to get a typical + S-curve booking pattern. + 2. We normalise that distribution, so as to get the corresponding + cdf (cumulative distribution function) equal to 1 on [0, infinite[. + 3. Moreover, in reality, we should first fit the parameters of that + S-curve distribution with the corresponding observations. Therefore, in the final version, we'll certainly use directly the discrete distributions corresponding to the observations (historical @@ -89,7 +113,7 @@ static_cast<const int> (lSimulationLength.days()); // DEBUG - // return (iFinalDemandMean / lSimulationLengthInDays); + return (iFinalDemandMean / lSimulationLengthInDays); // Current length-time (expressed as a number of days) const boost::gregorian::date_duration lCurrentDuration = @@ -117,7 +141,7 @@ We get: nc = lXRatio / Weibull_cdf (lXRatio . lSimulationLengthInDays), and: f_cdf (x) = Weibull_cdf (lXRatio . x) - / Weibull_cdf (lXRatio . lSimulationLengthInDays). + / Weibull_cdf (lXRatio . lSimulationLengthInDays). */ const double lSimulationLengthInWeibullX = lSimulationLengthInDays * lXRatio; const double lNormalisationConstant = @@ -136,171 +160,219 @@ // ////////////////////////////////////////////////////////////////////// void testSimulateHelper() { - try { + // Output log File + std::string lLogFilename ("SimulateTestSuite.log"); - // Output log File - std::string lLogFilename ("SimulateTestSuite.log"); + // Set the log parameters + std::ofstream logOutputFile; - // Set the log parameters - std::ofstream logOutputFile; + // Open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); - // Open and clean the log outputfile - logOutputFile.open (lLogFilename.c_str()); - logOutputFile.clear(); + // Time duration representing a full day + // (i.e., 24h or 1,440 minutes or 86,400 seconds) + const boost::posix_time::time_duration kDay = boost::posix_time::hours(24); + const int kDayInSeconds = static_cast<const int> (kDay.total_seconds()); + const boost::gregorian::date_duration kDayDuration (1); - // Time duration representing a full day - // (i.e., 24h or 1,440 minutes or 86,400 seconds) - const boost::posix_time::time_duration kDay = boost::posix_time::hours(24); - const int kDayInSeconds = static_cast<const int> (kDay.total_seconds()); - const boost::gregorian::date_duration kDayDuration (1); + // Simulation length (time length) / date range for the simulation + const boost::gregorian::date kStartDate (2007, boost::gregorian::Jan, 1); + const boost::gregorian::date kEndDate (2008, boost::gregorian::Jan, 1); - // Simulation length (time length) / date range for the simulation - const boost::gregorian::date kStartDate (2007, boost::gregorian::Jan, 1); - const boost::gregorian::date kEndDate (2008, boost::gregorian::Jan, 1); - - // Length of the Simulation (number of runs) - int K = 10; + // Length of the Simulation (number of runs) + int K = 10; - // Final demand (i.e., number of passengers) for the given simulated - // flight-date - double lFinalDemandMean = 300.0; - double lFinalDemandStandardDeviation = 20.0; + // Final demand (i.e., number of passengers) for the given simulated + // flight-date + const double lFinalDemandMean = 300.0; + const double lFinalDemandStandardDeviation = 17.32; - // Initialisation of random generators - /** Base for the random generator. */ - base_generator_type lGenerator (42u); + // Initialisation of random generators + /** Base for the random generator. */ + base_generator_type lGenerator (42u); - // Total number of events - int lTotalEventNumber = 0; + // Statistical accumulators for the respective numbers to watch + stat_acc_type lLambdaSumAcc; + stat_acc_type lTotalEventNumberAcc; + stat_acc_type lGaussianVariateAcc; + + // Total number of events + int lTotalEventNumber = 0; - // Consistency check: check that the sum of the daily lambdas equals to the - // final demand mean - double lLambdaSum = 0.0; + // Consistency check: check that the sum of the daily lambdas equals to the + // final demand mean + double lLambdaSum = 0.0; - // Generate k draws - logOutputFile << "Simulation#; Lambda_Sum; Total_Event#; Gaussian_Variate; " - << std::endl; - - // Perform K simulations - for (int i=0; i != K; i++) { - // Re-initialisaton of the current date - boost::gregorian::date lCurrentDate = kStartDate; + // Perform K simulations + for (int i=0; i != K; i++) { + // Re-initialisaton of the current date + boost::gregorian::date lCurrentDate = kStartDate; - // Generate 1 year of draws + // Generate 1 year of draws - // DEBUG - logOutputFile << "Day#; Total_Event#; Daily_Event#; Time; " << std::endl; + // Reset the total number of events for the current simulation + lTotalEventNumber = 0; - // Reset the total number of events for the current simulation - lTotalEventNumber = 0; - - // Reset the sum of lambdas - lLambdaSum = 0.0; + // Reset the sum of lambdas + lLambdaSum = 0.0; - while (lCurrentDate < kEndDate) { - // Calculate the daily rate of events (bookings) - const double lambda = calculateDailyRate (kStartDate, lCurrentDate, - kEndDate, lFinalDemandMean); - const double mu = 1 / lambda; + // DEBUG + /* + std::cout << "Start date: " << kStartDate << "; End date: " << kEndDate + << std::endl; + */ + + while (lCurrentDate < kEndDate) { + // Calculate the daily rate of events (bookings) + const double lambda = calculateDailyRate (kStartDate, lCurrentDate, + kEndDate, lFinalDemandMean); + // const double mu = 1 / lambda; - // - std::cout << "Lambda: " << lambda << "; mu: " << mu << std::endl; + // DEBUG + /* + std::cout << "Current date: " << lCurrentDate + << "; Final demand mean: " << lFinalDemandMean + << "; Lambda: " << lambda << "; mu: " << mu << std::endl; + */ - /** Poisson distribution. */ - poisson_dist_type lPoissonDistribution (lambda); + /** Poisson distribution. */ + poisson_dist_type lPoissonDistribution (lambda); - /** Random generator for the Poisson distribution. */ - poisson_gen_type lPoissonDistributionGenerator (lGenerator, - lPoissonDistribution); + /** Random generator for the Poisson distribution. */ + poisson_gen_type lPoissonDistributionGenerator (lGenerator, + lPoissonDistribution); - /** Exponential distribution. */ - exponential_dist_type lExponentialDistribution (mu); + /** Exponential distribution + <br>Note: Boost.Math exponential distribution takes lambda as + the parameter, whereas the GSL (GNU Scientific Library) takes + mu (== 1/lambda). */ + exponential_dist_type lExponentialDistribution (lambda); - /** Random generator for the exponential distribution. */ - exponential_gen_type lExponentialDistributionGenerator (lGenerator, - lExponentialDistribution); + /** Random generator for the exponential distribution. */ + exponential_gen_type lExponentialDistributionGenerator (lGenerator, + lExponentialDistribution); - // - lLambdaSum += lambda; + // + lLambdaSum += lambda; - // Current time - boost::posix_time::time_duration lCurrentTime (0, 0, 0, 0); + // Current time + boost::posix_time::time_duration lCurrentTime (0, 0, 0, 0); - // Current number of events - int lDailyEventNumber = 0; + // Current number of events + int lDailyEventNumber = 0; - // Repeat until the current time exceeds 24h (i.e., 86,400 seconds) - while (lCurrentTime <= kDay) { - // Generate a random variate, expressed in (fractional) day - const double lExponentialVariateInDays = - lExponentialDistributionGenerator(); + // Repeat until the current time exceeds 24h (i.e., 86,400 seconds) + while (lCurrentTime <= kDay) { + // Generate a random variate, expressed in (fractional) day + const double lExponentialVariateInDays = + lExponentialDistributionGenerator(); - // Convert the variate in a number of seconds - const int lExponentialVariateInSeconds = - static_cast<const int> (lExponentialVariateInDays * kDayInSeconds); + // Convert the variate in a number of seconds + const int lExponentialVariateInSeconds = + static_cast<const int> (lExponentialVariateInDays * kDayInSeconds); - // Convert the variate in a (Boost typedef) time duration - const boost::posix_time::time_duration lExponentialVariate = - boost::posix_time::seconds (lExponentialVariateInSeconds); + // Convert the variate in a (Boost typedef) time duration + const boost::posix_time::time_duration lExponentialVariate = + boost::posix_time::seconds (lExponentialVariateInSeconds); - // Add an event - lDailyEventNumber++; lTotalEventNumber++; + // Add an event + lDailyEventNumber++; lTotalEventNumber++; - // Add the inter-arrival time to the current time - lCurrentTime += lExponentialVariate; + // Add the inter-arrival time to the current time + lCurrentTime += lExponentialVariate; - // const double lPoissonVariate = lPoissonDistributionGenerator(); + // const double lPoissonVariate = lPoissonDistributionGenerator(); - /* DEBUG - logOutputFile << lCurrentDate << "; " << lTotalEventNumber << "; " - << lDailyEventNumber << "; " << lCurrentTime << "; " - << std::endl; - */ - } - - // When the booking day is over, there's an additional event - // (the first one made after the booking date) - lTotalEventNumber--; lDailyEventNumber--; - /* DEBUG - logOutputFile << lCurrentDate << "; " << lambda << "; " - << lDailyEventNumber << "; " << lTotalEventNumber << "; " - << std::endl; + logOutputFile << lCurrentDate << "; " << lTotalEventNumber << "; " + << lDailyEventNumber << "; " << lCurrentTime << "; " + << std::endl; */ - - // Add a day - lCurrentDate += kDayDuration; } - // Generate a Gaussian variate, just in order to compare the final - // distributions (Gaussian and accumulated Poissonian). - /** Normal distribution. */ - normal_dist_type lNormalDistribution (lFinalDemandMean, - lFinalDemandStandardDeviation); + // When the booking day is over, there's an additional event + // (the first one made after the booking date) + lTotalEventNumber--; lDailyEventNumber--; + + // DEBUG + /** + logOutputFile << i << "; " << lCurrentDate << "; " << lambda << "; " + << lDailyEventNumber << "; " << lTotalEventNumber << "; " + << std::endl; + */ + + // Add a day + lCurrentDate += kDayDuration; + } - /** Random generator for the normal distribution. */ - normal_gen_type lNormalDistributionGenerator (lGenerator, - lNormalDistribution); + // Generate a Gaussian variate, just in order to compare the final + // distributions (Gaussian and accumulated Poissonian). + /** Normal distribution. */ + normal_dist_type lNormalDistribution (lFinalDemandMean, + lFinalDemandStandardDeviation); - const double lGaussianVariate = lNormalDistributionGenerator(); + /** Random generator for the normal distribution. */ + normal_gen_type lNormalDistributionGenerator (lGenerator, + lNormalDistribution); + + const double lGaussianVariate = lNormalDistributionGenerator(); - logOutputFile << i << "; " << lLambdaSum << "; " - << lTotalEventNumber << "; " - << lGaussianVariate << "; " << std::endl; - } + // DEBUG + logOutputFile << "Simulation#; Sum of Lambdas; Total nb of events; " + << "Random draw (following normal law);" << std::endl; + logOutputFile << i << "; " << lLambdaSum << "; " + << lTotalEventNumber << "; " + << lGaussianVariate << "; " << std::endl; + + // Update the statistics + lLambdaSumAcc (lLambdaSum); + lTotalEventNumberAcc (lTotalEventNumber); + lGaussianVariateAcc (lGaussianVariate); + } - // TODO: check that the average number of events corresponds to the given - // input + // DEBUG + logOutputFile << "Statistics for sum of Lambdas (min, max, mean, variance);" + << std::endl; + logOutputFile << ba::min (lLambdaSumAcc) << ", " + << ba::max (lLambdaSumAcc) << ", " + << ba::mean (lLambdaSumAcc) << ", " + << ba::variance (lLambdaSumAcc) << "; " << std::endl; + logOutputFile<<"Statistics for total nb of events (min, max, mean, variance);" + << std::endl; + logOutputFile << ba::min (lTotalEventNumberAcc) << ", " + << ba::max (lTotalEventNumberAcc) << ", " + << ba::mean (lTotalEventNumberAcc) << ", " + << ba::variance (lTotalEventNumberAcc) << "; " << std::endl; + logOutputFile << "Statistics for random draws (min, max, mean, variance);" + << std::endl; + logOutputFile << ba::min (lGaussianVariateAcc) << ", " + << ba::max (lGaussianVariateAcc) << ", " + << ba::mean (lGaussianVariateAcc) << ", " + << ba::variance (lGaussianVariateAcc) << "; " + << std::endl; - // Close the log file - logOutputFile.close(); + // Checking that the number of daily events follows a distribution + if (ba::mean (lTotalEventNumberAcc) + < lFinalDemandMean - lFinalDemandStandardDeviation + || ba::mean (lTotalEventNumberAcc) + > lFinalDemandMean + lFinalDemandStandardDeviation) { + throw simulation_exception ("The mean of the total number of events is not in the expected range"); + } + + // Checking that the random draws follow a normal distribution + if (ba::mean (lGaussianVariateAcc) + < lFinalDemandMean - lFinalDemandStandardDeviation + || ba::mean (lGaussianVariateAcc) + > lFinalDemandMean + lFinalDemandStandardDeviation) { + throw simulation_exception ("The mean of the total number of events is not in the expected range"); + } - } catch (const std::exception& stde) { - std::cerr << "Standard exception: " << stde.what() << std::endl; - - } catch (...) { - std::cerr << "Unknown exception" << std::endl; - } + // TODO: check that the average number of events corresponds to the given + // input + + // Close the log file + logOutputFile.close(); } // ////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-29 11:58:58
|
Revision: 342 http://rmol.svn.sourceforge.net/rmol/?rev=342&view=rev Author: denis_arnaud Date: 2010-09-29 11:58:51 +0000 (Wed, 29 Sep 2010) Log Message: ----------- [Test] Improved a little bit the single-day simulator. Modified Paths: -------------- trunk/rmol/test/rmol/SimulateTestSuite.cpp Modified: trunk/rmol/test/rmol/SimulateTestSuite.cpp =================================================================== --- trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-09-27 16:38:42 UTC (rev 341) +++ trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-09-29 11:58:51 UTC (rev 342) @@ -3,13 +3,16 @@ #include <sstream> // Boost Date-Time #include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/date_time/gregorian/gregorian.hpp> // Boost Random #include <boost/random/linear_congruential.hpp> +#include <boost/random/normal_distribution.hpp> #include <boost/random/poisson_distribution.hpp> #include <boost/random/exponential_distribution.hpp> #include <boost/random/variate_generator.hpp> // Boost Math #include <boost/math/distributions/normal.hpp> +#include <boost/math/distributions/weibull.hpp> // Extra-CPPUnit #include <extracppunit/CppUnitCore.hpp> // RMOL Test Suite @@ -24,12 +27,19 @@ selected when using mt19937 as the base_generator_type. */ typedef unsigned int random_generator_seed_type; +/** Type definiton for the normal distribution (characteristics). */ +typedef boost::normal_distribution<> normal_dist_type; + /** Type definiton for the Poisson distribution (characteristics). */ typedef boost::poisson_distribution<> poisson_dist_type; /** Type definiton for the exponential distribution (characteristics). */ typedef boost::exponential_distribution<> exponential_dist_type; +/** Type definition for the normal distribution random generator. */ +typedef boost::variate_generator<base_generator_type&, + normal_dist_type> normal_gen_type; + /** Type definition for the Poisson distribution random generator. */ typedef boost::variate_generator<base_generator_type&, poisson_dist_type> poisson_gen_type; @@ -38,6 +48,91 @@ typedef boost::variate_generator<base_generator_type&, exponential_dist_type> exponential_gen_type; +// /////////////////////////////////////////////////// +double calculateDailyRate (const boost::gregorian::date iStartDate, + const boost::gregorian::date iCurrentDate, + const boost::gregorian::date iEndDate, + const double iFinalDemandMean) { + + /** + Note that the following method of pro-rating the daily rate, from + the final annual demand, may appear cumbersome, as: + 1. We discretise a continuous distribution, just to get a typical + S-curve booking pattern. + 2. We normalise that distribution, so as to get the corresponding + cdf (cumulative distribution function) equal to 1 on [0, infinite[. + 3. Moreover, in reality, we should first fit the parameters of that + S-curve distribution with the corresponding observations. + + Therefore, in the final version, we'll certainly use directly the + discrete distributions corresponding to the observations (historical + date) made beforehand. But as those observations may be difficult + to obtain, the following method is just handy for now. + */ + + /** + The result is the daily rate, expressed as a number of events (per day). + (lambda => mu = 1/ lambda), e.g., lambda = 10 => mu = 0.1 (= 2.4h, + i.e., in average, an event occurs every 2.4h). + */ + double lambda = 0.0001; + + // The first day open to reservation, there is no reservation (lambda = 0) + if (iStartDate == iCurrentDate) { + return lambda; + } + + // Simulation length-time (expressed as a number of days) + const boost::gregorian::date_duration lSimulationLength = + iEndDate - iStartDate; + const int lSimulationLengthInDays = + static_cast<const int> (lSimulationLength.days()); + + // DEBUG + // return (iFinalDemandMean / lSimulationLengthInDays); + + // Current length-time (expressed as a number of days) + const boost::gregorian::date_duration lCurrentDuration = + iCurrentDate - iStartDate; + const double lCurrentDurationInDays = + static_cast<const double> (lCurrentDuration.days()); + + /** Ratio on the x-absciss for the Weibull distribution + (see ref: http://www.boost.org/doc/libs/1_44_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/weibull.html). */ + const double lXRatio = 2.0 / lSimulationLengthInDays; + + /** The daily rate is pro-rated/weighted according to the + Weibull distribution (see above for the Boost reference). + The a and b parameters are taken equal to respectively 2 and 3. */ + boost::math::weibull weibull_distribution (2, 3); + const double lCurrentDurationInWeibullX = lCurrentDurationInDays * lXRatio; + const double lPreviousDurationInWeibullX = + (lCurrentDurationInDays - 1.0) * lXRatio; + + /** + There's also a normalisation factor, so as the CDF be equal + to one when x is equal to lSimulationLengthInDays. + Hence, we're looking for a normalisation constant (let's name it nc) + such as: f_pdf (x) = nc . Weibull_pdf (lXRatio . x). + We get: + nc = lXRatio / Weibull_cdf (lXRatio . lSimulationLengthInDays), and: + f_cdf (x) = Weibull_cdf (lXRatio . x) + / Weibull_cdf (lXRatio . lSimulationLengthInDays). + */ + const double lSimulationLengthInWeibullX = lSimulationLengthInDays * lXRatio; + const double lNormalisationConstant = + 1 / boost::math::cdf (weibull_distribution, lSimulationLengthInWeibullX); + // gsl_cdf_weibull_P (lSimulationLengthInWeibullX, 2, 3); + + const double lDailyIncrementalRate = lNormalisationConstant + * (boost::math::cdf (weibull_distribution, lCurrentDurationInWeibullX) + - boost::math::cdf (weibull_distribution, lPreviousDurationInWeibullX)); + + lambda = iFinalDemandMean * lDailyIncrementalRate; + + return lambda; +} + // ////////////////////////////////////////////////////////////////////// void testSimulateHelper() { @@ -55,64 +150,143 @@ // Time duration representing a full day // (i.e., 24h or 1,440 minutes or 86,400 seconds) - const boost::posix_time::time_duration kDay (24, 0, 0, 0); + const boost::posix_time::time_duration kDay = boost::posix_time::hours(24); + const int kDayInSeconds = static_cast<const int> (kDay.total_seconds()); + const boost::gregorian::date_duration kDayDuration (1); - // Length of the Simulation (time-length) - const int kSimulationLength = 365; + // Simulation length (time length) / date range for the simulation + const boost::gregorian::date kStartDate (2007, boost::gregorian::Jan, 1); + const boost::gregorian::date kEndDate (2008, boost::gregorian::Jan, 1); - // Rate, expressed as a number of events per day - // (lambda => mu = 1 / lambda) - const double lambda = 10.0; - const double mu = 1 / lambda; - // mu = 0.1 (= 2.4h, i.e., in average, an event occurs every 2.4h) + // Length of the Simulation (number of runs) + int K = 10; + // Final demand (i.e., number of passengers) for the given simulated + // flight-date + double lFinalDemandMean = 300.0; + double lFinalDemandStandardDeviation = 20.0; + // Initialisation of random generators /** Base for the random generator. */ base_generator_type lGenerator (42u); - /** Poisson distribution. */ - exponential_dist_type lExponentialDistribution (mu); + // Total number of events + int lTotalEventNumber = 0; + + // Consistency check: check that the sum of the daily lambdas equals to the + // final demand mean + double lLambdaSum = 0.0; + + // Generate k draws + logOutputFile << "Simulation#; Lambda_Sum; Total_Event#; Gaussian_Variate; " + << std::endl; - /** Random generator for the Poisson distribution. */ - exponential_gen_type lExponentialDistributionGenerator (lGenerator, - lExponentialDistribution); + // Perform K simulations + for (int i=0; i != K; i++) { + // Re-initialisaton of the current date + boost::gregorian::date lCurrentDate = kStartDate; + + // Generate 1 year of draws - /** Poisson distribution. */ - poisson_dist_type lPoissonDistribution (lambda); + // DEBUG + logOutputFile << "Day#; Total_Event#; Daily_Event#; Time; " << std::endl; - /** Random generator for the Poisson distribution. */ - poisson_gen_type lPoissonDistributionGenerator (lGenerator, - lPoissonDistribution); + // Reset the total number of events for the current simulation + lTotalEventNumber = 0; - // Generate k draws - logOutputFile << "Event#; Time; " << std::endl; - for (int i=1; i != kSimulationLength; i++) { + // Reset the sum of lambdas + lLambdaSum = 0.0; + + while (lCurrentDate < kEndDate) { + // Calculate the daily rate of events (bookings) + const double lambda = calculateDailyRate (kStartDate, lCurrentDate, + kEndDate, lFinalDemandMean); + const double mu = 1 / lambda; - // Current time - boost::posix_time::time_duration lCurrentTime (0, 0, 0, 0); + // + std::cout << "Lambda: " << lambda << "; mu: " << mu << std::endl; - // Current number of events - int lEventNumber = 0; + /** Poisson distribution. */ + poisson_dist_type lPoissonDistribution (lambda); - // Repeat until the current time exceeds 24h (i.e., 86,400 seconds) - while (lCurrentTime <= kDay) { - const double lExponentialVariateDay = - lExponentialDistributionGenerator(); - const long int lExponentialVariateHours = - static_cast<long int> (lExponentialVariateDay * 24); - const boost::posix_time::time_duration lExponentialVariateSeconds = - boost::posix_time::hours (lExponentialVariateHours); + /** Random generator for the Poisson distribution. */ + poisson_gen_type lPoissonDistributionGenerator (lGenerator, + lPoissonDistribution); - // Add an event - ++lEventNumber; + /** Exponential distribution. */ + exponential_dist_type lExponentialDistribution (mu); - // Add the inter-arrival time to the current time - lCurrentTime += lExponentialVariateSeconds; + /** Random generator for the exponential distribution. */ + exponential_gen_type lExponentialDistributionGenerator (lGenerator, + lExponentialDistribution); + + // + lLambdaSum += lambda; - // const double lPoissonVariate = lPoissonDistributionGenerator(); - logOutputFile << lEventNumber << "; " << lCurrentTime << "; " + // Current time + boost::posix_time::time_duration lCurrentTime (0, 0, 0, 0); + + // Current number of events + int lDailyEventNumber = 0; + + // Repeat until the current time exceeds 24h (i.e., 86,400 seconds) + while (lCurrentTime <= kDay) { + // Generate a random variate, expressed in (fractional) day + const double lExponentialVariateInDays = + lExponentialDistributionGenerator(); + + // Convert the variate in a number of seconds + const int lExponentialVariateInSeconds = + static_cast<const int> (lExponentialVariateInDays * kDayInSeconds); + + // Convert the variate in a (Boost typedef) time duration + const boost::posix_time::time_duration lExponentialVariate = + boost::posix_time::seconds (lExponentialVariateInSeconds); + + // Add an event + lDailyEventNumber++; lTotalEventNumber++; + + // Add the inter-arrival time to the current time + lCurrentTime += lExponentialVariate; + + // const double lPoissonVariate = lPoissonDistributionGenerator(); + + /* DEBUG + logOutputFile << lCurrentDate << "; " << lTotalEventNumber << "; " + << lDailyEventNumber << "; " << lCurrentTime << "; " + << std::endl; + */ + } + + // When the booking day is over, there's an additional event + // (the first one made after the booking date) + lTotalEventNumber--; lDailyEventNumber--; + + /* DEBUG + logOutputFile << lCurrentDate << "; " << lambda << "; " + << lDailyEventNumber << "; " << lTotalEventNumber << "; " << std::endl; + */ + + // Add a day + lCurrentDate += kDayDuration; } + + // Generate a Gaussian variate, just in order to compare the final + // distributions (Gaussian and accumulated Poissonian). + /** Normal distribution. */ + normal_dist_type lNormalDistribution (lFinalDemandMean, + lFinalDemandStandardDeviation); + + /** Random generator for the normal distribution. */ + normal_gen_type lNormalDistributionGenerator (lGenerator, + lNormalDistribution); + + const double lGaussianVariate = lNormalDistributionGenerator(); + + logOutputFile << i << "; " << lLambdaSum << "; " + << lTotalEventNumber << "; " + << lGaussianVariate << "; " << std::endl; } // TODO: check that the average number of events corresponds to the given This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-27 16:38:48
|
Revision: 341 http://rmol.svn.sourceforge.net/rmol/?rev=341&view=rev Author: denis_arnaud Date: 2010-09-27 16:38:42 +0000 (Mon, 27 Sep 2010) Log Message: ----------- [Test] Added a directory to compare Boost.Math and the GSL (GNU Scientific Library) for normal distributions. Modified Paths: -------------- trunk/rmol/configure.ac Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2010-09-27 16:38:06 UTC (rev 340) +++ trunk/rmol/configure.ac 2010-09-27 16:38:42 UTC (rev 341) @@ -365,6 +365,7 @@ po/Makefile.in test/Makefile test/samples/Makefile + test/random/Makefile test/valarrays/Makefile test/rmol/Makefile win32/Makefile) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-27 16:38:12
|
Revision: 340 http://rmol.svn.sourceforge.net/rmol/?rev=340&view=rev Author: denis_arnaud Date: 2010-09-27 16:38:06 +0000 (Mon, 27 Sep 2010) Log Message: ----------- [Test] Added a directory to compare Boost.Math and the GSL (GNU Scientific Library) for normal distributions. Added Paths: ----------- trunk/rmol/test/random/ trunk/rmol/test/random/Makefile.am trunk/rmol/test/random/boost_vs_gsl.cpp Property changes on: trunk/rmol/test/random ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile boost_vs_gsl Added: trunk/rmol/test/random/Makefile.am =================================================================== --- trunk/rmol/test/random/Makefile.am (rev 0) +++ trunk/rmol/test/random/Makefile.am 2010-09-27 16:38:06 UTC (rev 340) @@ -0,0 +1,22 @@ +## test/random sub-directory +include $(top_srcdir)/Makefile.common + +MAINTAINERCLEANFILES = Makefile.in + +## +SUBDIRS = + +## +EXTRA_TESTS = boost_vs_gsl + +STD_CHECKS = +check_PROGRAMS = $(STD_CHECKS) $(EXTRA_TESTS) +TESTS = $(STD_CHECKS) +XFAIL_TESTS = #boost_vs_gsl + + +boost_vs_gsl_SOURCES = boost_vs_gsl.cpp +boost_vs_gsl_CXXFLAGS= $(BOOST_CFLAGS) $(GSL_CFLAGS) $(CPPUNIT_CFLAGS) +boost_vs_gsl_LDADD = +boost_vs_gsl_LDFLAGS = $(BOOST_LIBS) $(GSL_LIBS) + Added: trunk/rmol/test/random/boost_vs_gsl.cpp =================================================================== --- trunk/rmol/test/random/boost_vs_gsl.cpp (rev 0) +++ trunk/rmol/test/random/boost_vs_gsl.cpp 2010-09-27 16:38:06 UTC (rev 340) @@ -0,0 +1,149 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iostream> +// GSL +#include <gsl/gsl_randist.h> +#include <gsl/gsl_cdf.h> +// Boost Math +#include <boost/math/distributions/binomial.hpp> +#include <boost/math/distributions/normal.hpp> +#include <boost/math/special_functions/round.hpp> + +// Alias for the Boost::Math namespace +namespace bm = boost::math; + +// /////////////////////// M A I N ////////////////////////////// +int main (int argc, char* agrv[]) { + + // + std::cout << std::endl + << "Compare Boost.Math vs GSL (GNU Scientific Library)" + << std::endl; + + std::cout + << "* For the GSL, see http://www.gnu.org/software/gsl/manual/html_node/" + << std::endl + << "* For Boost.Math, see " + << "http://www.boost.org/doc/libs/1_44_0/libs/math/doc/sf_and_dist/html/index.html" + << std::endl; + std::cout + << "All the following resuls are compared with a precision of 1e-8. " + << std::endl + << "If one of those results are not equal for GSL and Boost, " + << "the program aborts." + << std::endl << std::endl; + + const double precision = 1e-8; + + // + const double mean = 10.0; + const double sigma = 2.0; + + // Boost distributions need first to be instantiated + bm::normal normalDistribution (mean, sigma); + + std::cout + << "___________________________________________" << std::endl + << " pdf and cdf of a normal distribution " << std::endl + << "___________________________________________" << std::endl << std::endl; + std::cout << std::setprecision(7); + std::cout << std::setw(15) << std::left << "Mean = " << mean << std::endl; + std::cout << std::setw(15) << std::left << "Sigma = " << sigma << std::endl; + std::cout << std::endl; + + std::cout + << "_______________________________________________________________________" + << std::endl + << " GSL Boost GSL Boost " + << std::endl + << " Value (x) pdf pdf cdf cdf " + << std::endl + << "_______________________________________________________________________" + << std::endl; + + for (double x = mean - 5*sigma; x <= mean + 5*sigma; ++x) { + // + std::cout << std::fixed << std::setprecision(3) + << std::setw(10) << std::right << x; + + // Normal pdf (probability distribution function) + const double lNormalPdfGSL = gsl_ran_gaussian_pdf (x - mean, sigma); + const double lNormalPdfBoost = bm::pdf (normalDistribution, x); + + // Normal cdf (cumulated probability distribution function) + const double lNormalCdfGSL = gsl_cdf_gaussian_P (x - mean, sigma); + const double lNormalCdfBoost = bm::cdf (normalDistribution, x); + + // Print probabilities + std::cout << std::fixed << std::setprecision(5) + << std::setw(15) << std::right << lNormalPdfGSL + << std::setw(15) << std::right << lNormalPdfBoost + << std::setw(15) << std::right << lNormalCdfGSL + << std::setw(15) << std::right << lNormalCdfBoost + << std::endl; + + // Check that the GSL results are the same of those from Boost Math + assert (bm::round (lNormalPdfGSL / precision) + == bm::round (lNormalPdfBoost / precision)); + assert (bm::round (lNormalCdfGSL / precision) + == bm::round (lNormalCdfBoost / precision)); + } + + std::cout + << "___________________________________________" << std::endl + << " Inverse of cdf for a normal distribution " << std::endl + << "___________________________________________" << std::endl << std::endl; + std::cout << std::setprecision(7); + std::cout << std::setw(15) << std::left << "Mean = " << mean << std::endl; + std::cout << std::setw(15) << std::left << "Sigma = " << sigma << std::endl; + std::cout << std::endl; + + std::cout + << "_______________________________________________________________________" + << std::endl + << " GSL Boost GSL Boost " + << std::endl + << " Value (x) icdf icdf 1-icdf 1-icdf " + << std::endl + << "_______________________________________________________________________" + << std::endl; + + for (double prob = 0.05; prob < 1.0; prob += 0.05) { + // + std::cout << std::fixed << std::setprecision(3) + << std::setw(10) << std::right << prob; + + // Inverse normal cdf + const double lInverseNormalCdfGSL = + mean + gsl_cdf_gaussian_Pinv (prob, sigma); + const double lInverseNormalCdfBoost = + bm::quantile (normalDistribution, prob); + + // Complement of the inverse normal cdf + const double lComplementInverseNormalCdfGSL = + mean + gsl_cdf_gaussian_Qinv (prob, sigma); + const double lComplementInverseNormalCdfBoost = + bm::quantile (bm::complement (normalDistribution, prob)); + + // Print values (quantiles) + std::cout << std::fixed << std::setprecision(5) + << std::setw(15) << std::right << lInverseNormalCdfGSL + << std::setw(15) << std::right << lInverseNormalCdfBoost + << std::setw(15) << std::right << lComplementInverseNormalCdfGSL + << std::setw(15) << std::right << lComplementInverseNormalCdfBoost + << std::endl; + + // Check that the GSL results are the same of those from Boost Math + assert (bm::round (lInverseNormalCdfGSL / precision) + == bm::round (lInverseNormalCdfBoost / precision)); + assert (bm::round (lComplementInverseNormalCdfGSL / precision) + == bm::round (lComplementInverseNormalCdfBoost / precision)); + } + + // + std::cout << std::endl; + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-27 11:37:10
|
Revision: 339 http://rmol.svn.sourceforge.net/rmol/?rev=339&view=rev Author: denis_arnaud Date: 2010-09-27 11:37:00 +0000 (Mon, 27 Sep 2010) Log Message: ----------- [Dev] Replaced calls to the GSL (GNU Scientific Library) by Boost.Math. Modified Paths: -------------- trunk/rmol/test/rmol/Makefile.am trunk/rmol/test/rmol/SimulateTestSuite.cpp Property Changed: ---------------- trunk/rmol/test/rmol/ Property changes on: trunk/rmol/test/rmol ___________________________________________________________________ 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 bomsforforecaster bomsforforecaster.log + .deps .libs Makefile Makefile.in optimise simulate sim.gnumeric OptimiseTestSuite OptimiseTestSuite.log OptimiseTestSuite_results.xml SimulateTestSuite SimulateTestSuite.log SimulateTestSuite_results.xml rmol.log ForecasterTestSuite ForecasterTestSuite.log ForecasterTestSuite_results.xml UnconstrainerTestSuite UnconstrainerTestSuite.log UnconstrainerTestSuite_results.xml bomsforforecaster bomsforforecaster.log Modified: trunk/rmol/test/rmol/Makefile.am =================================================================== --- trunk/rmol/test/rmol/Makefile.am 2010-09-27 11:36:24 UTC (rev 338) +++ trunk/rmol/test/rmol/Makefile.am 2010-09-27 11:37:00 UTC (rev 339) @@ -26,10 +26,10 @@ $(top_builddir)/rmol/core/librmol.la SimulateTestSuite_SOURCES = SimulateTestSuite.hpp SimulateTestSuite.cpp -SimulateTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(GSL_CFLAGS) $(CPPUNIT_CFLAGS) \ +SimulateTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) SimulateTestSuite_LDADD = -SimulateTestSuite_LDFLAGS = $(BOOST_LIBS) $(GSL_LIBS) $(CPPUNIT_LIBS) \ +SimulateTestSuite_LDFLAGS = $(BOOST_LIBS) $(CPPUNIT_LIBS) \ $(EXTRACC_LIBS) $(STDAIR_LIBS) ForecasterTestSuite_SOURCES = ForecasterTestSuite.hpp ForecasterTestSuite.cpp Modified: trunk/rmol/test/rmol/SimulateTestSuite.cpp =================================================================== --- trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-09-27 11:36:24 UTC (rev 338) +++ trunk/rmol/test/rmol/SimulateTestSuite.cpp 2010-09-27 11:37:00 UTC (rev 339) @@ -1,64 +1,58 @@ // STL #include <iostream> #include <sstream> -// Boost (Extended STL) +// Boost Date-Time #include <boost/date_time/posix_time/posix_time.hpp> -// GSL Random Number Generation (GSL Reference Manual, version 1.7, Chapter 17) -#include <gsl/gsl_rng.h> -// GSL Random Number Distributions (GSL Reference Manual, version 1.7, -// Chapter 19) -#include <gsl/gsl_randist.h> -// CPPUNIT +// Boost Random +#include <boost/random/linear_congruential.hpp> +#include <boost/random/poisson_distribution.hpp> +#include <boost/random/exponential_distribution.hpp> +#include <boost/random/variate_generator.hpp> +// Boost Math +#include <boost/math/distributions/normal.hpp> +// Extra-CPPUnit #include <extracppunit/CppUnitCore.hpp> // RMOL Test Suite #include <test/rmol/SimulateTestSuite.hpp> -// Random Generator Type -const gsl_rng_type* _rngTypePtr = NULL; +// ////////// Type definitions ////////// +/** Type definition for a random number generator base (mt19937). */ +typedef boost::minstd_rand base_generator_type; -// Random Generator -gsl_rng* _rngExponentialPtr = NULL; -gsl_rng* _rngPoissonPtr = NULL; +/** Type definition for the random generator seed. + <br>That seed must be unsigned, otherwise the wrong overload may be + selected when using mt19937 as the base_generator_type. */ +typedef unsigned int random_generator_seed_type; -// /////////////////////////////////////////////////// -void init () { - // Random Generator type - _rngTypePtr = gsl_rng_default; +/** Type definiton for the Poisson distribution (characteristics). */ +typedef boost::poisson_distribution<> poisson_dist_type; + +/** Type definiton for the exponential distribution (characteristics). */ +typedef boost::exponential_distribution<> exponential_dist_type; + +/** Type definition for the Poisson distribution random generator. */ +typedef boost::variate_generator<base_generator_type&, + poisson_dist_type> poisson_gen_type; - // Initialise the Random Generator - gsl_rng_env_setup (); +/** Type definition for the exponential distribution random generator. */ +typedef boost::variate_generator<base_generator_type&, + exponential_dist_type> exponential_gen_type; - // Allocate the memory for the random generator - _rngExponentialPtr = gsl_rng_alloc (_rngTypePtr); - _rngPoissonPtr = gsl_rng_alloc (_rngTypePtr); -} - -// /////////////////////////////////////////////////// -double generateExponentialVariate (const double iLambda) { - const double lMu = 1/iLambda; - double result = gsl_ran_exponential (_rngExponentialPtr, lMu); - return result; -} - -// /////////////////////////////////////////////////// -double generatePoissonVariate (const double iMu) { - double result = gsl_ran_poisson (_rngPoissonPtr, iMu); - return result; -} - -// /////////////////////////////////////////////////// -void finalise () { - gsl_rng_free (_rngExponentialPtr); - gsl_rng_free (_rngPoissonPtr); -} - // ////////////////////////////////////////////////////////////////////// void testSimulateHelper() { + try { // Output log File std::string lLogFilename ("SimulateTestSuite.log"); + // Set the log parameters + std::ofstream logOutputFile; + + // Open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + // Time duration representing a full day // (i.e., 24h or 1,440 minutes or 86,400 seconds) const boost::posix_time::time_duration kDay (24, 0, 0, 0); @@ -67,15 +61,31 @@ const int kSimulationLength = 365; // Rate, expressed as a number of events per day - // (lambda => mu = 1/ lambda) + // (lambda => mu = 1 / lambda) const double lambda = 10.0; + const double mu = 1 / lambda; // mu = 0.1 (= 2.4h, i.e., in average, an event occurs every 2.4h) // Initialisation of random generators - init(); + /** Base for the random generator. */ + base_generator_type lGenerator (42u); + /** Poisson distribution. */ + exponential_dist_type lExponentialDistribution (mu); + + /** Random generator for the Poisson distribution. */ + exponential_gen_type lExponentialDistributionGenerator (lGenerator, + lExponentialDistribution); + + /** Poisson distribution. */ + poisson_dist_type lPoissonDistribution (lambda); + + /** Random generator for the Poisson distribution. */ + poisson_gen_type lPoissonDistributionGenerator (lGenerator, + lPoissonDistribution); + // Generate k draws - // std::cout << "Event#; Time; " << std::endl; + logOutputFile << "Event#; Time; " << std::endl; for (int i=1; i != kSimulationLength; i++) { // Current time @@ -87,29 +97,29 @@ // Repeat until the current time exceeds 24h (i.e., 86,400 seconds) while (lCurrentTime <= kDay) { const double lExponentialVariateDay = - generateExponentialVariate (lambda); + lExponentialDistributionGenerator(); const long int lExponentialVariateHours = static_cast<long int> (lExponentialVariateDay * 24); const boost::posix_time::time_duration lExponentialVariateSeconds = boost::posix_time::hours (lExponentialVariateHours); // Add an event - lEventNumber++; + ++lEventNumber; // Add the inter-arrival time to the current time lCurrentTime += lExponentialVariateSeconds; - // const double lPoissonVariate = generatePoissonVariate (lambda); - - // std::cout << lEventNumber << "; " << lCurrentTime << "; " << std::endl; + // const double lPoissonVariate = lPoissonDistributionGenerator(); + logOutputFile << lEventNumber << "; " << lCurrentTime << "; " + << std::endl; } } - // Cleaning of random generators - finalise(); - // TODO: check that the average number of events corresponds to the given // input + + // Close the log file + logOutputFile.close(); } catch (const std::exception& stde) { std::cerr << "Standard exception: " << stde.what() << std::endl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-27 11:36:32
|
Revision: 338 http://rmol.svn.sourceforge.net/rmol/?rev=338&view=rev Author: denis_arnaud Date: 2010-09-27 11:36:24 +0000 (Mon, 27 Sep 2010) Log Message: ----------- [Dev] Replaced calls to the GSL (GNU Scientific Library) by Boost.Math. Modified Paths: -------------- trunk/rmol/rmol/bom/DPOptimiser.cpp trunk/rmol/rmol/bom/EmsrUtils.cpp trunk/rmol/rmol/bom/ExpectationMaximization.cpp trunk/rmol/rmol/bom/Gaussian.cpp trunk/rmol/rmol/bom/Gaussian.hpp trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp trunk/rmol/rmol/bom/HistoricalDataHolder.cpp trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp trunk/rmol/rmol/bom/MCOptimiser.cpp trunk/rmol/rmol/bom/Makefile.am trunk/rmol/rmol/bom/Overbooking.cpp trunk/rmol/rmol/core/Makefile.am trunk/rmol/rmol/service/RMOL_ServiceContext.cpp Modified: trunk/rmol/rmol/bom/DPOptimiser.cpp =================================================================== --- trunk/rmol/rmol/bom/DPOptimiser.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/DPOptimiser.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,14 +1,13 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Generation (GSL Reference Manual, version 1.7, Chapter 19) -#include <gsl/gsl_cdf.h> -#include <gsl/gsl_randist.h> // STL #include <cassert> #include <sstream> #include <vector> #include <cmath> +// Boost Math +#include <boost/math/distributions/normal.hpp> // StdAir #include <stdair/service/Logger.hpp> // RMOL @@ -55,7 +54,7 @@ const double meanDemand = currentBucket.getMean(); const double SDDemand = currentBucket.getStandardDeviation(); const double currentYield = currentBucket.getAverageYield(); - const double errorFactor = 1;//gsl_cdf_gaussian_Q (-meanDemand, SDDemand); + const double errorFactor = 1.0; Bucket& nextBucket = ioBucketHolder.getNextBucket(); const double nextYield = nextBucket.getAverageYield(); @@ -63,23 +62,27 @@ // For x <= currentProtection (y_(j-1)), V_j(x) = V_(j-1)(x). for (int x = 0; x <= currentProtection; ++x) { const double MERValue = MERVectorHolder.at(currentBucketIndex-1).at(x); - currentMERVector.push_back(MERValue); + currentMERVector.push_back (MERValue); } + + // + boost::math::normal lNormalDistribution (meanDemand, SDDemand); // Vector of gaussian pdf values. std::vector<double> pdfVector; for (int s = 0; s <= maxValue - currentProtection; ++s) { const double pdfValue = - gsl_ran_gaussian_pdf (s/DEFAULT_PRECISION - meanDemand, SDDemand); - pdfVector.push_back(pdfValue); + boost::math::pdf (lNormalDistribution, s/DEFAULT_PRECISION); + pdfVector.push_back (pdfValue); } // Vector of gaussian cdf values. std::vector<double> cdfVector; for (int s = 0; s <= maxValue - currentProtection; ++s) { const double cdfValue = - cdfGaussianQ (s/DEFAULT_PRECISION - meanDemand, SDDemand); - cdfVector.push_back(cdfValue); + boost::math::cdf (boost::math::complement (lNormalDistribution, + s/DEFAULT_PRECISION)); + cdfVector.push_back (cdfValue); } // Compute V_j(x) for x > currentProtection (y_(j-1)). @@ -88,31 +91,31 @@ // Compute the first integral in the V_j(x) formulation (see // the memo of Jerome Contant). - const double power1 = - 0.5 * meanDemand * meanDemand / - (SDDemand * SDDemand); + const double power1 = + - 0.5 * meanDemand * meanDemand / (SDDemand * SDDemand); const double e1 = std::exp (power1); const double power2 = - - 0.5 * (lowerBound / DEFAULT_PRECISION - meanDemand) * - (lowerBound / DEFAULT_PRECISION - meanDemand) / - (SDDemand * SDDemand); - const double e2 = exp (power2); - /* - const double integralResult1 = currentYield * - ((e1 - e2) * SDDemand / sqrt (2 * 3.14159265) + - meanDemand * gsl_cdf_gaussian_Q (-meanDemand, SDDemand) - - meanDemand * gsl_cdf_gaussian_Q (lowerBound / DEFAULT_PRECISION - meanDemand, SDDemand)); - */ - const double integralResult1 = currentYield * - ((e1 - e2) * SDDemand / sqrt (2 * 3.14159265) + - meanDemand * cdfGaussianQ (-meanDemand, SDDemand) - - meanDemand * cdfGaussianQ (lowerBound / DEFAULT_PRECISION - meanDemand, SDDemand)); + - 0.5 * (lowerBound / DEFAULT_PRECISION - meanDemand) + * (lowerBound / DEFAULT_PRECISION - meanDemand) + / (SDDemand * SDDemand); + const double e2 = std::exp (power2); + + const double cdfValue0 = + boost::math::cdf (boost::math::complement (lNormalDistribution, + 0.0)); + const double cdfValue1 = + boost::math::cdf(boost::math::complement(lNormalDistribution, + lowerBound/DEFAULT_PRECISION)); + const double integralResult1 = currentYield + * ((e1 - e2) * SDDemand / sqrt (2 * 3.14159265) + + meanDemand * (cdfValue0 - cdfValue1)); double integralResult2 = 0.0; for (int s = 0; s < lowerBound; ++s) { const double partialResult = - 2 * MERVectorHolder.at(currentBucketIndex-1).at(x-s) * - pdfVector.at(s); + 2 * MERVectorHolder.at(currentBucketIndex-1).at(x-s) + * pdfVector.at(s); integralResult2 += partialResult; } @@ -139,11 +142,13 @@ // Compute the second integral in the V_j(x) formulation (see // the memo of Jerome Contant). const double constCoefOfSecondElement = - currentYield * lowerBound / DEFAULT_PRECISION + - MERVectorHolder.at(currentBucketIndex-1).at(currentProtection); - const double secondElement = constCoefOfSecondElement * - //gsl_cdf_gaussian_Q(lowerBound / DEFAULT_PRECISION - meanDemand, SDDemand); - cdfGaussianQ (lowerBound / DEFAULT_PRECISION - meanDemand, SDDemand); + currentYield * lowerBound / DEFAULT_PRECISION + + MERVectorHolder.at(currentBucketIndex-1).at(currentProtection); + + const double secondElement = constCoefOfSecondElement + * boost::math::cdf(boost::math::complement(lNormalDistribution, + lowerBound/DEFAULT_PRECISION)); + const double MERValue = (firstElement + secondElement) / errorFactor; @@ -200,20 +205,4 @@ } } - // //////////////////////////////////////////////////////////////////// - double DPOptimiser::cdfGaussianQ (const double c, const double sd) { - const double power = - c * c * 0.625 / (sd * sd); - const double e = std::sqrt (1 - std::exp (power)); - double result = 0.0; - - if (c >= 0) { - result = 0.5 * (1 - e); - - } else { - result = 0.5 * (1 + e); - } - - return result; - } - } Modified: trunk/rmol/rmol/bom/EmsrUtils.cpp =================================================================== --- trunk/rmol/rmol/bom/EmsrUtils.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/EmsrUtils.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,11 +1,11 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Generation (GSL Reference Manual, version 1.7, Chapter 19) -#include <gsl/gsl_cdf.h> -// C -#include <math.h> -#include <assert.h> +// STL +#include <cassert> +#include <cmath> +// Boost Math +#include <boost/math/distributions/normal.hpp> // RMOL #include <rmol/bom/EmsrUtils.hpp> #include <rmol/bom/Bucket.hpp> @@ -53,17 +53,24 @@ const double lNextYield = ioNextBucket.getAverageYield(); assert (lAggreatedYield != 0); - // Compute the protection for the aggregated class/bucket - const double lProtection = - lMean + gsl_cdf_gaussian_Qinv (lNextYield/lAggreatedYield, lSD); + // Compute the yield ratio between the higher bucket and the current one + const double lYieldRatio = lNextYield / lAggreatedYield; + + /** Compute the protection for the aggregated class/bucket. + <br>Note: The inverse cdf is the quantile function (see also + http://en.wikipedia.org/wiki/Quantile_function). */ + boost::math::normal lNormalDistribution (lMean, lSD); + const double lProtection = + boost::math::quantile (boost::math::complement (lNormalDistribution, + lYieldRatio)); return lProtection; } // //////////////////////////////////////////////////////////////////// - const double EmsrUtils::computeProtectionLevelwithSellup (Bucket& iHigherBucket, - Bucket& iBucket, - double iSellupFactor){ + const double EmsrUtils:: + computeProtectionLevelwithSellup (Bucket& iHigherBucket, Bucket& iBucket, + double iSellupFactor) { // Retrieve the mean and the standard deviation of the higher // class(es)/bucket(s) depending EMSR-a or EMSR-b // and the average yield of each input classes/buckets @@ -74,25 +81,34 @@ assert (lHigherBucketYield > DEFAULT_EPSILON); assert (1-iSellupFactor > DEFAULT_EPSILON); - // compute the protection level for the higher class/bucket - const double lProtectionLevel = - lMean + - gsl_cdf_gaussian_Pinv((lHigherBucketYield-lBucketYield)/ - (lHigherBucketYield*(1-iSellupFactor)),lSD); - + // Compute the yield ratio + const double lYieldRatio = (lHigherBucketYield - lBucketYield) + / (lHigherBucketYield * (1 - iSellupFactor)); + + /** Compute the protection for the for the higher class/bucket. + <br>Note: The inverse cdf is the quantile function (see also + http://en.wikipedia.org/wiki/Quantile_function). */ + boost::math::normal lNormalDistribution (lMean, lSD); + const double lProtectionLevel = boost::math::quantile (lNormalDistribution, + lYieldRatio); + return lProtectionLevel; } // //////////////////////////////////////////////////////////////////// - const double EmsrUtils::computeEmsrValue (double iCapacity, Bucket& ioBucket) { - // Retrive the average yield, mean and standard deviation of the + const double EmsrUtils::computeEmsrValue (double iCapacity, + Bucket& ioBucket) { + // Retrieve the average yield, mean and standard deviation of the // demand of the class/bucket. const double lMean = ioBucket.getMean(); const double lSD = ioBucket.getStandardDeviation(); const double lYield = ioBucket.getAverageYield(); // Compute the EMSR value = lYield * Pr (demand >= iCapacity). - const double emsrValue = lYield * gsl_cdf_gaussian_Q(iCapacity-lMean, lSD); + boost::math::normal lNormalDistribution (lMean, lSD); + const double emsrValue = + lYield * boost::math::cdf (boost::math::complement (lNormalDistribution, + iCapacity)); return emsrValue; } Modified: trunk/rmol/rmol/bom/ExpectationMaximization.cpp =================================================================== --- trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/ExpectationMaximization.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,11 +1,11 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL -#include <gsl/gsl_cdf.h> // STL #include <cassert> #include <cmath> +// Boost Math +#include <boost/math/distributions/normal.hpp> // StdAir #include <stdair/service/Logger.hpp> // RMOL @@ -125,18 +125,21 @@ */ 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); + + // + boost::math::normal lNormalDistribution (iMean, iSD); + d1 = boost::math::cdf (boost::math::complement (lNormalDistribution, + kthCensoredData)); + e = -lerror*lerror * 0.5 / (iSD*iSD); + d2 = exp(e) * iSD / sqrt (2 * 3.14159265); if (d1 < DEFAULT_EPSILON) { - ioUnconstrainedDataHolder.push_back(kthCensoredData); + ioUnconstrainedDataHolder.push_back (kthCensoredData); + + } else { + ioUnconstrainedDataHolder.push_back (iMean + d2/d1); } - else { - ioUnconstrainedDataHolder.push_back(iMean + d2/d1); - } } } - // ////////////////////////////////////////////////////////////////////// } Modified: trunk/rmol/rmol/bom/Gaussian.cpp =================================================================== --- trunk/rmol/rmol/bom/Gaussian.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/Gaussian.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -2,76 +2,46 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Distributions (GSL Reference Manual, version 1.7, -// Chapter 19) -#include <gsl/gsl_randist.h> // RMOL #include <rmol/bom/Gaussian.hpp> namespace RMOL { // ////////////////////////////////////////////////////////////////////// - Gaussian::Gaussian () : - _rngTypePtr (gsl_rng_default), _rngPtr (NULL), - _params (FldDistributionParameters()) { - initRandomGenerator(); + Gaussian::Gaussian (const FldDistributionParameters& iParams) + : _seed (42u), _generator (42u), + _normalDistribution (iParams.getMean(), iParams.getStandardDeviation()), + _normalDistributionGenerator (_generator, _normalDistribution) { + init(); } // ////////////////////////////////////////////////////////////////////// - Gaussian::Gaussian (const Gaussian& iGaussian) : - _rngTypePtr (gsl_rng_default), _rngPtr (NULL), - _params (iGaussian.getDistributionParameters()) { - initRandomGenerator(); + void Gaussian::init() { } // ////////////////////////////////////////////////////////////////////// - Gaussian::Gaussian (const FldDistributionParameters& iParams) : - _rngTypePtr (gsl_rng_default), _rngPtr (NULL), - _params (FldDistributionParameters (iParams.getMean(), - iParams.getStandardDeviation())) { - initRandomGenerator(); - } - - // ////////////////////////////////////////////////////////////////////// Gaussian::~Gaussian() { // Release the memory for the random generator - gsl_rng_free (_rngPtr); } // ////////////////////////////////////////////////////////////////////// double Gaussian::getMean() const { - return _params.getMean(); + return _normalDistribution.mean(); } // ////////////////////////////////////////////////////////////////////// double Gaussian::getStandardDeviation() const { - return _params.getStandardDeviation(); + return _normalDistribution.sigma(); } - // ////////////////////////////////////////////////////////////////////// double Gaussian::getVariance() const { - return _params.getVariance(); + return (_normalDistribution.sigma() * _normalDistribution.sigma()); } // ////////////////////////////////////////////////////////////////////// - void Gaussian::initRandomGenerator () { - // Initialise the Random Generator - gsl_rng_env_setup (); - - // Allocate the memory for the random generator - _rngPtr = gsl_rng_alloc (_rngTypePtr); - } - - // ////////////////////////////////////////////////////////////////////// - double Gaussian::generateVariate () const { - - const double mean = getMean(); - const double standardDeviation = getStandardDeviation(); - - double result = gsl_ran_gaussian (_rngPtr, standardDeviation); - result += mean; - + double Gaussian::generateVariate() { + const double result = _normalDistributionGenerator(); return result; } Modified: trunk/rmol/rmol/bom/Gaussian.hpp =================================================================== --- trunk/rmol/rmol/bom/Gaussian.hpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/Gaussian.hpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,36 +1,61 @@ -#ifndef __RMOL_GAUSSIAN_HPP -#define __RMOL_GAUSSIAN_HPP +#ifndef __RMOL_BOM_GAUSSIAN_HPP +#define __RMOL_BOM_GAUSSIAN_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Generation (GSL Reference Manual, version 1.7, Chapter 17) -#include <gsl/gsl_rng.h> +// Boost Random +#include <boost/random/linear_congruential.hpp> +#include <boost/random/normal_distribution.hpp> +#include <boost/random/variate_generator.hpp> // RMOL #include <rmol/field/FldDistributionParameters.hpp> namespace RMOL { - /** Gaussian Distribution-based Utilities. */ + // ////////// Type definitions ////////// + /** Type definition for the random generator seed. + <br>That seed must be unsigned, otherwise the wrong overload may be + selected when using mt19937 as the base_generator_type. */ + typedef unsigned int random_generator_seed_type; + + + /** Wrapper around a random generator following a normal distribution. */ class Gaussian { + private: + // ////////// Type definitions ////////// + /** Type definition for a random number generator base (mt19937). */ + typedef boost::minstd_rand base_generator_type; + + /** Type definiton for the normal distribution (characteristics). */ + typedef boost::normal_distribution<> normal_dist_type; + + /** Type definition for the normal distribution random generator. */ + typedef boost::variate_generator<base_generator_type&, + normal_dist_type> normal_gen_type; + public: - /** Constructors. */ + /** Constructor with mean and sigma (standard deviation) for + the normal Distribution. + <br>See also + http://www.boost.org/doc/libs/1_44_0/doc/html/boost/normal_distribution.html */ + Gaussian (const FldDistributionParameters&); + + /** Destructor. */ + ~Gaussian(); + + private: + /** Default constructors. + <br>They are kept private so that the class can be instantiated only + with the public constructor. */ Gaussian (); Gaussian (const Gaussian&); - /** Constructor with mean and standard deviation of - the Gaussian Distribution. */ - Gaussian (const FldDistributionParameters&); - /** Destructors. */ - virtual ~Gaussian(); - - // Getters - /** Getter for the parameters for the Gaussian distribution (i.e., - mean and standard deviation). */ - const FldDistributionParameters& getDistributionParameters() const { - return _params; - } + /** Initialise the random generator. */ + void init(); + public: + // /////////////////// Getters ////////////////// /** Getter for the mean value. */ double getMean() const; @@ -43,20 +68,21 @@ /** Generate a Gaussian random variate (following the Gaussian distribution). */ - double generateVariate () const; + double generateVariate(); private: - // Wrapper on GSL Random Generators (type and generator) - const gsl_rng_type* _rngTypePtr; - gsl_rng* _rngPtr; + /** Seed of the random generator. */ + const random_generator_seed_type _seed; - // Gaussian distribution characteristics - FldDistributionParameters _params; + /** Base for the random generator. */ + base_generator_type _generator; - private: - // Initialise the Random Generator - void initRandomGenerator(); + /** Normal distribution. */ + normal_dist_type _normalDistribution; + + /** Random generator for the normal distribution. */ + normal_gen_type _normalDistributionGenerator; }; } -#endif // __RMOL_GAUSSIAN_HPP +#endif // __RMOL_BOM_GAUSSIAN_HPP Modified: trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,18 +1,14 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Generation -// (GSL Reference Manual, version 1.7, Chapter 19) -#include <gsl/gsl_cdf.h> -#include <gsl/gsl_randist.h> -// C -#include <assert.h> -#include <math.h> // STL +#include <cassert> #include <iostream> #include <iomanip> #include <cmath> -// RMU +// Boost Math +#include <boost/math/distributions/normal.hpp> +// RMOL #include <rmol/bom/HistoricalBooking.hpp> #include <rmol/bom/HistoricalBookingHolder.hpp> @@ -211,13 +207,15 @@ d1 = 0.5 * (1 + s); } */ + + // + boost::math::normal lNormalDistribution (iMean, iSD); + d1 = boost::math::cdf (boost::math::complement (lBooking, _capacity)); - d1 = gsl_cdf_gaussian_Q (lBooking - iMean, iSD); - e = - (lBooking - iMean) * (lBooking - iMean) * 0.5 / (iSD * iSD); e = exp (e); - d2 = e * iSD / sqrt(2 * 3.14159265); + d2 = e * iSD / sqrt (2 * 3.14159265); // std::cout << "d1, d2 = " << d1 << " " << d2 << std::endl; Modified: trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,17 +1,14 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Generation (GSL Reference Manual, version 1.7, Chapter 19) -#include <gsl/gsl_cdf.h> -#include <gsl/gsl_randist.h> -// C -#include <assert.h> -#include <math.h> // STL +#include <cassert> #include <iostream> #include <iomanip> #include <cmath> -// RMU +// Boost Math +#include <boost/math/distributions/normal.hpp> +// RMOL #include <rmol/bom/HistoricalBookingHolder.hpp> #include <rmol/bom/HistoricalBookingHolderHolder.hpp> @@ -210,9 +207,9 @@ // d1 = 0.5 * (1 + s); // } // */ - -// d1 = gsl_cdf_gaussian_Q (lBooking - iMean, iSD); - +// +// boost::math::normal lNormalDistribution (iMean, iSD); +// d1 = boost::math::cdf (boost::math::complement (lBooking, _capacity)); // e = - (lBooking - iMean) * (lBooking - iMean) * 0.5 / (iSD * iSD); // e = exp (e); Modified: trunk/rmol/rmol/bom/HistoricalDataHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalDataHolder.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/HistoricalDataHolder.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,17 +1,11 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Generation -// (GSL Reference Manual, version 1.7, Chapter 19) -#include <gsl/gsl_cdf.h> -#include <gsl/gsl_randist.h> -// C -#include <assert.h> -#include <math.h> // STL +#include <cassert> #include <iostream> //#include <iomanip> -//#include <cmath> +#include <cmath> // RMU #include <rmol/bom/HistoricalDataHolder.hpp> Modified: trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,18 +1,12 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// GSL Random Number Generation -// (GSL Reference Manual, version 1.7, Chapter 19) -// #include <gsl/gsl_cdf.h> -// #include <gsl/gsl_randist.h> -// C -// #include <assert.h> -// #include <math.h> // STL + #include <cassert> #include <iostream> -#include <iomanip> -// #include <cmath> -// RMU +//#include <iomanip> +//#include <cmath> +// RMOL #include <rmol/bom/HistoricalDataHolder.hpp> #include <rmol/bom/HistoricalDataHolderHolder.hpp> Modified: trunk/rmol/rmol/bom/MCOptimiser.cpp =================================================================== --- trunk/rmol/rmol/bom/MCOptimiser.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/MCOptimiser.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -4,9 +4,7 @@ // STL #include <cassert> #include <string> -#include <fstream> #include <sstream> -#include <cmath> // StdAir #include <stdair/basic/BasChronometer.hpp> #include <stdair/service/Logger.hpp> @@ -75,7 +73,7 @@ */ const FldDistributionParameters& aDistribParams = currentBucket.getDistributionParameters(); - const Gaussian gaussianDemandGenerator (aDistribParams); + Gaussian gaussianDemandGenerator (aDistribParams); /** DEBUG STDAIR_LOG_DEBUG ("[" << j << "]: " << Kj << " values with N ( " @@ -208,7 +206,7 @@ // STEP 1. const FldDistributionParameters& aDistribParams = currentBucket.getDistributionParameters(); - const Gaussian gaussianDemandGenerator (aDistribParams); + Gaussian gaussianDemandGenerator (aDistribParams); VariateList_T aVariateList; @@ -308,7 +306,7 @@ */ const FldDistributionParameters& aDistribParams = currentBucket.getDistributionParameters(); - const Gaussian gaussianDemandGenerator (aDistribParams); + Gaussian gaussianDemandGenerator (aDistribParams); /** DEBUG STDAIR_LOG_DEBUG ("[" << j << "]: " << Kj << " values with N ( " @@ -452,7 +450,7 @@ // STEP 1. const FldDistributionParameters& aDistribParams = currentBucket.getDistributionParameters(); - const Gaussian gaussianDemandGenerator (aDistribParams); + Gaussian gaussianDemandGenerator (aDistribParams); VariateList_T aVariateList; Modified: trunk/rmol/rmol/bom/Makefile.am =================================================================== --- trunk/rmol/rmol/bom/Makefile.am 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/Makefile.am 2010-09-27 11:36:24 UTC (rev 338) @@ -6,8 +6,8 @@ noinst_LTLIBRARIES = librmolbom.la librmolbom_la_SOURCES = $(rmol_bom_h_sources) $(rmol_bom_cc_sources) -librmolbom_la_CXXFLAGS = $(GSL_CFLAGS) $(BOOST_CFLAGS) $(STDAIR_CFLAGS) -librmolbom_la_LDFLAGS = $(GSL_LIBS) +librmolbom_la_CXXFLAGS = $(BOOST_CFLAGS) $(STDAIR_CFLAGS) +librmolbom_la_LDFLAGS = # #pkgincludedir = $(includedir)/@PACKAGE@/bom Modified: trunk/rmol/rmol/bom/Overbooking.cpp =================================================================== --- trunk/rmol/rmol/bom/Overbooking.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/bom/Overbooking.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -1,16 +1,14 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> // STL -#include <iostream> -// GSL -#include <gsl/gsl_sys.h> -#include <gsl/gsl_math.h> -#include <gsl/gsl_sf.h> -#include <gsl/gsl_randist.h> -#include <gsl/gsl_cdf.h> +#include <cassert> +// Boost Math +#include <boost/math/special_functions/pow.hpp> +#include <boost/math/special_functions/powm1.hpp> +#include <boost/math/special_functions/round.hpp> +#include <boost/math/distributions/binomial.hpp> +#include <boost/math/distributions/normal.hpp> // RMOL #include <rmol/basic/BasConst_Overbooking.hpp> #include <rmol/bom/Overbooking.hpp> @@ -335,9 +333,13 @@ const double lDemandStdDev = _demandDistributionParameters.getStandardDeviation(); + boost::math::normal lNormalDistribution (lDemandMean, + lDemandStdDev); + // Algorithm double pNormal = - gsl_cdf_gaussian_Q (_capacity - lDemandMean, lDemandStdDev); + boost::math::cdf (boost::math::complement (lNormalDistribution, + _capacity)); // double pNormal = probabilityNormal (CAPACITY, DEMAND_AVERAGE, // DEMAND_DEVIATION); @@ -348,20 +350,22 @@ } assert (PRICE_OVER_DENIED_COST < 1 - pNormal); - pNormal = gsl_cdf_gaussian_Q (_capacity - 1 - lDemandMean, - lDemandStdDev); + pNormal = + boost::math::cdf (boost::math::complement (lNormalDistribution, + _capacity - 1)); // pNormal = probabilityNormal (CAPACITY-1, DEMAND_AVERAGE, // DEMAND_DEVIATION); const double lNoShowMean = _noShowDistributionParameters.getMean(); - - double lProbability = (1 - pNormal) - * gsl_sf_pow_int (lNoShowMean, _capacity); + double lProbability = + (1 - pNormal) * (boost::math::powm1 (lNoShowMean, _capacity) + 1); + int counter = 1; - while ((lProbability < PRICE_OVER_DENIED_COST) && (counter < 100)) { - counter++; + while (lProbability < PRICE_OVER_DENIED_COST && counter < 100) { + ++counter; + if (resultBookingLimit >= MAX_BOOKING_LIMIT) { return resultBookingLimit; @@ -371,7 +375,9 @@ const unsigned int b = static_cast<unsigned int> (resultBookingLimit); - pNormal = gsl_cdf_gaussian_Q (b + 1 - lDemandMean, lDemandStdDev); + pNormal = + boost::math::cdf (boost::math::complement (lNormalDistribution, + b + 1)); // pNormal = probabilityNormal (b+1, DEMAND_AVERAGE, DEMAND_DEVIATION); @@ -380,51 +386,30 @@ // assert (b >= 0); (derived from the other two) - // The cumulated probability that the number of shows exceeds - // the leg/cabin physical capacity - lProbability += (1+pNormal) - * lNoShowMean * gsl_ran_binomial_pdf (_capacity-1, lNoShowMean, b); - + /** + The probability that the number of shows exceeds the leg/cabin + physical capacity follows a binomial distribution, with the following + parameters:<br> + <ul> + <li>"Probability of success (== no-show)": p == lNoShowMean</li> + <li>"Number of trials (== bookings)": n == b</li> + <li>"Number of successes (no-shows)": k == _capacity - 1</li> + </ul> */ + boost::math::binomial lBinomialDistribution (lNoShowMean, b); + lProbability += (1 + pNormal) * lNoShowMean + * boost::math::pdf (lBinomialDistribution, _capacity-1); } return resultBookingLimit; } - // Private useful functions, some of them are to be replaced by gsl - // library's functions + // Private useful functions // ////////////////////////////////////////////////////////////////////// - //to be deleted, already available in gsl lib - //cumulated binomial probability - double Overbooking::probabilityNormal (const int b, const double average, - const double sdeviation) const { - double resultCdf = 0.0; - for (int i=0; i < b+1 ; i++) { - resultCdf += 1 /( sqrt(2 * M_PI) ) - * gsl_sf_exp (-1* (gsl_sf_pow_int(i-average, 2)) / (2*sdeviation)); - } - return resultCdf; - } - - // ////////////////////////////////////////////////////////////////////// - - // to be deleted, already available in gsl lib, gsl_ran_binomial_pdf(unsigned int k, double SHOW_RATE, unsigned int b) - double Overbooking::binomialProbability_F_b_s (const double iShowRate, - const int b, - const int k) const { - double Factorials = gsl_sf_fact(b)/gsl_sf_fact(k)/gsl_sf_fact(b-k); - double f = Factorials* - gsl_sf_pow_int(iShowRate, k)*gsl_sf_pow_int(1-iShowRate, b-k) ; - - return f; - } - // pSHOW_RATEbability to deny one or more services // ////////////////////////////////////////////////////////////////////// - - ////////////// Private functions for Servive level policies///////////// // service level 1 : cumulated probability of having no-shows @@ -432,10 +417,21 @@ // ////////////////////////////////////////////////////////////////////// double Overbooking::serviceLevel1 (const double iShowRate, - const int b, const int C) const { - double resultProbability = 1.0; - for (int i = 1; i<=C; i++) { - resultProbability -= gsl_ran_binomial_pdf (i, iShowRate, b);} + const int b, const int iCapacity) const { + + /** + The probability that the number of shows exceeds the leg/cabin + physical capacity follows a binomial distribution, with the following + parameters:<br> + <ul> + <li>"Probability of success (== no-show)": p == iShowRate</li> + <li>"Number of trials (== bookings)": n == b</li> + <li>"Number of successes (no-shows)": k == iCapacity</li> + </ul> */ + boost::math::binomial lBinomialDistribution (iShowRate, b); + const double resultProbability = + boost::math::cdf (lBinomialDistribution, iCapacity); + return resultProbability; } Modified: trunk/rmol/rmol/core/Makefile.am =================================================================== --- trunk/rmol/rmol/core/Makefile.am 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/core/Makefile.am 2010-09-27 11:36:24 UTC (rev 338) @@ -22,6 +22,6 @@ $(top_builddir)/rmol/service/librmolsvc.la librmol_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ - $(BOOST_FILESYSTEM_LIB) $(STDAIR_LIBS) $(GSL_LIBS) \ + $(BOOST_FILESYSTEM_LIB) $(STDAIR_LIBS) \ -version-info $(GENERIC_LIBRARY_VERSION) Modified: trunk/rmol/rmol/service/RMOL_ServiceContext.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_ServiceContext.cpp 2010-09-13 18:56:50 UTC (rev 337) +++ trunk/rmol/rmol/service/RMOL_ServiceContext.cpp 2010-09-27 11:36:24 UTC (rev 338) @@ -120,11 +120,11 @@ lDemandVector.reserve (K); const FldDistributionParameters aDistributionParam = FldDistributionParameters (iMean, iDeviation); - const Gaussian gaussianDemandGenerator (aDistributionParam); + Gaussian gaussianDemandGenerator (aDistributionParam); // Generate K numbers for (int i = 0; i < K; ++i) { - const double lGeneratedDemand = gaussianDemandGenerator.generateVariate (); + const double lGeneratedDemand= gaussianDemandGenerator.generateVariate (); lDemandVector.push_back (lGeneratedDemand); } @@ -137,17 +137,26 @@ GeneratedDemandVector_T* ioSecondVector) { if (ioFirstVector == NULL || ioSecondVector == NULL) { return NULL; + } else { + assert (ioFirstVector != NULL); + assert (ioSecondVector != NULL); + const unsigned int K = ioFirstVector->size(); assert (K == ioSecondVector->size()); + _generatedDemandVectorHolder.push_back (DEFAULT_GENERATED_DEMAND_VECTOR); GeneratedDemandVectorHolder_T::reverse_iterator itLastVector = _generatedDemandVectorHolder.rbegin(); + GeneratedDemandVector_T& lDemandVector = *itLastVector; lDemandVector.reserve (K); - for (unsigned int i = 0; i < K; ++i) { - const double lGeneratedDemand = - ioFirstVector->at(i) + ioSecondVector->at(i); + GeneratedDemandVector_T::const_iterator itFirst = ioFirstVector->begin(); + GeneratedDemandVector_T::const_iterator itSecond= ioSecondVector->begin(); + for ( ; itFirst != ioFirstVector->end(); ++itFirst, ++itSecond) { + const double& lFirst = *itFirst; + const double& lSecond = *itSecond; + const double lGeneratedDemand = lFirst + lSecond; lDemandVector.push_back (lGeneratedDemand); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-13 18:56:58
|
Revision: 337 http://rmol.svn.sourceforge.net/rmol/?rev=337&view=rev Author: denis_arnaud Date: 2010-09-13 18:56:50 +0000 (Mon, 13 Sep 2010) Log Message: ----------- [Test] Moved the valarrays test into a dedicated sub-directory. Modified Paths: -------------- trunk/rmol/configure.ac trunk/rmol/test/Makefile.am Added Paths: ----------- trunk/rmol/test/valarrays/ trunk/rmol/test/valarrays/Makefile.am trunk/rmol/test/valarrays/valarrays.cpp Removed Paths: ------------- trunk/rmol/test/valarrays.cpp Property Changed: ---------------- trunk/rmol/ trunk/rmol/test/ Property changes on: trunk/rmol ___________________________________________________________________ Modified: svn:externals - config https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config test/samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples + https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config config Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2010-09-13 16:42:57 UTC (rev 336) +++ trunk/rmol/configure.ac 2010-09-13 18:56:50 UTC (rev 337) @@ -365,6 +365,7 @@ po/Makefile.in test/Makefile test/samples/Makefile + test/valarrays/Makefile test/rmol/Makefile win32/Makefile) AC_OUTPUT 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 bomsforforecaster bomsforforecaster.log + .deps .libs Makefile Makefile.in Modified: svn:externals - + https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples samples Modified: trunk/rmol/test/Makefile.am =================================================================== --- trunk/rmol/test/Makefile.am 2010-09-13 16:42:57 UTC (rev 336) +++ trunk/rmol/test/Makefile.am 2010-09-13 18:56:50 UTC (rev 337) @@ -4,18 +4,13 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = rmol +SUBDIRS = rmol valarrays ## -EXTRA_TESTS = valarrays +EXTRA_TESTS = STD_CHECKS = check_PROGRAMS = $(STD_CHECKS) $(EXTRA_TESTS) TESTS = $(STD_CHECKS) -XFAIL_TESTS = #valarrays +XFAIL_TESTS = # - -valarrays_SOURCES = valarrays.cpp -valarrays_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) -valarrays_LDADD = -valarrays_LDFLAGS = $(BOOST_LIBS) Property changes on: trunk/rmol/test/valarrays ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile valarrays Added: trunk/rmol/test/valarrays/Makefile.am =================================================================== --- trunk/rmol/test/valarrays/Makefile.am (rev 0) +++ trunk/rmol/test/valarrays/Makefile.am 2010-09-13 18:56:50 UTC (rev 337) @@ -0,0 +1,22 @@ +## test/valarrays sub-directory +include $(top_srcdir)/Makefile.common + +MAINTAINERCLEANFILES = Makefile.in + +## +SUBDIRS = + +## +EXTRA_TESTS = valarrays + +STD_CHECKS = +check_PROGRAMS = $(STD_CHECKS) $(EXTRA_TESTS) +TESTS = $(STD_CHECKS) +XFAIL_TESTS = #valarrays + + +valarrays_SOURCES = valarrays.cpp +valarrays_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) +valarrays_LDADD = +valarrays_LDFLAGS = $(BOOST_LIBS) + Copied: trunk/rmol/test/valarrays/valarrays.cpp (from rev 336, trunk/rmol/test/valarrays.cpp) =================================================================== --- trunk/rmol/test/valarrays/valarrays.cpp (rev 0) +++ trunk/rmol/test/valarrays/valarrays.cpp 2010-09-13 18:56:50 UTC (rev 337) @@ -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; +} Deleted: trunk/rmol/test/valarrays.cpp =================================================================== --- trunk/rmol/test/valarrays.cpp 2010-09-13 16:42:57 UTC (rev 336) +++ trunk/rmol/test/valarrays.cpp 2010-09-13 18:56:50 UTC (rev 337) @@ -1,58 +0,0 @@ -// ////////////////////////////////////////////////////////////// -// 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: <den...@us...> - 2010-09-13 16:43:03
|
Revision: 336 http://rmol.svn.sourceforge.net/rmol/?rev=336&view=rev Author: denis_arnaud Date: 2010-09-13 16:42:57 +0000 (Mon, 13 Sep 2010) Log Message: ----------- [Dev] Fixed a small typo in the Makefile.am. Modified Paths: -------------- trunk/rmol/rmol/command/Makefile.am Modified: trunk/rmol/rmol/command/Makefile.am =================================================================== --- trunk/rmol/rmol/command/Makefile.am 2010-09-07 17:37:53 UTC (rev 335) +++ trunk/rmol/rmol/command/Makefile.am 2010-09-13 16:42:57 UTC (rev 336) @@ -7,7 +7,7 @@ librmolcmd_la_SOURCES = $(rmol_cmd_h_sources) $(rmol_cmd_cc_sources) librmolcmd_la_CXXFLAGS = $(BOOST_CFLAGS) $(STDAIR_CFLAGS) -librmolbas_la_LDFLAGS = +librmolcmd_la_LDFLAGS = # #pkgincludedir = $(includedir)/@PACKAGE@/command This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-07 17:37:59
|
Revision: 335 http://rmol.svn.sourceforge.net/rmol/?rev=335&view=rev Author: denis_arnaud Date: 2010-09-07 17:37:53 +0000 (Tue, 07 Sep 2010) Log Message: ----------- [Branch 0.23.0] Fixed wrong tab in the main Makefile. Modified Paths: -------------- branches/rmol/0.23.0/main/Makefile.am branches/rmol/0.23.0/main/configure.ac branches/rmol/0.23.0/main/rmol.spec.in Modified: branches/rmol/0.23.0/main/Makefile.am =================================================================== --- branches/rmol/0.23.0/main/Makefile.am 2010-09-07 07:24:14 UTC (rev 334) +++ branches/rmol/0.23.0/main/Makefile.am 2010-09-07 17:37:53 UTC (rev 335) @@ -49,7 +49,7 @@ snapshot-src: - $(MAKE) dist distdir=@PACKAGE_TARNAME@-`date +"%Y%m%d"` + $(MAKE) dist distdir=@PACKAGE_TARNAME@-`date +"%Y%m%d"` snapshot-html: $(MAKE) -C doc dist-html html_tarname=@PACKAGE_TARNAME@-doc-`date +"%Y%m%d"` Modified: branches/rmol/0.23.0/main/configure.ac =================================================================== --- branches/rmol/0.23.0/main/configure.ac 2010-09-07 07:24:14 UTC (rev 334) +++ branches/rmol/0.23.0/main/configure.ac 2010-09-07 17:37:53 UTC (rev 335) @@ -2,7 +2,7 @@ #------------------------------------------------------------------- AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (C) 2007-2010 Denis Arnaud <den...@us...>]) -AC_INIT([RMOL],[0.23.0],[den...@us...],[rmol]) +AC_INIT([RMOL],[0.23.1],[den...@us...],[rmol]) AC_CONFIG_HEADER([rmol/config.h]) AC_CONFIG_SRCDIR([rmol/basic/BasConst.cpp]) AC_CONFIG_AUX_DIR([config]) Modified: branches/rmol/0.23.0/main/rmol.spec.in =================================================================== --- branches/rmol/0.23.0/main/rmol.spec.in 2010-09-07 07:24:14 UTC (rev 334) +++ branches/rmol/0.23.0/main/rmol.spec.in 2010-09-07 17:37:53 UTC (rev 335) @@ -130,6 +130,9 @@ %changelog +* Tue Sep 07 2010 Denis Arnaud <den...@m4...> 0.23.1-1 +- Upstream integration + * Tue Sep 15 2009 Denis Arnaud <den...@m4...> 0.23.0-1 - Upstream integration @@ -159,3 +162,4 @@ * Wed Mar 4 2009 Denis Arnaud <den...@m4...> 0.18.0-1 - Second RPM release + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-07 07:24:21
|
Revision: 334 http://rmol.svn.sourceforge.net/rmol/?rev=334&view=rev Author: denis_arnaud Date: 2010-09-07 07:24:14 +0000 (Tue, 07 Sep 2010) Log Message: ----------- [Build] Fixed missing dependencies on StdAir. Modified Paths: -------------- trunk/rmol/configure.ac Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2010-09-06 20:58:49 UTC (rev 333) +++ trunk/rmol/configure.ac 2010-09-07 07:24:14 UTC (rev 334) @@ -109,10 +109,6 @@ # ----------------------------------------------------------------------------- # Support for ExtraCC (Extra-CruiseControl): http://sf.net/projects/extracc # ----------------------------------------------------------------------------- -# Note: the ExtraCC is now imported as a Subversion external reference, -# thus directly accessible within the extracppunit directory. -# When that library will be widely avaible on Linux distributions, -# the external reference can be removed and the following line uncommented. AM_PATH_EXTRACC AC_SUBST(EXTRACC_VERSION) AC_SUBST(EXTRACC_CFLAGS) @@ -188,10 +184,6 @@ # ----------------------------------------------------------------------------- # Support for StdAir (): http://sf.net/projects/stdair # ----------------------------------------------------------------------------- -# Note: the StdAir is now imported as a Subversion external reference, -# thus directly accessible within the extracppunit directory. -# When that library will be widely avaible on Linux distributions, -# the external reference can be removed and the following line uncommented. AM_PATH_STDAIR AC_SUBST(STDAIR_VERSION) AC_SUBST(STDAIR_CFLAGS) @@ -454,7 +446,7 @@ o SOCI_CFLAGS ..... : ${SOCI_CFLAGS} o SOCI_LIBS ....... : ${SOCI_LIBS} - - StdAir ........... : + - StdAir ............ : o STDAIR_VERSION .. : ${STDAIR_VERSION} o STDAIR_CFLAGS ... : ${STDAIR_CFLAGS} o STDAIR_LIBS ..... : ${STDAIR_LIBS} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-06 20:58:55
|
Revision: 333 http://rmol.svn.sourceforge.net/rmol/?rev=333&view=rev Author: denis_arnaud Date: 2010-09-06 20:58:49 +0000 (Mon, 06 Sep 2010) Log Message: ----------- [Build] Changed the dependency on StdAir, which is no longer an external Subversion reference. Modified Paths: -------------- trunk/rmol/test/rmol/Makefile.am Modified: trunk/rmol/test/rmol/Makefile.am =================================================================== --- trunk/rmol/test/rmol/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) +++ trunk/rmol/test/rmol/Makefile.am 2010-09-06 20:58:49 UTC (rev 333) @@ -18,38 +18,41 @@ XFAIL_TESTS = #OptimiseTestSuite OptimiseTestSuite_SOURCES = OptimiseTestSuite.hpp OptimiseTestSuite.cpp -OptimiseTestSuite_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) +OptimiseTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ + $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) OptimiseTestSuite_LDADD = OptimiseTestSuite_LDFLAGS = $(BOOST_LIBS) $(CPPUNIT_LIBS) \ - $(top_builddir)/extracppunit/libextracppunit.la \ - $(top_builddir)/stdair/core/libstdair.la \ + $(EXTRACC_LIBS) $(STDAIR_LIBS) \ $(top_builddir)/rmol/core/librmol.la SimulateTestSuite_SOURCES = SimulateTestSuite.hpp SimulateTestSuite.cpp -SimulateTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(GSL_CFLAGS) $(CPPUNIT_CFLAGS) +SimulateTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(GSL_CFLAGS) $(CPPUNIT_CFLAGS) \ + $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) SimulateTestSuite_LDADD = SimulateTestSuite_LDFLAGS = $(BOOST_LIBS) $(GSL_LIBS) $(CPPUNIT_LIBS) \ - $(top_builddir)/extracppunit/libextracppunit.la + $(EXTRACC_LIBS) $(STDAIR_LIBS) ForecasterTestSuite_SOURCES = ForecasterTestSuite.hpp ForecasterTestSuite.cpp -ForecasterTestSuite_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) +ForecasterTestSuite_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ + $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) ForecasterTestSuite_LDADD = ForecasterTestSuite_LDFLAGS = $(BOOST_LIBS) $(CPPUNIT_LIBS) \ - $(top_builddir)/extracppunit/libextracppunit.la \ - $(top_builddir)/stdair/core/libstdair.la \ + $(EXTRACC_LIBS) $(STDAIR_LIBS) \ $(top_builddir)/rmol/core/librmol.la UnconstrainerTestSuite_SOURCES = UnconstrainerTestSuite.hpp \ UnconstrainerTestSuite.cpp -UnconstrainerTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS) +UnconstrainerTestSuite_CXXFLAGS = $(CPPUNIT_CFLAGS) \ + $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) UnconstrainerTestSuite_LDADD = UnconstrainerTestSuite_LDFLAGS = $(CPPUNIT_LIBS) \ - $(top_builddir)/extracppunit/libextracppunit.la \ - $(top_builddir)/stdair/core/libstdair.la \ + $(EXTRACC_LIBS) $(STDAIR_LIBS) \ $(top_builddir)/rmol/core/librmol.la bomsforforecaster_SOURCES = bomsforforecaster.cpp -bomsforforecaster_CXXFLAGS= $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) +bomsforforecaster_CXXFLAGS = $(BOOST_CFLAGS) $(CPPUNIT_CFLAGS) \ + $(EXTRACC_CFLAGS) $(STDAIR_CFLAGS) bomsforforecaster_LDADD = bomsforforecaster_LDFLAGS = $(BOOST_LIBS) \ $(top_builddir)/rmol/core/librmol.la + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-06 19:31:19
|
Revision: 332 http://rmol.svn.sourceforge.net/rmol/?rev=332&view=rev Author: denis_arnaud Date: 2010-09-06 19:31:12 +0000 (Mon, 06 Sep 2010) Log Message: ----------- [Build] Changed the dependency on StdAir, which is no longer an external Subversion reference. Modified Paths: -------------- trunk/rmol/Makefile.am trunk/rmol/configure.ac trunk/rmol/rmol/basic/Makefile.am trunk/rmol/rmol/batches/Makefile.am trunk/rmol/rmol/bom/Makefile.am trunk/rmol/rmol/command/Makefile.am trunk/rmol/rmol/config/Makefile.am trunk/rmol/rmol/core/Makefile.am trunk/rmol/rmol/factory/Makefile.am trunk/rmol/rmol/field/Makefile.am trunk/rmol/rmol/service/Makefile.am Property Changed: ---------------- trunk/rmol/ Property changes on: trunk/rmol ___________________________________________________________________ Modified: svn:externals - config https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair extracppunit https://extracc.svn.sourceforge.net/svnroot/extracc/trunk/extracc/extracppunit test/samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples + config https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config test/samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples Modified: trunk/rmol/Makefile.am =================================================================== --- trunk/rmol/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -25,8 +25,7 @@ EXTRA_DIST = # Build in these directories: -SUBDIRS = stdair rmol win32 po man $(INFO_DOC_DIR) $(HTML_DOC_DIR) \ - samples extracppunit $(TEST_DIR) +SUBDIRS = rmol win32 po man $(INFO_DOC_DIR) $(HTML_DOC_DIR) samples $(TEST_DIR) # Configuration helpers Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/configure.ac 2010-09-06 19:31:12 UTC (rev 332) @@ -351,16 +351,6 @@ rmol-config rmol.pc rmol.m4 - stdair/Makefile - stdair/basic/Makefile - stdair/bom/Makefile - stdair/dbadaptor/Makefile - stdair/factory/Makefile - stdair/command/Makefile - stdair/service/Makefile - stdair/config/Makefile - stdair/core/Makefile - stdair/batches/Makefile rmol/Makefile rmol/basic/Makefile rmol/field/Makefile @@ -381,10 +371,8 @@ doc/local/Makefile doc/doxygen_html.cfg po/Makefile.in - extracppunit/Makefile test/Makefile test/samples/Makefile - test/stdair/Makefile test/rmol/Makefile win32/Makefile) AC_OUTPUT @@ -485,3 +473,4 @@ Now type 'make && make install' to build and install $PACKAGE-$VERSION library ------------------------------------------------------------------------------ " + Modified: trunk/rmol/rmol/basic/Makefile.am =================================================================== --- trunk/rmol/rmol/basic/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/basic/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -6,8 +6,10 @@ noinst_LTLIBRARIES = librmolbas.la librmolbas_la_SOURCES = $(rmol_bas_h_sources) $(rmol_bas_cc_sources) -librmolbas_la_CXXFLAGS = $(BOOST_CFLAGS) +librmolbas_la_CXXFLAGS = $(BOOST_CFLAGS) $(STDAIR_CFLAGS) +librmolbas_la_LDFLAGS = +# +#pkgincludedir = $(includedir)/@PACKAGE@/basic +#pkginclude_HEADERS = $(rmol_bas_h_sources) -#pkgincludedir = $(includedir)/@PACKAGE@/basic -#pkginclude_HEADERS = $(bas_h_sources) Modified: trunk/rmol/rmol/batches/Makefile.am =================================================================== --- trunk/rmol/rmol/batches/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/batches/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -11,8 +11,8 @@ bin_PROGRAMS = rmol rmol_SOURCES = $(rmol_batches_h_sources) $(rmol_batches_cc_sources) -rmol_CXXFLAGS = $(BOOST_CFLAGS) +rmol_CXXFLAGS = $(BOOST_CFLAGS) $(STDAIR_CFLAGS) #rmol_LDADD = -rmol_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(GSL_LIBS) \ - $(top_builddir)/stdair/core/libstdair.la \ +rmol_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(GSL_LIBS) $(STDAIR_LIBS) \ $(top_builddir)/rmol/core/librmol.la + Modified: trunk/rmol/rmol/bom/Makefile.am =================================================================== --- trunk/rmol/rmol/bom/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/bom/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -6,9 +6,10 @@ noinst_LTLIBRARIES = librmolbom.la librmolbom_la_SOURCES = $(rmol_bom_h_sources) $(rmol_bom_cc_sources) -librmolbom_la_CXXFLAGS = $(GSL_CFLAGS) $(BOOST_CFLAGS) +librmolbom_la_CXXFLAGS = $(GSL_CFLAGS) $(BOOST_CFLAGS) $(STDAIR_CFLAGS) librmolbom_la_LDFLAGS = $(GSL_LIBS) +# +#pkgincludedir = $(includedir)/@PACKAGE@/bom +#pkginclude_HEADERS = $(rmol_bom_h_sources) -#pkgincludedir = $(includedir)/@PACKAGE@/bom -#pkginclude_HEADERS = $(bom_h_sources) Modified: trunk/rmol/rmol/command/Makefile.am =================================================================== --- trunk/rmol/rmol/command/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/command/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -6,8 +6,10 @@ noinst_LTLIBRARIES = librmolcmd.la librmolcmd_la_SOURCES = $(rmol_cmd_h_sources) $(rmol_cmd_cc_sources) -librmolcmd_la_CXXFLAGS = $(BOOST_CFLAGS) +librmolcmd_la_CXXFLAGS = $(BOOST_CFLAGS) $(STDAIR_CFLAGS) +librmolbas_la_LDFLAGS = +# +#pkgincludedir = $(includedir)/@PACKAGE@/command +#pkginclude_HEADERS = $(rmol_cmd_h_sources) -#pkgincludedir = $(includedir)/@PACKAGE@/command -#pkginclude_HEADERS = $(cmd_h_sources) Modified: trunk/rmol/rmol/config/Makefile.am =================================================================== --- trunk/rmol/rmol/config/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/config/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -24,3 +24,4 @@ @echo '#define DATADIR "$(datadir)"' >> $@ @echo '#define DOCDIR "$(docdir)"' >> $@ @echo '#endif // __RMOL_PATHS_HPP' >> $@ + Modified: trunk/rmol/rmol/core/Makefile.am =================================================================== --- trunk/rmol/rmol/core/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/core/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -22,7 +22,6 @@ $(top_builddir)/rmol/service/librmolsvc.la librmol_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ - $(BOOST_FILESYSTEM_LIB) \ - $(top_builddir)/stdair/core/libstdair.la \ - $(GSL_LIBS) -version-info $(GENERIC_LIBRARY_VERSION) + $(BOOST_FILESYSTEM_LIB) $(STDAIR_LIBS) $(GSL_LIBS) \ + -version-info $(GENERIC_LIBRARY_VERSION) Modified: trunk/rmol/rmol/factory/Makefile.am =================================================================== --- trunk/rmol/rmol/factory/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/factory/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -6,8 +6,10 @@ noinst_LTLIBRARIES = librmolfac.la librmolfac_la_SOURCES = $(rmol_fac_h_sources) $(rmol_fac_cc_sources) -librmolfac_la_CXXFLAGS = +librmolfac_la_CXXFLAGS = $(STDAIR_CFLAGS) +librmolfac_la_LDFLAGS = +# +#pkgincludedir = $(includedir)/@PACKAGE@/factory +#pkginclude_HEADERS = $(rmol_fac_h_sources) -#pkgincludedir = $(includedir)/@PACKAGE@/factory -#pkginclude_HEADERS = $(fac_h_sources) Modified: trunk/rmol/rmol/field/Makefile.am =================================================================== --- trunk/rmol/rmol/field/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/field/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -6,8 +6,10 @@ noinst_LTLIBRARIES = librmolfld.la librmolfld_la_SOURCES = $(rmol_fld_h_sources) $(rmol_fld_cc_sources) -librmolfld_la_CXXFLAGS = +librmolfld_la_CXXFLAGS = $(STDAIR_CFLAGS) +librmolfld_la_LDFLAGS = +# +#pkgincludedir = $(includedir)/@PACKAGE@/field +#pkginclude_HEADERS = $(rmol_fld_h_sources) -#pkgincludedir = $(includedir)/@PACKAGE@/field -#pkginclude_HEADERS = $(fld_h_sources) Modified: trunk/rmol/rmol/service/Makefile.am =================================================================== --- trunk/rmol/rmol/service/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) +++ trunk/rmol/rmol/service/Makefile.am 2010-09-06 19:31:12 UTC (rev 332) @@ -6,8 +6,10 @@ noinst_LTLIBRARIES = librmolsvc.la librmolsvc_la_SOURCES = $(rmol_svc_h_sources) $(rmol_svc_cc_sources) -librmolsvc_la_CXXFLAGS = +librmolsvc_la_CXXFLAGS = $(STDAIR_CFLAGS) +librmolsvc_la_LDFLAGS = +# +#pkgincludedir = $(includedir)/@PACKAGE@/service +#pkginclude_HEADERS = $(rmol_cmd_h_sources) -#pkgincludedir = $(includedir)/@PACKAGE@/service -#pkginclude_HEADERS = $(cmd_h_sources) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-06 14:54:13
|
Revision: 331 http://rmol.svn.sourceforge.net/rmol/?rev=331&view=rev Author: denis_arnaud Date: 2010-09-06 14:54:07 +0000 (Mon, 06 Sep 2010) Log Message: ----------- [Conf] Added StdAir in the configuration dependencies. Modified Paths: -------------- trunk/rmol/rmol/Makefile.am Modified: trunk/rmol/rmol/Makefile.am =================================================================== --- trunk/rmol/rmol/Makefile.am 2010-09-06 10:28:50 UTC (rev 330) +++ trunk/rmol/rmol/Makefile.am 2010-09-06 14:54:07 UTC (rev 331) @@ -2,15 +2,16 @@ include $(top_srcdir)/Makefile.common include $(srcdir)/core/sources.mk -## Source directory +# +SUBDIRS = basic field bom factory command service core config batches +# MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic field bom factory command service core config batches - EXTRA_DIST = config_msvc.h # Header files -nobase_pkginclude_HEADERS = $(service_h_sources) +nobase_pkginclude_HEADERS = $(rmol_service_h_sources) #nobase_nodist_pkginclude_HEADERS = $(top_builddir)/@PACKAGE@/config.h + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-06 10:28:56
|
Revision: 330 http://rmol.svn.sourceforge.net/rmol/?rev=330&view=rev Author: denis_arnaud Date: 2010-09-06 10:28:50 +0000 (Mon, 06 Sep 2010) Log Message: ----------- [Conf] Added StdAir in the configuration dependencies. Modified Paths: -------------- trunk/rmol/configure.ac trunk/rmol/rmol/core/Makefile.am Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2010-08-21 20:09:56 UTC (rev 329) +++ trunk/rmol/configure.ac 2010-09-06 10:28:50 UTC (rev 330) @@ -113,10 +113,10 @@ # thus directly accessible within the extracppunit directory. # When that library will be widely avaible on Linux distributions, # the external reference can be removed and the following line uncommented. -#AM_PATH_EXTRACC -#AC_SUBST(EXTRACC_VERSION) -#AC_SUBST(EXTRACC_CFLAGS) -#AC_SUBST(EXTRACC_LIBS) +AM_PATH_EXTRACC +AC_SUBST(EXTRACC_VERSION) +AC_SUBST(EXTRACC_CFLAGS) +AC_SUBST(EXTRACC_LIBS) # --------------------------------------------------------- # GSL (GNU Scientific Library: http://gnu.org/projects/gsl) @@ -185,6 +185,17 @@ AC_SUBST(SOCI_CFLAGS) AC_SUBST(SOCI_LIBS) +# ----------------------------------------------------------------------------- +# Support for StdAir (): http://sf.net/projects/stdair +# ----------------------------------------------------------------------------- +# Note: the StdAir is now imported as a Subversion external reference, +# thus directly accessible within the extracppunit directory. +# When that library will be widely avaible on Linux distributions, +# the external reference can be removed and the following line uncommented. +AM_PATH_STDAIR +AC_SUBST(STDAIR_VERSION) +AC_SUBST(STDAIR_CFLAGS) +AC_SUBST(STDAIR_LIBS) # ------------------------------------------------------------------- # Support for documentation @@ -455,6 +466,11 @@ o SOCI_CFLAGS ..... : ${SOCI_CFLAGS} o SOCI_LIBS ....... : ${SOCI_LIBS} + - StdAir ........... : + o STDAIR_VERSION .. : ${STDAIR_VERSION} + o STDAIR_CFLAGS ... : ${STDAIR_CFLAGS} + o STDAIR_LIBS ..... : ${STDAIR_LIBS} + - ExtraCC ........... : o EXTRACC_VERSION . : ${EXTRACC_VERSION} o EXTRACC_CFLAGS .. : ${EXTRACC_CFLAGS} Modified: trunk/rmol/rmol/core/Makefile.am =================================================================== --- trunk/rmol/rmol/core/Makefile.am 2010-08-21 20:09:56 UTC (rev 329) +++ trunk/rmol/rmol/core/Makefile.am 2010-09-06 10:28:50 UTC (rev 330) @@ -25,3 +25,4 @@ $(BOOST_FILESYSTEM_LIB) \ $(top_builddir)/stdair/core/libstdair.la \ $(GSL_LIBS) -version-info $(GENERIC_LIBRARY_VERSION) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-08-21 20:10:04
|
Revision: 329 http://rmol.svn.sourceforge.net/rmol/?rev=329&view=rev Author: denis_arnaud Date: 2010-08-21 20:09:56 +0000 (Sat, 21 Aug 2010) Log Message: ----------- [Packaging] Took into account latest RPM guidelines. Modified Paths: -------------- trunk/rmol/rmol.spec Modified: trunk/rmol/rmol.spec =================================================================== --- trunk/rmol/rmol.spec 2010-08-21 20:06:18 UTC (rev 328) +++ trunk/rmol/rmol.spec 2010-08-21 20:09:56 UTC (rev 329) @@ -129,6 +129,9 @@ %changelog +* Tue Aug 21 2010 Denis Arnaud <den...@m4...> 99.99.99-1 +- Upstream integration + * Tue Sep 15 2009 Denis Arnaud <den...@m4...> 0.23.0-1 - Upstream integration This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-08-21 20:06:24
|
Revision: 328 http://rmol.svn.sourceforge.net/rmol/?rev=328&view=rev Author: denis_arnaud Date: 2010-08-21 20:06:18 +0000 (Sat, 21 Aug 2010) Log Message: ----------- [Packaging] Took into account latest RPM guidelines. Modified Paths: -------------- trunk/rmol/rmol.spec Modified: trunk/rmol/rmol.spec =================================================================== --- trunk/rmol/rmol.spec 2010-08-20 10:42:54 UTC (rev 327) +++ trunk/rmol/rmol.spec 2010-08-21 20:06:18 UTC (rev 328) @@ -49,13 +49,10 @@ %package doc Summary: HTML documentation for the %{name} library Group: Documentation -%if 0%{?fedora} >= 10 +%if 0%{?fedora} BuildArch: noarch BuildRequires: texlive-latex %endif -%if 0%{?fedora} < 10 -BuildRequires: tetex-latex -%endif %{?el5:BuildRequires: tetex-latex} BuildRequires: doxygen, ghostscript @@ -78,8 +75,10 @@ make %{?_smp_mflags} %install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT +# On Fedora, the BuildRoot is automatically cleaned. Which is not the case for +# RedHat. See: https://fedoraproject.org/wiki/Packaging/Guidelines#BuildRoot_tag +%if %{?rhel:rm -rf $RPM_BUILD_ROOT} +make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p" %find_lang %{name} # remove unpackaged files from the buildroot #rm -f $RPM_BUILD_ROOT%{_includedir}/%{name}/config.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-08-20 10:43:00
|
Revision: 327 http://rmol.svn.sourceforge.net/rmol/?rev=327&view=rev Author: denis_arnaud Date: 2010-08-20 10:42:54 +0000 (Fri, 20 Aug 2010) Log Message: ----------- [Build] Added a missing tab in the Makefile. Modified Paths: -------------- trunk/rmol/Makefile.am Modified: trunk/rmol/Makefile.am =================================================================== --- trunk/rmol/Makefile.am 2010-08-07 16:11:37 UTC (rev 326) +++ trunk/rmol/Makefile.am 2010-08-20 10:42:54 UTC (rev 327) @@ -53,7 +53,7 @@ snapshot-src: - $(MAKE) dist distdir=@PACKAGE_TARNAME@-`date +"%Y%m%d"` + $(MAKE) dist distdir=@PACKAGE_TARNAME@-`date +"%Y%m%d"` snapshot-html: $(MAKE) -C doc dist-html html_tarname=@PACKAGE_TARNAME@-doc-`date +"%Y%m%d"` @@ -74,3 +74,4 @@ upload-pdf: dist-pdf @UPLOAD_COMMAND@ @PACKAGE_TARNAME@-pdf-@VERSION@.tar.gz \ @PACKAGE_TARNAME@-pdf-@VERSION@.tar.bz2 + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-08-07 16:11:43
|
Revision: 326 http://rmol.svn.sourceforge.net/rmol/?rev=326&view=rev Author: denis_arnaud Date: 2010-08-07 16:11:37 +0000 (Sat, 07 Aug 2010) Log Message: ----------- [Dev] Added the 'built-in' command-line option, which now works. Modified Paths: -------------- trunk/rmol/rmol/batches/rmol.cpp trunk/rmol/rmol/bom/BucketHolder.cpp trunk/rmol/rmol/service/RMOL_Service.cpp Modified: trunk/rmol/rmol/batches/rmol.cpp =================================================================== --- trunk/rmol/rmol/batches/rmol.cpp 2010-08-07 09:37:43 UTC (rev 325) +++ trunk/rmol/rmol/batches/rmol.cpp 2010-08-07 16:11:37 UTC (rev 326) @@ -1,6 +1,5 @@ -// C -#include <assert.h> // STL +#include <cassert> #include <iostream> #include <sstream> #include <fstream> @@ -9,6 +8,8 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/program_options.hpp> +// StdAir +#include <stdair/service/Logger.hpp> // RMOL #include <rmol/RMOL_Service.hpp> #include <rmol/config/rmol-paths.hpp> @@ -18,6 +19,10 @@ /** Default name and location for the log file. */ const std::string K_RMOL_DEFAULT_LOG_FILENAME ("rmol.log"); +/** Default for the input type. It can be either built-in or provided by an + input file. That latter must then be given with the -i/--input option. */ +const bool K_RMOL_DEFAULT_BUILT_IN_INPUT = false; + /** Default name and location for the (CSV) input file. */ const std::string K_RMOL_DEFAULT_INPUT_FILENAME ("../../test/samples/rm01.csv"); @@ -67,9 +72,12 @@ int readConfiguration(int argc, char* argv[], int& ioRandomDraws, double& ioCapacity, RMOL::SellupProbabilityVector_T& ioSellupProbabilityVector, - short& ioMethod, std::string& ioInputFilename, - std::string& ioLogFilename) { + short& ioMethod, bool& ioIsBuiltin, + std::string& ioInputFilename, std::string& ioLogFilename){ + // Default for the built-in input + ioIsBuiltin = K_RMOL_DEFAULT_BUILT_IN_INPUT; + // Initialise the sell-up probability vector with default values initDefaultValuesForSellupProbabilityVector (ioSellupProbabilityVector); @@ -96,6 +104,8 @@ ("method,m", boost::program_options::value<short>(&ioMethod)->default_value(K_RMOL_DEFAULT_METHOD), "Revenue Management method to be used (0 = Monte-Carlo, 1 = Dynamic Programming, 2 = EMSR, 3 = EMSR-a, 4 = EMSR-b, 5 = EMSR-a with sell up probability)") + ("builtin,b", + "The cabin set up can be either built-in or parsed from an input file. That latter must then be given with the -i/--input option") ("input,i", boost::program_options::value< std::string >(&ioInputFilename)->default_value(K_RMOL_DEFAULT_INPUT_FILENAME), "(CVS) input file for the demand distributions") @@ -149,11 +159,19 @@ return K_RMOL_EARLY_RETURN_STATUS; } - if (vm.count ("input")) { - ioInputFilename = vm["input"].as< std::string >(); - std::cout << "Input filename is: " << ioInputFilename << std::endl; + if (vm.count ("builtin")) { + ioIsBuiltin = true; } + const std::string isBuiltinStr = (ioIsBuiltin == true)?"yes":"no"; + std::cout << "The BOM should be built-in? " << isBuiltinStr << std::endl; + if (ioIsBuiltin == false) { + if (vm.count ("input")) { + ioInputFilename = vm["input"].as< std::string >(); + std::cout << "Input filename is: " << ioInputFilename << std::endl; + } + } + if (vm.count ("log")) { ioLogFilename = vm["log"].as< std::string >(); std::cout << "Log filename is: " << ioLogFilename << std::endl; @@ -195,6 +213,9 @@ // 2 = EMSR, 3 = EMSR-a, 4 = EMSR-b, 5 = EMSR-a with sell up probability) short lMethod = 0; + // Built-in + bool isBuiltin; + // Input file name std::string lInputFilename; @@ -204,19 +225,13 @@ // Call the command-line option parser const int lOptionParserStatus = readConfiguration (argc, argv, lRandomDraws, lCapacity, - lSellupProbabilityVector, lMethod, lInputFilename, - lLogFilename); + lSellupProbabilityVector, lMethod, + isBuiltin, lInputFilename, lLogFilename); if (lOptionParserStatus == K_RMOL_EARLY_RETURN_STATUS) { return 0; } - // Check wether or not a (CSV) input file should be read - bool hasInputFile = false; - if (lInputFilename.empty() == false) { - hasInputFile = true; - } - // Set the log parameters std::ofstream logOutputFile; // Open and clean the log outputfile @@ -229,24 +244,32 @@ RMOL::RMOL_Service rmolService (lLogParams, lAirlineCode, lCapacity); rmolService.setUpStudyStatManager(); - if (hasInputFile) { - // Read the input file - rmolService.readFromInputFile (lInputFilename); - - } else { + if (isBuiltin == true) { // No input file has been provided. So, process a sample. + + // DEBUG + STDAIR_LOG_DEBUG ("rmol will build the BOM tree from built-in specifications."); // STEP 0. // List of demand distribution parameters (mean and standard deviation) - // Class/bucket 1: N (20, 9), p1 = 100 - rmolService.addBucket (100.0, 20, 9); + // Class/bucket 1: p1 = 110, N (15, 9) + rmolService.addBucket (110.0, 15, 9); - // Class/bucket 2: N (45, 12), p2 = 70 - rmolService.addBucket (70.0, 45, 12); + // Class/bucket 2: p2 = 75, N (40, 12) + rmolService.addBucket (75.0, 40, 12); - // Class/bucket 3: no need to define a demand distribution, p3 = 42 - rmolService.addBucket (42.0, 0, 0); + // Class/bucket 3: p3 = 48, no need to define a demand distribution + // (it can be considered very big) + rmolService.addBucket (48.0, 0, 0); + + } else { + // DEBUG + STDAIR_LOG_DEBUG ("rmol will parse " << lInputFilename + << " and build the corresponding BOM tree."); + + // Parse the input file + rmolService.readFromInputFile (lInputFilename); } switch (lMethod) { Modified: trunk/rmol/rmol/bom/BucketHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/BucketHolder.cpp 2010-08-07 09:37:43 UTC (rev 325) +++ trunk/rmol/rmol/bom/BucketHolder.cpp 2010-08-07 16:11:37 UTC (rev 326) @@ -77,10 +77,11 @@ // ////////////////////////////////////////////////////////////////////// const std::string BucketHolder::display() const { std::ostringstream oStr; - oStr << shortDisplay(); + oStr << shortDisplay() << std::endl; + // Generate a CSV (Comma Separated Values) output oStr << "Class; Price; Mean; Std Dev; Protection; Cum. Protection; Cum. Bkg Limit; " - << std::endl; + << std::endl; BucketList_T::const_iterator itBucket = _bucketList.begin(); for (short j=1; itBucket != _bucketList.end(); itBucket++, j++) { Modified: trunk/rmol/rmol/service/RMOL_Service.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_Service.cpp 2010-08-07 09:37:43 UTC (rev 325) +++ trunk/rmol/rmol/service/RMOL_Service.cpp 2010-08-07 16:11:37 UTC (rev 326) @@ -229,7 +229,7 @@ // DEBUG STDAIR_LOG_DEBUG ("Optimisation by Monte-Carlo performed in " - << lOptimisationMeasure); + << lOptimisationMeasure); STDAIR_LOG_DEBUG ("Resulting buckets: " << oBucketHolder_ptr->display()); std::ostringstream logStream; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |