*/
#include <sstream>
#include <fstream>
#include <string>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE OptimiseTestSuite
#include <boost/test/unit_test.hpp>
#include <stdair/basic/BasLogParams.hpp>
#include <stdair/basic/BasDBParams.hpp>
#include <stdair/basic/BasFileMgr.hpp>
#include <stdair/service/Logger.hpp>
#include <rmol/config/rmol-paths.hpp>
namespace boost_utf = boost::unit_test;
std::ofstream utfReportStream ("OptimiseTestSuite_utfresults.xml");
struct UnitTestConfig {
UnitTestConfig() {
boost_utf::unit_test_log.set_stream (utfReportStream);
boost_utf::unit_test_log.set_format (boost_utf::XML);
boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
}
~UnitTestConfig() {
}
};
int testOptimiseHelper (const unsigned short optimisationMethodFlag,
const bool isBuiltin) {
int oExpectedBookingLimit = 0;
std::ostringstream oStr;
oStr << "OptimiseTestSuite_" << optimisationMethodFlag << "_" << isBuiltin << ".log";
const stdair::Filename_T lLogFilename (oStr.str());
const unsigned short METHOD_FLAG = optimisationMethodFlag;
const double cabinCapacity = 100.0;
std::ofstream logOutputFile;
logOutputFile.open (lLogFilename.c_str());
logOutputFile.clear();
const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
if (isBuiltin == true) {
rmolService.buildSampleBom();
} else {
const stdair::Filename_T lRMInputFileName (STDAIR_SAMPLE_DIR "/rm02.csv");
rmolService.parseAndLoad (cabinCapacity, lRMInputFileName);
}
switch (METHOD_FLAG) {
case 0: {
STDAIR_LOG_DEBUG ("Optimisation by Monte-Carlo (MC)");
rmolService.optimalOptimisationByMCIntegration (K);
break;
}
case 1: {
STDAIR_LOG_DEBUG ("Optimisation by Dynamic Programming (DP)");
rmolService.optimalOptimisationByDP ();
break;
}
case 2: {
STDAIR_LOG_DEBUG ("Calculate the Bid-Price Vectors (BPV) by EMSR");
rmolService.heuristicOptimisationByEmsr ();
break;
}
case 3: {
STDAIR_LOG_DEBUG ("Calculate the Authorisation Levels (AUs) by EMSRa");
rmolService.heuristicOptimisationByEmsrA ();
break;
}
case 4: {
STDAIR_LOG_DEBUG ("Calculate the Authorisation Levels (AUs) by EMSRb");
rmolService.heuristicOptimisationByEmsrB ();
break;
}
default: rmolService.optimalOptimisationByMCIntegration (K);
}
logOutputFile.close();
return oExpectedBookingLimit;
}
BOOST_GLOBAL_FIXTURE (UnitTestConfig);
BOOST_AUTO_TEST_SUITE (master_test_suite)
BOOST_AUTO_TEST_CASE (rmol_optimisation_monte_carlo) {
const bool isBuiltin = false;
BOOST_CHECK_NO_THROW (testOptimiseHelper(0, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_dynamic_programming) {
const bool isBuiltin = false;
BOOST_CHECK_NO_THROW (testOptimiseHelper(1, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_bpv) {
const bool isBuiltin = false;
BOOST_CHECK_NO_THROW (testOptimiseHelper(2, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_a) {
const bool isBuiltin = false;
BOOST_CHECK_NO_THROW (testOptimiseHelper(3, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_b) {
const bool isBuiltin = false;
BOOST_CHECK_NO_THROW (testOptimiseHelper(4, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_monte_carlo_built_in) {
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW (testOptimiseHelper(0, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_dynamic_programming_built_in) {
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW (testOptimiseHelper(1, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_bpv_built_in) {
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW (testOptimiseHelper(2, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_a_built_in) {
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW (testOptimiseHelper(3, isBuiltin););
}
BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_b_built_in) {
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW (testOptimiseHelper(4, isBuiltin););
}
BOOST_AUTO_TEST_SUITE_END()