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>
32 namespace boost_utf = boost::unit_test;
35 std::ofstream utfReportStream (
"PartnerSimulationTestSuite_utfresults.xml");
40 struct UnitTestConfig {
43 boost_utf::unit_test_log.set_stream (utfReportStream);
44 boost_utf::unit_test_log.set_format (boost_utf::XML);
45 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
57 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
60 BOOST_AUTO_TEST_SUITE (master_test_suite)
65 BOOST_AUTO_TEST_CASE (partner_simulation_test) {
68 const stdair::DemandGenerationMethod lOrderStatDemandGenMethod =
69 stdair::DemandGenerationMethod::STA_ORD;
72 const stdair::Date_T lStartDate (2009, boost::gregorian::Jan, 01);
75 const stdair::Date_T lEndDate (2011, boost::gregorian::Jan, 01);
78 const stdair::RandomSeed_T lRandomSeed (stdair::DEFAULT_RANDOM_SEED);
85 "/IBP_study/demand01.csv");
89 "/IBP_study/schedule01.csv");
92 const stdair::Filename_T lOnDInputFilename (
STDAIR_SAMPLE_DIR "/IBP_study/ond01.csv");
100 "/ffDisutility.csv");
104 "/IBP_study/yield01.csv");
108 "/IBP_study/fare01.csv");
111 bool doesExistAndIsReadable =
112 stdair::BasFileMgr::doesExistAndIsReadable (lScheduleInputFilename);
113 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
114 "The '" << lScheduleInputFilename
115 <<
"' input file can not be open and read");
118 doesExistAndIsReadable =
119 stdair::BasFileMgr::doesExistAndIsReadable (lOnDInputFilename);
120 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
121 "The '" << lOnDInputFilename
122 <<
"' input file can not be open and read");
125 doesExistAndIsReadable =
126 stdair::BasFileMgr::doesExistAndIsReadable (lFRAT5InputFilename);
127 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
128 "The '" << lFRAT5InputFilename
129 <<
"' input file can not be open and read");
132 doesExistAndIsReadable =
133 stdair::BasFileMgr::doesExistAndIsReadable (lFFDisutilityInputFilename);
134 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
135 "The '" << lFFDisutilityInputFilename
136 <<
"' input file can not be open and read");
139 doesExistAndIsReadable =
140 stdair::BasFileMgr::doesExistAndIsReadable (lDemandInputFilename);
141 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
142 "The '" << lDemandInputFilename
143 <<
"' input file can not be open and read");
146 doesExistAndIsReadable =
147 stdair::BasFileMgr::doesExistAndIsReadable (lFareInputFilename);
148 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
149 "The '" << lFareInputFilename
150 <<
"' input file can not be open and read");
153 doesExistAndIsReadable =
154 stdair::BasFileMgr::doesExistAndIsReadable (lYieldInputFilename);
155 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
156 "The '" << lYieldInputFilename
157 <<
"' input file can not be open and read");
160 const stdair::Filename_T lLogFilename (
"PartnerSimulationTestSuite.log");
163 std::ofstream logOutputFile;
165 logOutputFile.open (lLogFilename.c_str());
166 logOutputFile.clear();
169 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
172 lRandomSeed, lOrderStatDemandGenMethod,
176 std::ostringstream lMyCommandJSONstream;
177 lMyCommandJSONstream <<
"{\"config\":"
179 <<
"{ \"airline_code\":\"" <<
"SQ"
180 <<
"\",\"unconstraining_method\":\"" <<
"E"
181 <<
"\",\"pre_optimisation_method\":\"N"
182 <<
"\",\"optimisation_method\":\"M"
183 <<
"\",\"partnership_technique\":\"i"
184 <<
"\",\"forecasting_method\":\"B"
187 <<
"{ \"airline_code\":\"" <<
"CX"
188 <<
"\",\"unconstraining_method\":\"" <<
"E"
189 <<
"\",\"pre_optimisation_method\":\"N"
190 <<
"\",\"optimisation_method\":\"M"
191 <<
"\",\"partnership_technique\":\"i"
192 <<
"\",\"forecasting_method\":\"B"
195 STDAIR_LOG_DEBUG(lMyCommandJSONstream.str());
197 const stdair::JSONString lJSONCommandString (lMyCommandJSONstream.str());
198 const std::string& lCSVConfigDump =
199 tvlsimService.jsonHandler (lJSONCommandString);
201 STDAIR_LOG_DEBUG(lCSVConfigDump);
207 const stdair::ScheduleFilePath lScheduleFilePath (lScheduleInputFilename);
208 const stdair::ODFilePath lODFilePath (lOnDInputFilename);
209 const stdair::FRAT5FilePath lFRAT5FilePath (lFRAT5InputFilename);
210 const stdair::FFDisutilityFilePath lFFDisutilityFilePath (lFFDisutilityInputFilename);
211 const SIMFQT::FareFilePath lFareFilePath (lFareInputFilename);
212 const AIRRAC::YieldFilePath lYieldFilePath (lYieldInputFilename);
213 const TRADEMGEN::DemandFilePath lDemandFilePath (lDemandInputFilename);
216 BOOST_CHECK_NO_THROW (tvlsimService.setInputFiles(lScheduleFilePath,
219 lFFDisutilityFilePath,
225 BOOST_CHECK_NO_THROW (tvlsimService.parseAndLoad ());
228 BOOST_CHECK_NO_THROW (tvlsimService.initSnapshotAndRMEvents());
232 BOOST_CHECK_NO_THROW (tvlsimService.simulate ());
235 logOutputFile.close();
239 BOOST_AUTO_TEST_SUITE_END()