*/
#include <sstream>
#include <fstream>
#include <string>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE TvlSimTest
#include <boost/test/unit_test.hpp>
#include <stdair/stdair_exceptions.hpp>
#include <stdair/stdair_json.hpp>
#include <stdair/basic/BasConst_General.hpp>
#include <stdair/basic/BasLogParams.hpp>
#include <stdair/basic/BasFileMgr.hpp>
#include <stdair/basic/DemandGenerationMethod.hpp>
#include <stdair/service/Logger.hpp>
#include <simfqt/SIMFQT_Types.hpp>
#include <tvlsim/config/tvlsim-paths.hpp>
namespace boost_utf = boost::unit_test;
std::ofstream utfReportStream ("PartnerSimulationTestSuite_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() {
}
};
BOOST_GLOBAL_FIXTURE (UnitTestConfig);
BOOST_AUTO_TEST_SUITE (master_test_suite)
BOOST_AUTO_TEST_CASE (partner_simulation_test) {
const stdair::DemandGenerationMethod lOrderStatDemandGenMethod =
stdair::DemandGenerationMethod::STA_ORD;
const stdair::Date_T lStartDate (2009, boost::gregorian::Jan, 01);
const stdair::Date_T lEndDate (2011, boost::gregorian::Jan, 01);
const stdair::RandomSeed_T lRandomSeed (stdair::DEFAULT_RANDOM_SEED);
"/IBP_study/demand01.csv");
"/IBP_study/schedule01.csv");
const stdair::Filename_T lOnDInputFilename (
STDAIR_SAMPLE_DIR "/IBP_study/ond01.csv");
"/frat5.csv");
"/ffDisutility.csv");
"/IBP_study/yield01.csv");
"/IBP_study/fare01.csv");
bool doesExistAndIsReadable =
stdair::BasFileMgr::doesExistAndIsReadable (lScheduleInputFilename);
BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
"The '" << lScheduleInputFilename
<< "' input file can not be open and read");
doesExistAndIsReadable =
stdair::BasFileMgr::doesExistAndIsReadable (lOnDInputFilename);
BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
"The '" << lOnDInputFilename
<< "' input file can not be open and read");
doesExistAndIsReadable =
stdair::BasFileMgr::doesExistAndIsReadable (lFRAT5InputFilename);
BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
"The '" << lFRAT5InputFilename
<< "' input file can not be open and read");
doesExistAndIsReadable =
stdair::BasFileMgr::doesExistAndIsReadable (lFFDisutilityInputFilename);
BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
"The '" << lFFDisutilityInputFilename
<< "' input file can not be open and read");
doesExistAndIsReadable =
stdair::BasFileMgr::doesExistAndIsReadable (lDemandInputFilename);
BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
"The '" << lDemandInputFilename
<< "' input file can not be open and read");
doesExistAndIsReadable =
stdair::BasFileMgr::doesExistAndIsReadable (lFareInputFilename);
BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
"The '" << lFareInputFilename
<< "' input file can not be open and read");
doesExistAndIsReadable =
stdair::BasFileMgr::doesExistAndIsReadable (lYieldInputFilename);
BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
"The '" << lYieldInputFilename
<< "' input file can not be open and read");
const stdair::Filename_T lLogFilename ("PartnerSimulationTestSuite.log");
std::ofstream logOutputFile;
logOutputFile.open (lLogFilename.c_str());
logOutputFile.clear();
const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
lRandomSeed, lOrderStatDemandGenMethod,
lNbOfRuns);
std::ostringstream lMyCommandJSONstream;
lMyCommandJSONstream << "{\"config\":"
<< "{\"airline1\":"
<< "{ \"airline_code\":\"" << "SQ"
<< "\",\"unconstraining_method\":\"" << "E"
<< "\",\"pre_optimisation_method\":\"N"
<< "\",\"optimisation_method\":\"M"
<< "\",\"partnership_technique\":\"i"
<< "\",\"forecasting_method\":\"B"
<< "\"},"
<< "\"airline2\":"
<< "{ \"airline_code\":\"" << "CX"
<< "\",\"unconstraining_method\":\"" << "E"
<< "\",\"pre_optimisation_method\":\"N"
<< "\",\"optimisation_method\":\"M"
<< "\",\"partnership_technique\":\"i"
<< "\",\"forecasting_method\":\"B"
<< "\"}}}";
STDAIR_LOG_DEBUG(lMyCommandJSONstream.str());
const stdair::JSONString lJSONCommandString (lMyCommandJSONstream.str());
const std::string& lCSVConfigDump =
tvlsimService.jsonHandler (lJSONCommandString);
STDAIR_LOG_DEBUG(lCSVConfigDump);
const stdair::ScheduleFilePath lScheduleFilePath (lScheduleInputFilename);
const stdair::ODFilePath lODFilePath (lOnDInputFilename);
const stdair::FRAT5FilePath lFRAT5FilePath (lFRAT5InputFilename);
const stdair::FFDisutilityFilePath lFFDisutilityFilePath (lFFDisutilityInputFilename);
const SIMFQT::FareFilePath lFareFilePath (lFareInputFilename);
const AIRRAC::YieldFilePath lYieldFilePath (lYieldInputFilename);
const TRADEMGEN::DemandFilePath lDemandFilePath (lDemandInputFilename);
BOOST_CHECK_NO_THROW (tvlsimService.setInputFiles(lScheduleFilePath,
lODFilePath,
lFRAT5FilePath,
lFFDisutilityFilePath,
lYieldFilePath,
lFareFilePath,
lDemandFilePath));
BOOST_CHECK_NO_THROW (tvlsimService.parseAndLoad ());
BOOST_CHECK_NO_THROW (tvlsimService.initSnapshotAndRMEvents());
BOOST_CHECK_NO_THROW (tvlsimService.simulate ());
logOutputFile.close();
}
BOOST_AUTO_TEST_SUITE_END()
*/
#include <sstream>
#include <fstream>
#include <string>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE SimulationTestSuite
#include <boost/test/unit_test.hpp>
#include <stdair/stdair_exceptions.hpp>
#include <stdair/basic/BasConst_General.hpp>
#include <stdair/basic/BasLogParams.hpp>
#include <stdair/basic/BasFileMgr.hpp>
#include <stdair/basic/DemandGenerationMethod.hpp>
#include <stdair/service/Logger.hpp>
#include <simfqt/SIMFQT_Types.hpp>
#include <tvlsim/config/tvlsim-paths.hpp>
namespace boost_utf = boost::unit_test;
std::ofstream utfReportStream ("SimulationTestSuite_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() {
}
};
void SimulationTest (const unsigned short iTestFlag,
const stdair::Filename_T iScheduleInputFilename,
const stdair::Filename_T iOnDInputFilename,
const stdair::Filename_T iFRAT5InputFilename,
const stdair::Filename_T iFFDisutilityInputFilename,
const stdair::Filename_T iYieldInputFilename,
const stdair::Filename_T iFareInputFilename,
const stdair::Filename_T iDemandInputFilename,
const bool isBuiltin) {
const stdair::DemandGenerationMethod lOrderStatDemandGenMethod =
stdair::DemandGenerationMethod::STA_ORD;
const stdair::Date_T lStartDate (2009, boost::gregorian::Jan, 01);
const stdair::Date_T lEndDate (2011, boost::gregorian::Jan, 01);
const stdair::RandomSeed_T lRandomSeed (stdair::DEFAULT_RANDOM_SEED);
std::ostringstream oStr;
oStr << "SimpleSimulationTestSuite_" << iTestFlag << ".log";
const stdair::Filename_T lLogFilename (oStr.str());
std::ofstream logOutputFile;
logOutputFile.open (lLogFilename.c_str());
logOutputFile.clear();
const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
lRandomSeed, lOrderStatDemandGenMethod,
lNbOfRuns);
if (isBuiltin == true) {
tvlsimService.buildSampleBom();
} else {
const stdair::ScheduleFilePath lScheduleFilePath (iScheduleInputFilename);
const stdair::ODFilePath lODFilePath (iOnDInputFilename);
const stdair::FRAT5FilePath lFRAT5FilePath (iFRAT5InputFilename);
const stdair::FFDisutilityFilePath lFFDisutilityFilePath (iFFDisutilityInputFilename);
const AIRRAC::YieldFilePath lYieldFilePath (iYieldInputFilename);
const SIMFQT::FareFilePath lFareFilePath (iFareInputFilename);
const TRADEMGEN::DemandFilePath lDemandFilePath (iDemandInputFilename);
tvlsimService.setInputFiles(lScheduleFilePath,
lODFilePath,
lFRAT5FilePath,
lFFDisutilityFilePath,
lYieldFilePath,
lFareFilePath,
lDemandFilePath);
tvlsimService.parseAndLoad ();
}
tvlsimService.initSnapshotAndRMEvents();
tvlsimService.simulate ();
logOutputFile.close();
}
BOOST_GLOBAL_FIXTURE (UnitTestConfig);
BOOST_AUTO_TEST_SUITE (master_test_suite)
BOOST_AUTO_TEST_CASE (simple_simulation_test) {
const bool isBuiltin = false;
"/rds01/schedule.csv");
"/frat5.csv");
"/ffDisutility.csv");
"/rds01/yield.csv");
"/rds01/fare.csv");
"/rds01/demand.csv");
BOOST_CHECK_NO_THROW (SimulationTest(0,
lScheduleInputFilename,
lOnDInputFilename,
lFRAT5InputFilename,
lFFDisutilityInputFilename,
lYieldInputFilename,
lFareInputFilename,
lDemandInputFilename,
isBuiltin));
}
BOOST_AUTO_TEST_CASE (default_bom_simulation_test) {
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW (SimulationTest(1,
" ", " ", " ", " ", " ", " ", " ",
isBuiltin));
}
BOOST_AUTO_TEST_SUITE_END()