7#include <stdair/basic/RandomGeneration.hpp>
8#include <stdair/basic/BasFileMgr.hpp>
9#include <stdair/service/Logger.hpp>
16namespace bsc = boost::spirit::classic;
57 const stdair::DateOffset_T oneDay (1);
62 stdair::DatePeriod_T (
_demand._prefDepDateStart,
76 stdair::DOW_String_T lDow (iStr, iStrEnd);
87 stdair::AirportCode_T lOrigin (iStr, iStrEnd);
99 stdair::AirportCode_T lDestination (iStr, iStrEnd);
100 _demand._destination = lDestination;
111 stdair::CabinCode_T lPrefCabin (iStr, iStrEnd);
112 _demand._prefCabin = lPrefCabin;
145 _demand._changeFeeProb = iReal;
156 _demand._changeFeeDisutility = iReal;
168 _demand._nonRefundableProb = iReal;
180 _demand._nonRefundableDisutility = iReal;
191 const stdair::AirportCode_T lPosCode (iStr, iStrEnd);
203 const bool hasInsertBeenSuccessfull =
206 value_type (
_demand._itPosCode, iReal)).second;
207 if (hasInsertBeenSuccessfull ==
false) {
208 STDAIR_LOG_ERROR (
"The same POS code ('" <<
_demand._itPosCode
209 <<
"') has probably been given twice");
210 throw stdair::CodeDuplicationException (
"The same POS code ('"
212 +
"') has probably been given twice");
226 _demand._itChannelCode = std::string (iStr, iStrEnd);
237 const bool hasInsertBeenSuccessfull =
240 value_type (
_demand._itChannelCode, iReal)).second;
241 if (hasInsertBeenSuccessfull ==
false) {
242 STDAIR_LOG_ERROR (
"The same channel type code ('"
244 <<
"') has probably been given twice");
245 throw stdair::CodeDuplicationException (
"The same channel type code ('"
247 +
"') has probably been given twice");
261 _demand._itTripCode = std::string (iStr, iStrEnd);
272 const bool hasInsertBeenSuccessfull =
275 value_type (
_demand._itTripCode, iReal)).second;
276 if (hasInsertBeenSuccessfull ==
false) {
277 STDAIR_LOG_ERROR (
"The same trip type code ('"
279 <<
"') has probably been given twice");
280 throw stdair::CodeDuplicationException (
"The same trip type code ('"
282 +
"') has probably been given twice");
295 const stdair::DayDuration_T lStayDuration (iInteger);
296 _demand._itStayDuration = lStayDuration;
307 const bool hasInsertBeenSuccessfull =
310 value_type (
_demand._itStayDuration, iReal)).second;
311 if (hasInsertBeenSuccessfull ==
false) {
312 std::ostringstream oStr;
313 oStr <<
"The same stay duration ('" <<
_demand._itStayDuration
314 <<
"') has probably been given twice";
315 STDAIR_LOG_ERROR (oStr.str());
316 throw stdair::CodeDuplicationException (oStr.str());
329 _demand._itFFCode = std::string (iStr, iStrEnd);
340 const bool hasInsertBeenSuccessfull =
343 value_type (
_demand._itFFCode, iReal)).second;
344 if (hasInsertBeenSuccessfull ==
false) {
345 STDAIR_LOG_ERROR (
"The same Frequent Flyer code ('"
347 <<
"') has probably been given twice");
348 throw stdair::CodeDuplicationException(
"The same Frequent Flyer code ('"
350 +
"') has probably been given twice");
383 const stdair::IntDuration_T lIntDuration =
384 _demand._itPrefDepTime.total_seconds();
388 value_type (lIntDuration, iReal));
423 value_type (
_demand._itTimeValue, iReal));
434 const stdair::DayDuration_T lDTD (iInteger);
446 const stdair::FloatDuration_T lZeroDTDFloat = 0.0;
447 stdair::FloatDuration_T lDTDFloat =
448 static_cast<stdair::FloatDuration_T
> (
_demand._itDTD);
449 lDTDFloat = lZeroDTDFloat - lDTDFloat;
452 value_type (lDTDFloat, iReal));
458 stdair::RandomGeneration& ioSharedGenerator,
481 _demand._channelProbDist.clear();
485 _demand._prefDepTimeProbDist.clear();
486 _demand._timeValueProbDist.clear();
569 stdair::RandomGeneration& ioSharedGenerator,
578 template<
typename ScannerT>
587 lexeme_d[bsc::comment_p(
"//")
588 | bsc::comment_p(
"/*",
"*/")
652 | bsc::chseq_p(
"row")
669 bsc::chseq_p(
"DF") | bsc::chseq_p(
"DN")
670 | bsc::chseq_p(
"IF") | bsc::chseq_p(
"IN")
687 bsc::chseq_p(
"RO") | bsc::chseq_p(
"RI") | bsc::chseq_p(
"OW")
794 BOOST_SPIRIT_DEBUG_NODE (
demand);
796 BOOST_SPIRIT_DEBUG_NODE (pref_dep_date);
797 BOOST_SPIRIT_DEBUG_NODE (
date);
798 BOOST_SPIRIT_DEBUG_NODE (
origin);
816 BOOST_SPIRIT_DEBUG_NODE (
ff_dist);
817 BOOST_SPIRIT_DEBUG_NODE (
ff_pair);
818 BOOST_SPIRIT_DEBUG_NODE (
ff_code);
825 BOOST_SPIRIT_DEBUG_NODE (
time);
826 BOOST_SPIRIT_DEBUG_NODE (
wtp);
837 template<
typename ScannerT>
838 bsc::rule<ScannerT>
const&
855 stdair::RandomGeneration& ioSharedGenerator,
857 const std::string& iFilename)
858 : _filename (iFilename),
859 _sevmgrServicePtr (ioSEVMGR_ServicePtr),
860 _uniformGenerator (ioSharedGenerator),
861 _posProbabilityMass (iPOSProbMass) {
866 void DemandFileParser::init() {
868 const bool doesExistAndIsReadable =
869 stdair::BasFileMgr::doesExistAndIsReadable (_filename);
871 if (doesExistAndIsReadable ==
false) {
872 STDAIR_LOG_ERROR (
"The demand file " << _filename
873 <<
" does not exist or can not be read.");
876 +
" does not exist or can not "
884 if (!_startIterator) {
885 STDAIR_LOG_ERROR (
"The demand file " << _filename <<
" can not be open.");
887 throw DemandInputFileNotFoundException (
"The demand file " + _filename
888 +
" does not exist or can not "
893 _endIterator = _startIterator.make_end();
898 bool oResult =
false;
900 STDAIR_LOG_DEBUG (
"Parsing demand input file: " << _filename);
911 bsc::parse_info<iterator_t> info =
912 bsc::parse (_startIterator, _endIterator, lDemandParser,
913 bsc::space_p - bsc::eol_p);
918 const std::string hasBeenFullyReadStr = (info.full ==
true)?
"":
"not ";
919 if (oResult ==
true) {
920 STDAIR_LOG_DEBUG (
"Parsing of demand input file: " << _filename
921 <<
" succeeded: read " << info.length
922 <<
" characters. The input file has "
923 << hasBeenFullyReadStr
924 <<
"been fully read. Stop point: " << info.stop);
927 std::ostringstream oStr;
928 oStr <<
"Parsing of demand input file: " << _filename <<
" failed: read "
929 << info.length <<
" characters. The input file has "
930 << hasBeenFullyReadStr <<
"been fully read. Stop point: "
932 STDAIR_LOG_ERROR (oStr.str());
933 throw stdair::ParserException (oStr.str());
boost::spirit::classic::file_iterator< char_t > iterator_t
FrequentFlyerProbabilityMass_T::ProbabilityMassFunction_T FrequentFlyerProbabilityMassFunction_T
StayDurationProbabilityMass_T::ProbabilityMassFunction_T StayDurationProbabilityMassFunction_T
ValueOfTimeCumulativeDistribution_T::ContinuousDistribution_T ValueOfTimeContinuousDistribution_T
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 3 > uint1_3_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 2, 2 > uint2_p_t
boost::spirit::classic::impl::loop_traits< chset_t, unsignedint, unsignedint >::type repeat_p_t
boost::spirit::classic::bounded< uint1_4_p_t, unsigned int > bounded1_4_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 4, 4 > uint4_p_t
boost::spirit::classic::bounded< uint4_p_t, unsigned int > bounded4_p_t
TripTypeProbabilityMass_T::ProbabilityMassFunction_T TripTypeProbabilityMassFunction_T
boost::spirit::classic::bounded< uint1_2_p_t, unsigned int > bounded1_2_p_t
boost::spirit::classic::bounded< uint1_3_p_t, unsigned int > bounded1_3_p_t
CategoricalAttributeLite< stdair::AirportCode_T > POSProbabilityMass_T
boost::spirit::classic::bounded< uint2_p_t, unsigned int > bounded2_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 2 > uint1_2_p_t
boost::spirit::classic::chset< char_t > chset_t
ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPatternCumulativeDistribution_T
PreferredDepartureTimeCumulativeDistribution_T::ContinuousDistribution_T PreferredDepartureTimeContinuousDistribution_T
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 4 > uint1_4_p_t
ChannelProbabilityMass_T::ProbabilityMassFunction_T ChannelProbabilityMassFunction_T
POSProbabilityMass_T::ProbabilityMassFunction_T POSProbabilityMassFunction_T
boost::spirit::classic::int_parser< unsigned int, 10, 1, 1 > int1_p_t
bounded4_p_t year_p(uint4_p.derived(), 2000u, 2099u)
bounded2_p_t seconds_p(uint2_p.derived(), 0u, 59u)
repeat_p_t airline_code_p(chset_t("0-9A-Z").derived(), 2, 3)
chset_t cabin_code_p("A-Z")
repeat_p_t class_code_list_p(chset_t("A-Z").derived(), 1, 26)
bounded2_p_t month_p(uint2_p.derived(), 1u, 12u)
bounded2_p_t minutes_p(uint2_p.derived(), 0u, 59u)
chset_t passenger_type_p("A-Z")
bounded1_4_p_t flight_number_p(uint1_4_p.derived(), 0u, 9999u)
bounded2_p_t day_p(uint2_p.derived(), 1u, 31u)
repeat_p_t dow_p(chset_t("0-1").derived().derived(), 7, 7)
bounded1_2_p_t hours_p(uint1_2_p.derived(), 0u, 23u)
repeat_p_t airport_p(chset_t("0-9A-Z").derived(), 3, 3)
bounded1_3_p_t stay_duration_p(uint1_3_p.derived(), 0u, 999u)
ParserSemanticAction(DemandStruct &)
storePrefDepDateRangeStart(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storePrefDepDateRangeEnd(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeOrigin(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeDestination(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storePrefCabin(DemandStruct &)
void operator()(double iReal) const
storeDemandMean(DemandStruct &)
void operator()(double iReal) const
storeDemandStdDev(DemandStruct &)
storeDemandChangeFeeProb(DemandStruct &)
void operator()(double iReal) const
storeDemandChangeFeeDisutility(DemandStruct &)
void operator()(double iReal) const
void operator()(double iReal) const
storeDemandNonRefundableProb(DemandStruct &)
storeDemandNonRefundableDisutility(DemandStruct &)
void operator()(double iReal) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storePosCode(DemandStruct &)
void operator()(double iReal) const
storePosProbMass(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeChannelCode(DemandStruct &)
storeChannelProbMass(DemandStruct &)
void operator()(double iReal) const
storeTripCode(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeTripProbMass(DemandStruct &)
void operator()(double iReal) const
storeStayCode(DemandStruct &)
void operator()(unsigned int iInteger) const
void operator()(double iReal) const
storeStayProbMass(DemandStruct &)
storeFFCode(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(double iReal) const
storeFFProbMass(DemandStruct &)
storePrefDepTime(DemandStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storePrefDepTimeProbMass(DemandStruct &)
void operator()(double iReal) const
void operator()(double iReal) const
storeTimeValue(DemandStruct &)
void operator()(double iReal) const
storeTimeValueProbMass(DemandStruct &)
void operator()(double iReal) const
void operator()(unsigned int iInteger) const
void operator()(double iReal) const
storeDTDProbMass(DemandStruct &)
doEndDemand(SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration &, const POSProbabilityMass_T &, DemandStruct &)
SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr
stdair::RandomGeneration & _uniformGenerator
void operator()(iterator_t iStr, iterator_t iStrEnd) const
const POSProbabilityMass_T & _posProbabilityMass
stdair::RandomGeneration & _uniformGenerator
DemandParser(SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration &, const POSProbabilityMass_T &, DemandStruct &)
const POSProbabilityMass_T & _posProbabilityMass
SEVMGR::SEVMGR_ServicePtr_T _sevmgrServicePtr
boost::spirit::classic::rule< ScannerT > dow
boost::spirit::classic::rule< ScannerT > demand
boost::spirit::classic::rule< ScannerT > trip_share
boost::spirit::classic::rule< ScannerT > demand_list
boost::spirit::classic::rule< ScannerT > non_refundable
boost::spirit::classic::rule< ScannerT > stay_pair
boost::spirit::classic::rule< ScannerT > time
boost::spirit::classic::rule< ScannerT > ff_pair
boost::spirit::classic::rule< ScannerT > pos_code
boost::spirit::classic::rule< ScannerT > demand_end
boost::spirit::classic::rule< ScannerT > channel_code
boost::spirit::classic::rule< ScannerT > pref_dep_time_dist
boost::spirit::classic::rule< ScannerT > origin
boost::spirit::classic::rule< ScannerT > wtp
boost::spirit::classic::rule< ScannerT > trip_code
boost::spirit::classic::rule< ScannerT > pref_dep_time_share
boost::spirit::classic::rule< ScannerT > pref_cabin
boost::spirit::classic::rule< ScannerT > channel_share
boost::spirit::classic::rule< ScannerT > pos_share
boost::spirit::classic::rule< ScannerT > channel_pair
boost::spirit::classic::rule< ScannerT > stay_share
boost::spirit::classic::rule< ScannerT > trip_pair
boost::spirit::classic::rule< ScannerT > time_value_pair
boost::spirit::classic::rule< ScannerT > destination
boost::spirit::classic::rule< ScannerT > pos_dist
boost::spirit::classic::rule< ScannerT > ff_code
boost::spirit::classic::rule< ScannerT > demand_params
boost::spirit::classic::rule< ScannerT > stay_dist
boost::spirit::classic::rule< ScannerT > dtd_dist
boost::spirit::classic::rule< ScannerT > pref_dep_time_pair
boost::spirit::classic::rule< ScannerT > time_value_dist
boost::spirit::classic::rule< ScannerT > pos_pair
boost::spirit::classic::rule< ScannerT > change_fees
boost::spirit::classic::rule< ScannerT > const & start() const
definition(DemandParser const &self)
boost::spirit::classic::rule< ScannerT > ff_share
boost::spirit::classic::rule< ScannerT > dtd_pair
boost::spirit::classic::rule< ScannerT > trip_dist
boost::spirit::classic::rule< ScannerT > pref_dep_date_range
boost::spirit::classic::rule< ScannerT > ff_dist
boost::spirit::classic::rule< ScannerT > channel_dist
boost::spirit::classic::rule< ScannerT > date
boost::spirit::classic::rule< ScannerT > time_value_share
boost::spirit::classic::rule< ScannerT > dtd_share
boost::spirit::classic::rule< ScannerT > not_to_be_parsed
DemandFileParser(SEVMGR::SEVMGR_ServicePtr_T, stdair::RandomGeneration &, const POSProbabilityMass_T &, const stdair::Filename_T &iDemandInputFilename)