13 #define BOOST_TEST_DYN_LINK
14 #define BOOST_TEST_MAIN
15 #define BOOST_TEST_MODULE OptimiseTestSuite
16 #include <boost/test/unit_test.hpp>
18 #include <stdair/basic/BasLogParams.hpp>
19 #include <stdair/basic/BasDBParams.hpp>
20 #include <stdair/basic/BasFileMgr.hpp>
21 #include <stdair/service/Logger.hpp>
25 #include <rmol/config/rmol-paths.hpp>
27 namespace boost_utf = boost::unit_test;
30 std::ofstream utfReportStream (
"OptimiseTestSuite_utfresults.xml");
35 struct UnitTestConfig {
38 boost_utf::unit_test_log.set_stream (utfReportStream);
39 boost_utf::unit_test_log.set_format (boost_utf::XML);
40 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
51 int testOptimiseHelper (
const unsigned short optimisationMethodFlag,
52 const bool isBuiltin) {
55 int oExpectedBookingLimit = 0;
58 std::ostringstream oStr;
59 oStr <<
"OptimiseTestSuite_" << optimisationMethodFlag <<
"_" << isBuiltin <<
".log";
60 const stdair::Filename_T lLogFilename (oStr.str());
67 const unsigned short METHOD_FLAG = optimisationMethodFlag;
70 const double cabinCapacity = 100.0;
73 std::ofstream logOutputFile;
75 logOutputFile.open (lLogFilename.c_str());
76 logOutputFile.clear();
79 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
83 if (isBuiltin ==
true) {
86 rmolService.buildSampleBom();
91 const stdair::Filename_T lRMInputFileName (STDAIR_SAMPLE_DIR
"/rm02.csv");
92 rmolService.parseAndLoad (cabinCapacity, lRMInputFileName);
95 switch (METHOD_FLAG) {
98 STDAIR_LOG_DEBUG (
"Optimisation by Monte-Carlo (MC)");
102 rmolService.optimalOptimisationByMCIntegration (K);
108 STDAIR_LOG_DEBUG (
"Optimisation by Dynamic Programming (DP)");
111 rmolService.optimalOptimisationByDP ();
117 STDAIR_LOG_DEBUG (
"Calculate the Bid-Price Vectors (BPV) by EMSR");
120 rmolService.heuristicOptimisationByEmsr ();
126 STDAIR_LOG_DEBUG (
"Calculate the Authorisation Levels (AUs) by EMSRa");
130 rmolService.heuristicOptimisationByEmsrA ();
139 STDAIR_LOG_DEBUG (
"Calculate the Authorisation Levels (AUs) by EMSRb");
142 rmolService.heuristicOptimisationByEmsrB ();
146 default: rmolService.optimalOptimisationByMCIntegration (K);
150 logOutputFile.close();
152 return oExpectedBookingLimit;
159 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
174 BOOST_AUTO_TEST_SUITE (master_test_suite)
179 BOOST_AUTO_TEST_CASE (rmol_optimisation_monte_carlo) {
182 const bool isBuiltin =
false;
184 BOOST_CHECK_NO_THROW (testOptimiseHelper(0, isBuiltin););
190 BOOST_AUTO_TEST_CASE (rmol_optimisation_dynamic_programming) {
193 const bool isBuiltin =
false;
195 BOOST_CHECK_NO_THROW (testOptimiseHelper(1, isBuiltin););
202 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_bpv) {
205 const bool isBuiltin =
false;
207 BOOST_CHECK_NO_THROW (testOptimiseHelper(2, isBuiltin););
214 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_a) {
217 const bool isBuiltin =
false;
219 BOOST_CHECK_NO_THROW (testOptimiseHelper(3, isBuiltin););
233 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_b) {
236 const bool isBuiltin =
false;
238 BOOST_CHECK_NO_THROW (testOptimiseHelper(4, isBuiltin););
244 BOOST_AUTO_TEST_CASE (rmol_optimisation_monte_carlo_built_in) {
247 const bool isBuiltin =
true;
249 BOOST_CHECK_NO_THROW (testOptimiseHelper(0, isBuiltin););
255 BOOST_AUTO_TEST_CASE (rmol_optimisation_dynamic_programming_built_in) {
258 const bool isBuiltin =
true;
260 BOOST_CHECK_NO_THROW (testOptimiseHelper(1, isBuiltin););
267 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_bpv_built_in) {
270 const bool isBuiltin =
true;
272 BOOST_CHECK_NO_THROW (testOptimiseHelper(2, isBuiltin););
279 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_a_built_in) {
282 const bool isBuiltin =
true;
284 BOOST_CHECK_NO_THROW (testOptimiseHelper(3, isBuiltin););
291 BOOST_AUTO_TEST_CASE (rmol_optimisation_emsr_b_built_in) {
294 const bool isBuiltin =
true;
296 BOOST_CHECK_NO_THROW (testOptimiseHelper(4, isBuiltin););
300 BOOST_AUTO_TEST_SUITE_END()