Go to the documentation of this file.00001
00005
00006
00007
00008
00009 #include <sstream>
00010 #include <fstream>
00011 #include <string>
00012
00013 #define BOOST_TEST_DYN_LINK
00014 #define BOOST_TEST_MAIN
00015 #define BOOST_TEST_MODULE OptimiseTestSuite
00016 #include <boost/test/unit_test.hpp>
00017
00018 #include <stdair/basic/BasLogParams.hpp>
00019 #include <stdair/basic/BasDBParams.hpp>
00020 #include <stdair/basic/BasFileMgr.hpp>
00021 #include <stdair/service/Logger.hpp>
00022
00023 #include <rmol/RMOL_Service.hpp>
00024 #include <rmol/config/rmol-paths.hpp>
00025
00026 namespace boost_utf = boost::unit_test;
00027
00028
00029 std::ofstream utfReportStream ("OptimiseTestSuite_utfresults.xml");
00030
00034 struct UnitTestConfig {
00036 UnitTestConfig() {
00037 boost_utf::unit_test_log.set_stream (utfReportStream);
00038 boost_utf::unit_test_log.set_format (boost_utf::XML);
00039 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
00040
00041 }
00042
00044 ~UnitTestConfig() {
00045 }
00046 };
00047
00048
00049
00050 int testOptimiseHelper (const unsigned short optimisationMethodFlag,
00051 const bool isBuiltin) {
00052
00053
00054 int oExpectedBookingLimit = 0;
00055
00056
00057 std::ostringstream oStr;
00058 oStr << "OptimiseTestSuite_" << optimisationMethodFlag << ".log";
00059 const stdair::Filename_T lLogFilename (oStr.str());
00060
00061
00062 const int K = 100000;
00063
00064
00065
00066 const unsigned short METHOD_FLAG = optimisationMethodFlag;
00067
00068
00069 const double cabinCapacity = 100.0;
00070
00071
00072 std::ofstream logOutputFile;
00073
00074 logOutputFile.open (lLogFilename.c_str());
00075 logOutputFile.clear();
00076
00077
00078 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
00079 RMOL::RMOL_Service rmolService (lLogParams);
00080
00081
00082 if (isBuiltin == true) {
00083
00084
00085 rmolService.buildSampleBom();
00086
00087 } else {
00088
00089
00090 const stdair::Filename_T lRMInputFileName (STDAIR_SAMPLE_DIR "/rm02.csv");
00091 rmolService.parseAndLoad (cabinCapacity, lRMInputFileName);
00092 }
00093
00094 switch (METHOD_FLAG) {
00095 case 0: {
00096
00097 STDAIR_LOG_DEBUG ("Optimisation by Monte-Carlo (MC)");
00098
00099
00100
00101 rmolService.optimalOptimisationByMCIntegration (K);
00102 break;
00103 }
00104
00105 case 1: {
00106
00107 STDAIR_LOG_DEBUG ("Optimisation by Dynamic Programming (DP)");
00108
00109
00110 rmolService.optimalOptimisationByDP ();
00111 break;
00112 }
00113
00114 case 2: {
00115
00116 STDAIR_LOG_DEBUG ("Calculate the Bid-Price Vectors (BPV) by EMSR");
00117
00118
00119 rmolService.heuristicOptimisationByEmsr ();
00120 break;
00121 }
00122
00123 case 3: {
00124
00125 STDAIR_LOG_DEBUG ("Calculate the Authorisation Levels (AUs) by EMSRa");
00126
00127
00128
00129 rmolService.heuristicOptimisationByEmsrA ();
00130
00131
00132
00133 break;
00134 }
00135
00136 case 4: {
00137
00138 STDAIR_LOG_DEBUG ("Calculate the Authorisation Levels (AUs) by EMSRb");
00139
00140
00141 rmolService.heuristicOptimisationByEmsrB ();
00142 break;
00143 }
00144
00145 default: rmolService.optimalOptimisationByMCIntegration (K);
00146 }
00147
00148
00149 logOutputFile.close();
00150
00151 return oExpectedBookingLimit;
00152 }
00153
00154
00155
00156
00157
00158 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00173 BOOST_AUTO_TEST_SUITE (master_test_suite)
00174
00175
00178 BOOST_AUTO_TEST_CASE (rmol_optimisation_monte_carlo) {
00179
00180
00181 const bool isBuiltin = false;
00182
00183 BOOST_CHECK_NO_THROW (testOptimiseHelper(0, isBuiltin););
00184 }
00185
00189 BOOST_AUTO_TEST_CASE (rmol_optimisation_dynamic_programming) {
00190
00191
00192 const bool isBuiltin = false;
00193
00194 BOOST_CHECK_NO_THROW (testOptimiseHelper(1, isBuiltin););
00195 }
00196
00201 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_bpv) {
00202
00203
00204 const bool isBuiltin = false;
00205
00206 BOOST_CHECK_NO_THROW (testOptimiseHelper(2, isBuiltin););
00207 }
00208
00213 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_a) {
00214
00215
00216 const bool isBuiltin = false;
00217
00218 BOOST_CHECK_NO_THROW (testOptimiseHelper(3, isBuiltin););
00219
00220
00221
00222
00223
00224
00225
00226 }
00227
00232 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_b) {
00233
00234
00235 const bool isBuiltin = false;
00236
00237 BOOST_CHECK_NO_THROW (testOptimiseHelper(4, isBuiltin););
00238 }
00239
00243 BOOST_AUTO_TEST_CASE (rmol_optimisation_monte_carlo_built_in) {
00244
00245
00246 const bool isBuiltin = true;
00247
00248 BOOST_CHECK_NO_THROW (testOptimiseHelper(5, isBuiltin););
00249 }
00250
00254 BOOST_AUTO_TEST_CASE (rmol_optimisation_dynamic_programming_built_in) {
00255
00256
00257 const bool isBuiltin = true;
00258
00259 BOOST_CHECK_NO_THROW (testOptimiseHelper(6, isBuiltin););
00260 }
00261
00266 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_bpv_built_in) {
00267
00268
00269 const bool isBuiltin = true;
00270
00271 BOOST_CHECK_NO_THROW (testOptimiseHelper(7, isBuiltin););
00272 }
00273
00278 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_a_built_in) {
00279
00280
00281 const bool isBuiltin = true;
00282
00283 BOOST_CHECK_NO_THROW (testOptimiseHelper(8, isBuiltin););
00284 }
00285
00290 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_b_built_in) {
00291
00292
00293 const bool isBuiltin = true;
00294
00295 BOOST_CHECK_NO_THROW (testOptimiseHelper(9, isBuiltin););
00296 }
00297
00298
00299 BOOST_AUTO_TEST_SUITE_END()
00300
00301