13#define BOOST_TEST_DYN_LINK
14#define BOOST_TEST_MAIN
15#define BOOST_TEST_MODULE TvlSimTest
16#include <boost/test/unit_test.hpp>
18#include <stdair/stdair_exceptions.hpp>
19#include <stdair/stdair_json.hpp>
20#include <stdair/basic/BasConst_General.hpp>
21#include <stdair/basic/BasLogParams.hpp>
22#include <stdair/basic/BasFileMgr.hpp>
23#include <stdair/basic/DemandGenerationMethod.hpp>
24#include <stdair/service/Logger.hpp>
26#include <simfqt/SIMFQT_Types.hpp>
30#include <tvlsim/config/tvlsim-paths.hpp>
32namespace boost_utf = boost::unit_test;
35std::ofstream utfReportStream (
"PartnerSimulationTestSuite_utfresults.xml");
40struct UnitTestConfig {
43 boost_utf::unit_test_log.set_stream (utfReportStream);
44#if BOOST_VERSION_MACRO >= 105900
45 boost_utf::unit_test_log.set_format (boost_utf::OF_XML);
47 boost_utf::unit_test_log.set_format (boost_utf::XML);
49 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
61BOOST_GLOBAL_FIXTURE (UnitTestConfig);
64BOOST_AUTO_TEST_SUITE (master_test_suite)
69BOOST_AUTO_TEST_CASE (partner_simulation_test) {
72 const stdair::DemandGenerationMethod lOrderStatDemandGenMethod =
73 stdair::DemandGenerationMethod::STA_ORD;
76 const stdair::Date_T lStartDate (2009, boost::gregorian::Jan, 01);
79 const stdair::Date_T lEndDate (2011, boost::gregorian::Jan, 01);
82 const stdair::RandomSeed_T lRandomSeed (stdair::DEFAULT_RANDOM_SEED);
88 const stdair::Filename_T lDemandInputFilename (STDAIR_SAMPLE_DIR
89 "/IBP_study/demand01.csv");
92 const stdair::Filename_T lScheduleInputFilename (STDAIR_SAMPLE_DIR
93 "/IBP_study/schedule01.csv");
96 const stdair::Filename_T lOnDInputFilename (STDAIR_SAMPLE_DIR
"/IBP_study/ond01.csv");
99 const stdair::Filename_T lFRAT5InputFilename (STDAIR_SAMPLE_DIR
103 const stdair::Filename_T lFFDisutilityInputFilename (STDAIR_SAMPLE_DIR
104 "/ffDisutility.csv");
107 const stdair::Filename_T lYieldInputFilename (STDAIR_SAMPLE_DIR
108 "/IBP_study/yield01.csv");
111 const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR
112 "/IBP_study/fare01.csv");
115 bool doesExistAndIsReadable =
116 stdair::BasFileMgr::doesExistAndIsReadable (lScheduleInputFilename);
117 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
118 "The '" << lScheduleInputFilename
119 <<
"' input file can not be open and read");
122 doesExistAndIsReadable =
123 stdair::BasFileMgr::doesExistAndIsReadable (lOnDInputFilename);
124 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
125 "The '" << lOnDInputFilename
126 <<
"' input file can not be open and read");
129 doesExistAndIsReadable =
130 stdair::BasFileMgr::doesExistAndIsReadable (lFRAT5InputFilename);
131 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
132 "The '" << lFRAT5InputFilename
133 <<
"' input file can not be open and read");
136 doesExistAndIsReadable =
137 stdair::BasFileMgr::doesExistAndIsReadable (lFFDisutilityInputFilename);
138 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
139 "The '" << lFFDisutilityInputFilename
140 <<
"' input file can not be open and read");
143 doesExistAndIsReadable =
144 stdair::BasFileMgr::doesExistAndIsReadable (lDemandInputFilename);
145 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
146 "The '" << lDemandInputFilename
147 <<
"' input file can not be open and read");
150 doesExistAndIsReadable =
151 stdair::BasFileMgr::doesExistAndIsReadable (lFareInputFilename);
152 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
153 "The '" << lFareInputFilename
154 <<
"' input file can not be open and read");
157 doesExistAndIsReadable =
158 stdair::BasFileMgr::doesExistAndIsReadable (lYieldInputFilename);
159 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
160 "The '" << lYieldInputFilename
161 <<
"' input file can not be open and read");
164 const stdair::Filename_T lLogFilename (
"PartnerSimulationTestSuite.log");
167 std::ofstream logOutputFile;
169 logOutputFile.open (lLogFilename.c_str());
170 logOutputFile.clear();
173 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
176 lRandomSeed, lOrderStatDemandGenMethod,
180 std::ostringstream lMyCommandJSONstream;
181 lMyCommandJSONstream <<
"{\"config\":"
183 <<
"{ \"airline_code\":\"" <<
"SQ"
184 <<
"\",\"unconstraining_method\":\"" <<
"E"
185 <<
"\",\"pre_optimisation_method\":\"N"
186 <<
"\",\"optimisation_method\":\"M"
187 <<
"\",\"partnership_technique\":\"i"
188 <<
"\",\"forecasting_method\":\"B"
191 <<
"{ \"airline_code\":\"" <<
"CX"
192 <<
"\",\"unconstraining_method\":\"" <<
"E"
193 <<
"\",\"pre_optimisation_method\":\"N"
194 <<
"\",\"optimisation_method\":\"M"
195 <<
"\",\"partnership_technique\":\"i"
196 <<
"\",\"forecasting_method\":\"B"
199 STDAIR_LOG_DEBUG(lMyCommandJSONstream.str());
201 const stdair::JSONString lJSONCommandString (lMyCommandJSONstream.str());
202 const std::string& lCSVConfigDump =
203 tvlsimService.jsonHandler (lJSONCommandString);
205 STDAIR_LOG_DEBUG(lCSVConfigDump);
211 const stdair::ScheduleFilePath lScheduleFilePath (lScheduleInputFilename);
212 const stdair::ODFilePath lODFilePath (lOnDInputFilename);
213 const stdair::FRAT5FilePath lFRAT5FilePath (lFRAT5InputFilename);
214 const stdair::FFDisutilityFilePath lFFDisutilityFilePath (lFFDisutilityInputFilename);
215 const SIMFQT::FareFilePath lFareFilePath (lFareInputFilename);
216 const AIRRAC::YieldFilePath lYieldFilePath (lYieldInputFilename);
217 const TRADEMGEN::DemandFilePath lDemandFilePath (lDemandInputFilename);
220 BOOST_CHECK_NO_THROW (tvlsimService.setInputFiles(lScheduleFilePath,
223 lFFDisutilityFilePath,
229 BOOST_CHECK_NO_THROW (tvlsimService.parseAndLoad ());
232 BOOST_CHECK_NO_THROW (tvlsimService.initSnapshotAndRMEvents());
236 BOOST_CHECK_NO_THROW (tvlsimService.simulate ());
239 logOutputFile.close();
243BOOST_AUTO_TEST_SUITE_END()