From: <den...@us...> - 2010-01-21 19:34:04
|
Revision: 290 http://rmol.svn.sourceforge.net/rmol/?rev=290&view=rev Author: denis_arnaud Date: 2010-01-21 19:33:33 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The log output stream initialisation has been moved into the StdAir library. Modified Paths: -------------- trunk/rmol/test/rmol/ForecasterTestSuite.cpp trunk/rmol/test/rmol/OptimiseTestSuite.cpp trunk/rmol/test/rmol/UnconstrainerTestSuite.cpp trunk/rmol/test/rmol/bomsforforecaster.cpp Modified: trunk/rmol/test/rmol/ForecasterTestSuite.cpp =================================================================== --- trunk/rmol/test/rmol/ForecasterTestSuite.cpp 2010-01-21 19:33:17 UTC (rev 289) +++ trunk/rmol/test/rmol/ForecasterTestSuite.cpp 2010-01-21 19:33:33 UTC (rev 290) @@ -33,7 +33,8 @@ std::ostringstream oDebugStr; // Initialise the RMOL service - RMOL::RMOL_Service rmolService (logOutputFile); + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + RMOL::RMOL_Service rmolService (lLogParams); // A sample historical demand data to be processed by forecaster // Class | Q | M | B | Y | Modified: trunk/rmol/test/rmol/OptimiseTestSuite.cpp =================================================================== --- trunk/rmol/test/rmol/OptimiseTestSuite.cpp 2010-01-21 19:33:17 UTC (rev 289) +++ trunk/rmol/test/rmol/OptimiseTestSuite.cpp 2010-01-21 19:33:33 UTC (rev 290) @@ -41,7 +41,9 @@ logOutputFile.clear(); // Initialise the RMOL service - RMOL::RMOL_Service rmolService (logOutputFile, cabinCapacity); + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + RMOL::RMOL_Service rmolService (lLogParams, cabinCapacity); + rmolService.setUpStudyStatManager(); // Define bid price and booking Limit vectors RMOL::BidPriceVector_T lBidPriceVector; @@ -69,66 +71,70 @@ } switch (METHOD_FLAG) { + case 0 : { + // Calculate the optimal protections by the Monte Carlo + // Integration approach + rmolService.optimalOptimisationByMCIntegration (K); + break; + } + + case 1 : { + // Calculate the optimal protections by DP. + rmolService.optimalOptimisationByDP (); + break; + } + + case 2 : { + // Calculate the Bid-Price Vector by EMSR + rmolService.heuristicOptimisationByEmsr (); + break; + } + + case 3 : { + // Calculate the protections by EMSR-a + // Test the EMSR-a algorithm implementation + rmolService.heuristicOptimisationByEmsrA (lBidPriceVector, + lProtectionLevelVector, + lBookingLimitVector); - case 0 : // Calculate the optimal protections by the Monte Carlo - // Integration approach - { - rmolService.optimalOptimisationByMCIntegration (K); - break; - } - case 1 : // Calculate the optimal protections by DP. - { - rmolService.optimalOptimisationByDP (); - break; + // Return a cumulated booking limit value to test + oExpectedBookingLimit = static_cast<int> (lBookingLimitVector.at(2)); + break; + } + + case 4 : { + // Calculate the protections by EMSR-b + rmolService.heuristicOptimisationByEmsrB (); + break; + } + + case 5 : { + // Calculate the protection by EMSR-a with sellup + // Create an empty sell-up probability vector + std::vector<double> sellupProbabilityVector; + + // Define the sell-up probability to be 20% + const double sampleProbability = 0.2; + + // NOTE: size of sellup vector should be equal to no of buckets - 1 + // TODO: check that with an assertion + const short nbOfSampleBucket = 4; + for (short i = 1; i <= nbOfSampleBucket - 1; i++) { + sellupProbabilityVector.push_back (sampleProbability); } - case 2 : // Calculate the Bid-Price Vector by EMSR - { - rmolService.heuristicOptimisationByEmsr (); - break; - } - case 3 : // Calculate the protections by EMSR-a - { - // Test the EMSR-a algorithm implementation - rmolService.heuristicOptimisationByEmsrA (lBidPriceVector, - lProtectionLevelVector, - lBookingLimitVector); + + // Test the algorithm with the sample sell-up vector + rmolService.heuristicOptimisationByEmsrAwithSellup + (sellupProbabilityVector, lProtectionLevelVector, + lBidPriceVector, lBookingLimitVector); + + // Return a cumulated booking limit value to test + oExpectedBookingLimit = static_cast<int> (lBookingLimitVector.at(2)); + + break; + } - // Return a cumulated booking limit value to test - oExpectedBookingLimit = static_cast<int> (lBookingLimitVector.at(2)); - break; - } - case 4 : // Calculate the protections by EMSR-b - { - rmolService.heuristicOptimisationByEmsrB (); - break; - } - case 5 : // Calculate the protection by EMSR-a with sellup - { - // Create an empty sell-up probability vector - std::vector<double> sellupProbabilityVector; - - // Define the sell-up probability to be 20% - const double sampleProbability = 0.2; - - // NOTE: size of sellup vector should be equal to no of buckets - 1 - // TODO: check that with an assertion - const short nbOfSampleBucket = 4; - for (short i = 1; i <= nbOfSampleBucket - 1; i++) { - sellupProbabilityVector.push_back (sampleProbability); - } - - // Test the algorithm with the sample sell-up vector - rmolService.heuristicOptimisationByEmsrAwithSellup - (sellupProbabilityVector, lProtectionLevelVector, - lBidPriceVector, lBookingLimitVector); - - // Return a cumulated booking limit value to test - oExpectedBookingLimit = static_cast<int> (lBookingLimitVector.at(2)); - - break; - } - - default : rmolService.optimalOptimisationByMCIntegration (K); + default: rmolService.optimalOptimisationByMCIntegration (K); } } catch (const std::exception& stde) { @@ -172,7 +178,7 @@ // EMSR-a void OptimiseTestSuite::testOptimiseEMSRa() { const int lExpectedBookingLimit = testOptimiseHelper(3); - CPPUNIT_ASSERT(lExpectedBookingLimit == 61); + CPPUNIT_ASSERT (lExpectedBookingLimit == 61); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/rmol/test/rmol/UnconstrainerTestSuite.cpp =================================================================== --- trunk/rmol/test/rmol/UnconstrainerTestSuite.cpp 2010-01-21 19:33:17 UTC (rev 289) +++ trunk/rmol/test/rmol/UnconstrainerTestSuite.cpp 2010-01-21 19:33:33 UTC (rev 290) @@ -33,7 +33,8 @@ std::ostringstream oDebugStr; // Initialise the RMOL service - RMOL::RMOL_Service rmolService (logOutputFile); + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + RMOL::RMOL_Service rmolService (lLogParams); // A sample historical booking data to be processed by unconstrainer RMOL::ConstrainedDataHolder_T lConstrainedDataHolder; Modified: trunk/rmol/test/rmol/bomsforforecaster.cpp =================================================================== --- trunk/rmol/test/rmol/bomsforforecaster.cpp 2010-01-21 19:33:17 UTC (rev 289) +++ trunk/rmol/test/rmol/bomsforforecaster.cpp 2010-01-21 19:33:33 UTC (rev 290) @@ -3,14 +3,11 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> -#include <sstream> #include <fstream> -#include <string> -#include <limits> -// #include <iostream> +// StdAir +#include <stdair/service/Logger.hpp> // RMOL #include <rmol/RMOL_Service.hpp> -#include <rmol/service/Logger.hpp> namespace RMOL { @@ -190,8 +187,11 @@ // Open and clean the log outputfile logOutputFile.open (lLogFilename.c_str()); logOutputFile.clear(); - RMOL::RMOL_Service lRmolService(logOutputFile); + // Initialise the RMOL service + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + RMOL::RMOL_Service lRmolService (lLogParams); + // Register BCDataSet RMOL::BookingClassDataSet lBookingClassDataSet; @@ -202,10 +202,10 @@ RMOL::BookingClassData YClassData (0, 300, 0.3, false); // Display - RMOL_LOG_DEBUG(QClassData.toString()); - RMOL_LOG_DEBUG(MClassData.toString()); - RMOL_LOG_DEBUG(BClassData.toString()); - RMOL_LOG_DEBUG(YClassData.toString()); + STDAIR_LOG_DEBUG(QClassData.toString()); + STDAIR_LOG_DEBUG(MClassData.toString()); + STDAIR_LOG_DEBUG(BClassData.toString()); + STDAIR_LOG_DEBUG(YClassData.toString()); // Add BookingClassData into the BCDataSet lBookingClassDataSet.addBookingClassData (QClassData ); @@ -214,22 +214,24 @@ lBookingClassDataSet.addBookingClassData( YClassData ); //Display - RMOL_LOG_DEBUG( lBookingClassDataSet.toString() ); + STDAIR_LOG_DEBUG( lBookingClassDataSet.toString() ); // Number of classes const unsigned int lNoOfClass = lBookingClassDataSet.getNumberOfClass(); - RMOL_LOG_DEBUG( "Number of Classes: " << lNoOfClass ); + STDAIR_LOG_DEBUG( "Number of Classes: " << lNoOfClass ); // Minimum fare lBookingClassDataSet.updateMinimumFare(); const double lMinFare = lBookingClassDataSet.getMinimumFare(); - RMOL_LOG_DEBUG( "Minimum fare: " << lMinFare ); + STDAIR_LOG_DEBUG( "Minimum fare: " << lMinFare ); // Censorship flag lBookingClassDataSet.updateCensorshipFlag(); const bool lCensorshipFlag = lBookingClassDataSet.getCensorshipFlag(); - RMOL_LOG_DEBUG( "Censorship Flag: " << lCensorshipFlag ); + // DEBUG + STDAIR_LOG_DEBUG ( "Censorship Flag: " << lCensorshipFlag ); + // Close the log output file logOutputFile.close(); return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |