You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
(51) |
Nov
(8) |
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(32) |
Feb
(47) |
Mar
(6) |
Apr
(19) |
May
(7) |
Jun
(19) |
Jul
(39) |
Aug
(51) |
Sep
(39) |
Oct
(18) |
Nov
(10) |
Dec
(27) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <qua...@us...> - 2010-02-16 16:50:26
|
Revision: 145 http://stdair.svn.sourceforge.net/stdair/?rev=145&view=rev Author: quannaus Date: 2010-02-16 16:50:19 +0000 (Tue, 16 Feb 2010) Log Message: ----------- [test] Removed an empty line. Modified Paths: -------------- trunk/stdair/test/samples/schedule01.csv Modified: trunk/stdair/test/samples/schedule01.csv =================================================================== --- trunk/stdair/test/samples/schedule01.csv 2010-02-16 16:49:09 UTC (rev 144) +++ trunk/stdair/test/samples/schedule01.csv 2010-02-16 16:50:19 UTC (rev 145) @@ -4,5 +4,4 @@ // LegCabins: CabinCode; Capacity; // Segments: Specific; SQ; 11; 2010-01-15; 2010-02-28; 1111111; SIN; BKK; 08:20; 11:00; 07:40; Y; 300; 0; Y; YM; -SQ; 12; 2010-01-15; 2010-02-28; 1111111; SIN; HND; 09:20; 12:00; 07:40; Y; 200; 0; Y; YM; - +SQ; 12; 2010-01-15; 2010-02-28; 1111111; SIN; HND; 09:20; 12:00; 07:40; Y; 200; 0; Y; YM; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-16 16:49:16
|
Revision: 144 http://stdair.svn.sourceforge.net/stdair/?rev=144&view=rev Author: quannaus Date: 2010-02-16 16:49:09 +0000 (Tue, 16 Feb 2010) Log Message: ----------- [dev] Added some attributes into BookingRequest. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/CategoricalAttribute.hpp trunk/stdair/stdair/basic/ContinuousAttribute.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStreamContent.hpp Added Paths: ----------- trunk/stdair/stdair/basic/BasConst_Request.hpp trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp Removed Paths: ------------- trunk/stdair/stdair/basic/ArrivalPattern.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -450,5 +450,16 @@ /** Type definition for the hashed key of the DemandStreamKey object. */ typedef std::string DemandStreamKeyStr_T; + + /** Type of booking channel (D=direct, I=indirect, N=oNline, F=oFfline). */ + typedef std::string ChannelLabel_T; + + /** Type of trip type (RO=outbound of round-trip, RI=inbound of round-trip, + OW=one way). */ + typedef std::string TripType_T; + + /** Type of frequent flyer (P=Platinum, G=Gold, S=Silver, M=Member, N=None). */ + typedef std::string FrequentFlyer_T; + } #endif // __STDAIR_STDAIR_TYPES_HPP Deleted: trunk/stdair/stdair/basic/ArrivalPattern.hpp =================================================================== --- trunk/stdair/stdair/basic/ArrivalPattern.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/ArrivalPattern.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -1,27 +0,0 @@ -#ifndef __STDAIR_BAS_ARRIVALPATTERN_HPP -#define __STDAIR_BAS_ARRIVALPATTERN_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// StdAir -#include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/ContinuousAttribute.hpp> - -namespace stdair { - - /** Type definition for the continuous distribition of the duration - (as a float number). */ - typedef ContinuousAttribute<FloatDuration_T> ContinuousFloatDuration_T; - - /** Type definition for the arrival pattern. */ - typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPattern_T; - - /** Type definition for the arrival pattern cumulative distribution. */ - typedef std::multimap<FloatDuration_T, Probability_T> ArrivalPatternCumulativeDistribution_T; - - /** Type definition for the arrival pattern inverse cumulative distribution. */ - typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; - -} -#endif // __STDAIR_BAS_ARRIVALPATTERN_HPP Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-02-16 16:49:09 UTC (rev 144) @@ -6,6 +6,7 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/basic/BasConst_General.hpp> +#include <stdair/basic/BasConst_Request.hpp> #include <stdair/basic/BasConst_Inventory.hpp> #include <stdair/basic/BasConst_BookingClass.hpp> #include <stdair/basic/BasConst_Yield.hpp> @@ -24,92 +25,11 @@ /** Default number of generated flight dates . */ const NbOfFlightDates_T DEFAULT_NB_OF_FLIGHTDATES = 0.0; - - // // ///////// GSL ///////// - // /** Default (GSL) random generator type. */ - // const gsl_rng_type* DEFAULT_LATUS_RANDOM_GENERATOR_TYPE = gsl_rng_default; - - // /** Default seed value for Exponential distribution. */ - // const ExponentialSeed_T DEFAULT_EXPONENTIAL_SEED = 0; - - // /** Default seed value for Exponential distribution. */ - // const UniformSeed_T DEFAULT_UNIFORM_SEED = 0; - - // // ///////// Labels in General Configuration Files ///////// - // /** Default file path separator*/ - // const std::string DEFAULT_CONFIG_FILEPATH_SEPARATOR = "/"; - - // /** Default label for RDS. */ - // const std::string DEFAULT_CONFIG_RDS_LABEL = "rds"; - // /** Default label for RDS file path. */ - // const std::string DEFAULT_CONFIG_RDS_FILEPATH_LABEL = "rds_path"; - // /** Default label for RDS Id (= folder holding RDS). */ - // const std::string DEFAULT_CONFIG_RDS_ID_LABEL = "rds_id"; - // /** Default label for RDS manifest. */ - // const std::string DEFAULT_CONFIG_RDS_MANIFEST_LABEL = "rds_manifest"; - // /** Default label for RDS airline configuration file name. */ - // const std::string DEFAULT_CONFIG_RDS_AIRLINE_CONFIGURATION_LABEL = - // "airlineconfiguration"; - - // /** Default label for output files. */ - // const std::string DEFAULT_CONFIG_OUTPUT_FILE_LABEL = "output_files"; - // /** Default label for inventory output file name. */ - // const std::string DEFAULT_CONFIG_INVENTORY_OUTPUT_FILE_LABEL = - // "inventory_output"; - // /** Default label for simulation output file name. */ - // const std::string DEFAULT_CONFIG_SIMULATION_OUTPUT_FILE_LABEL = - // "simulation_output"; - - // // ///////// Lables in RDS XML file ///////// - // const std::string DEFAULT_CONFIG_RDS_DEMAND_ARRIVAL_FILENAME_LABEL = - // "demandpattern"; - // const std::string DEFAULT_CONFIG_RDS_CANCEL_FILENAME_LABEL = - // "cancelratecurve"; - // const std::string DEFAULT_CONFIG_RDS_CHARACTERISTIC_FILENAME_LABEL = - // "characteristics"; - // const std::string DEFAULT_CONFIG_RDS_DEMAND_FILENAME_LABEL = "demands"; - // const std::string DEFAULT_CONFIG_RDS_SCHEDULE_FILENAME_LABEL = "schedule"; - // const std::string DEFAULT_CONFIG_RDS_FARE_FILENAME_LABEL = "fares"; - // const std::string DEFAULT_CONFIG_RDS_YIELD_FILENAME_LABEL = "yields"; - // const std::string DEFAULT_CONFIG_RDS_AU_RULES_FILENAME_LABEL = "aurules"; - // const std::string DEFAULT_CONFIG_RDS_LFDTD_RULES_FILENAME_LABEL = "lfdtdrules"; - // const std::string DEFAULT_CONFIG_RDS_DCP_FILENAME_LABEL = - // "datacollectionpoints"; - - // // ///////// BOOST Date-Time ///////// - // // Time duration representing a full day - // // (i.e., 24h or 1,440 minutes or 86,400 seconds) - - // /** Time duration representing a full day (in boost::time_duration unit).*/ - // const Duration_T BOOST_TIME_DURATION_FOR_A_DAY = - // boost::posix_time::hours(24); - - // /** Time duration representing a full day (in seconds).*/ - // const int TIME_DURATION_FOR_A_DAY_IN_SECONDS = - // static_cast<const int> (BOOST_TIME_DURATION_FOR_A_DAY.total_seconds()); - - // /** Time duration representing a full hour (in seconds).*/ - // const int TIME_DURATION_FOR_AN_HOUR_IN_SECONDS = 3600; - - // /** Time duration representing a full minute (in seconds).*/ - // const int TIME_DURATION_FOR_A_MINUTE_IN_SECONDS = 60; - /** Null time duration (in boost::time_duration unit).*/ const Duration_T NULL_BOOST_TIME_DURATION = boost::posix_time::hours(0)+ boost::posix_time::minutes (0) + boost::posix_time::seconds (0); - // /** Date duration representing a full day (in boost::date_duration unit).*/ - // const DateOffSet_T BOOST_DATE_DURATION_FOR_A_DAY (1); - - // /** Date duration representing the window of time used for statistical - // analysis. */ - // const DateOffSet_T DEFAULT_ANALYSIS_TIME_WINDOW (180); - - // /** Date duration representing the period of reservation for a - // typical flight. */ - // const DateOffSet_T DEFAULT_RESERVATION_PERIOD_LENGTH (365); - // //////// (Flight-)Period-related BOM /////// /** Default number of duration days. */ @@ -144,6 +64,7 @@ /** Number of milliseconds in one second */ const Count_T MILLISECONDS_IN_ONE_SECOND = 1000; + // //////// Fare Rules /////// /** Default saturdayStay value (false). */ const SaturdayStay_T DEFAULT_SATURDAY_STAY = false; @@ -178,34 +99,7 @@ /** Default flightPathCode value (''). */ const FlightPathCode_T DEFAULT_FLIGHTPATH_CODE = ""; - // // //////// DemandFeatures /////// - // /** Default SaturdayStay average ratio of demand (value between [0, 100]). */ - // const SaturdayStayRatio_T DEFAULT_SATURDAY_STAY_RATIO = 50; - // /** Default Change fees average ratio (value between [0, 100]). */ - // const ChangeFeesRatio_T DEFAULT_CHANGE_FEES_RATIO = 50; - - // /** Default Non refundable average ratio (value between [0, 100]). */ - // const NonRefundableRatio_T DEFAULT_NON_REFUNDABLE_RATIO = 50; - - // /** Default passenger type (Leisure or Business). */ - // const PassengerType_T DEFAULT_PASSENGER_TYPE = "L"; - - // /** Default distribution pattern identifier. */ - // const DistributionPatternId_T DEFAULT_DISTRIBUTION_PATTERN_ID = ""; - - // /** Default cancellation rate curve identifier. */ - // const CancellationRateCurveId_T DEFAULT_CANCELLATION_RATE_CURVE_ID = ""; - - // /** Default airline preference identifier. */ - // const AirlinePreferenceId_T DEFAULT_AIRLINE_PREFERENCE_ID = ""; - - // /** Default percentage pair of cancellation and no-show. */ - // const CancellationNoShowRatePair_T DEFAULT_PERCENTAGE_PAIR (0.0, 0.0); - - // /** Default characteristics pattern identifier. */ - // const CharacteristicsPatternId_T DEFAULT_CHARACTERISTICS_PATTERN_ID = ""; - // //////// (Segment-)Class-related BOM /////// /** Default distance value (kilometers). */ const Distance_T DEFAULT_DISTANCE_VALUE = 0; @@ -286,6 +180,7 @@ /** Default load factor value (100%). */ const Percentage_T DEFAULT_LOAD_FACTOR_VALUE = 100.0; + // //////// (Leg-)YieldRange-related BOM /////// /** Default yield value. */ const Yield_T DEFAULT_YIELD_VALUE = 0.0; @@ -322,156 +217,25 @@ /** Default value of Fare. */ const Fare_T DEFAULT_OND_FARE_VALUE = 0.0; - // /** Default number of bookings. */ - // const NbOfBookings_T DEFAULT_OND_NB_OF_BOOKINGS = 0.0; + // //////// Booking Request ///////// + /** Default party size in a request. */ + const PartySize_T DEFAULT_PARTY_SIZE = 1; - // /** Default remaining future demand mean for OnD. */ - // const NbOfBookings_T DEFAULT_OND_REMAINING_DEMAND_MEAN = 0.0; - - // /** Default remaining futre demand standard deviation for OnD. */ - // const NbOfBookings_T DEFAULT_OND_REMAINING_DEMAND_STANDARD_DEVIATION = 0.0; - // //////// Travel Solutions /////// - /** Default Minimum connection time. */ - const Duration_T DEFAULT_MINIMUM_CONNECTION_TIME (0, 30, 0); + // //////// Travel Solutions /////// + /** Default Minimum connection time. */ + const Duration_T DEFAULT_MINIMUM_CONNECTION_TIME (0, 30, 0); - /** Default Matching Indicator value. */ - const MatchingIndicator_T DEFAULT_MATCHING_INDICATOR (0.0); + /** Default Matching Indicator value. */ + const MatchingIndicator_T DEFAULT_MATCHING_INDICATOR (0.0); - /** Default price value (0.0). */ - // const PriceValue_T DEFAULT_PRICE_VALUE (0.0); + /** Default currency (euro). */ + const PriceCurrency_T DEFAULT_CURRENCY ("EUR"); - /** Default currency (euro). */ - const PriceCurrency_T DEFAULT_CURRENCY ("EUR"); + /** Default availability status for a travel solution. */ + const AvailabilityStatus_T DEFAULT_AVAILABILITY_STATUS = false; - /** Default availability status for a travel solution. */ - const AvailabilityStatus_T DEFAULT_AVAILABILITY_STATUS = false; - // // //////// Cancellation /////// - // /** Default Fare value */ - // const Fare_T DEFAULT_FARE_VALUE = 0.0; - - // /** Default number of bookings. */ - // const NbOfBookings_T DEFAULT_NB_OF_BOOKINGS = 0; - - // /** Default date&time. */ - // const DateTime_T DEFAULT_CANCELLATION_DATETIME - // (DEFAULT_WORLD_SCHEDULE_UPDATE_DATE, - // NULL_BOOST_TIME_DURATION); - - // // //////// CityPair //////// - // /** Default booking date for BookingDay. */ - // const Date_T DEFAULT_BOOKING_DATE (2007, boost::gregorian::Jan, 1); - - // /** Default departure date for CityPairDate. */ - // const Date_T DEFAULT_DEPARTURE_DATE (2008, boost::gregorian::Jan, 1); - - // /** Date duration representing the time during which a flight-date is open - // to the reservation (in boost::date_duration unit).*/ - // const DateOffSet_T DEFAULT_FLIGHT_DATE_RESERVATION_DURATION (365); - - // /** Default number of seats required whenever a demand is processed into - // the simulator. */ - // const unsigned short DEFAULT_NUMBER_OF_REQUIRED_SEATS = 1; - - // // //////// Flight Period Actions //////// - // // //////// RMS mode /////// - // /** Default forecaster mode. */ - // const ForecasterMode_T DEFAULT_FORECAST_MODE = "NoForecast"; - - // /** First forecaster mode. */ - // const ForecasterMode_T FIRST_FORECAST_MODE = "Forecaster1"; - - // /** Basic forecaster mode. */ - // const ForecasterMode_T BASIC_FORECAST_MODE = "BasicForecaster"; - - // /** Neural forecaster mode. */ - // const ForecasterMode_T NEURAL_FORECAST_MODE = "NeuralForecaster"; - - // /** Q forecaster mode. */ - // const ForecasterMode_T Q_FORECAST_MODE = "QForecaster"; - - // /** Default optimizer mode. */ - // const OptimizerMode_T DEFAULT_OPTIMIZER_MODE = "FCFS"; - - // /** Optimizer mode for rules like LF & DTD threshold. */ - // const OptimizerMode_T LF_DTD_RULES_OPTIMIZER_MODE = "LFDTDRules"; - - // /** Optimizer mode for EMSR heuristic. */ - // const OptimizerMode_T EMSR_OPTIMIZER_MODE = "EMSR"; - - // /** Optimizer mode for EMSR-a heuristic. */ - // const OptimizerMode_T EMSRA_OPTIMIZER_MODE = "EMSRa"; - - // // /** Optimizer mode for EMSR-a with sell up probability. */ - // // const OptimizerMode_T EMSRA_SELLUP_OPTIMIZER_MODE = "EMSRaSellup"; - - // /** Optimizer mode for EMSR-b heuristic. */ - // const OptimizerMode_T EMSRB_OPTIMIZER_MODE = "EMSRb"; - - // /** Optimizer mode for Optimal Optimization by Monte-Carlo. */ - // const OptimizerMode_T MC_OPTIMIZER_MODE = "MC"; - - // /** Optimizer mode for Leg-Based Iterative DAVN Optimization with - // Monte-Carlo. */ - // const OptimizerMode_T LB_ITERATIVE_DAVN_OPTIMIZER_WITH_MC_MODE = "LB_DAVN_MC"; - - // /** Optimizer mode for Leg-Based Iterative DAVN Optimization with - // EMSR. */ - // const OptimizerMode_T LB_ITERATIVE_DAVN_OPTIMIZER_WITH_EMSR_MODE = "LB_DAVN_EMSR"; - - // // /** No sell-up for optimizer by default*/ - // // const SellupFlagForOptimizer_T DEFAULT_SELLUP_FLAG_FOR_OPTIMIZER = false; - - // /** Defaut control mode. */ - // const ControlMode_T DEFAULT_CONTROL_MODE = "STD"; - - // /** Theft control mode. */ - // const ControlMode_T THEFT_CONTROL_MODE = "THEFT"; - - // /** Default number of draws for Monte-Carlo Integration method. */ - // const int DEFAULT_NUMBER_OF_RANDOM_DRAWS = 1000; - - // /** Default epsilon for convergence test. */ - // const double DEFAULT_CONVERGENCE_EPSILON = 0.1; - - // /** Default max number of iterations for Iterative DAVN. */ - // const int DEFAULT_NB_OF_ITERATIONS_DAVN = 10; - - // // //////// Characteristics /////// - // /** Default k-factor (0.3).*/ - // const Multiplier_T DEFAULT_KFACTOR = 0.3; - - // /** Default basefare [used for computing WTP] (0).*/ - // const Fare_T DEFAULT_BASEFARE = 0; - - // /** Default elasticity multiplier [used for computing WTP] (1.5). */ - // const Multiplier_T DEFAULT_EMULTIPLIER = 1.5; - - // // //////// DICO mode /////// - // /** Default DICO studied airline. */ - // const AirlineCode_T DEFAULT_DICO_AIRLINE = "AD"; - // //const AirlineCode_T DEFAULT_DICO_STUDIED_AIRLINE = "AA"; - - // /** Default second studied airline for DICO. */ - // const AirlineCode_T DEFAULT_SECOND_DICO_AIRLINE = "AL"; - // //const AirlineCode_T DEFAULT_SECOND_DICO_STUDIED_AIRLINE = "BA"; - - // /** Default DICO studied date. */ - // const Date_T DEFAULT_DICO_STUDIED_DATE (2009, boost::gregorian::Jun, 29); - // //const Date_T DEFAULT_DICO_STUDIED_DATE (2009, boost::gregorian::Jun, 27); - - // /** Default DICO optimiser (dico mode). */ - // const DicoOptimizerMode_T DEFAULT_DICO_OPTIMIZER = "dico"; - - // /** Default DICO optimiser (robust dico mode). */ - // const DicoOptimizerMode_T DEFAULT_ROBUST_DICO_OPTIMIZER = - // "robustdico"; - - // /** Default DICO optimiser (fast robust dico mode). */ - // const DicoOptimizerMode_T DEFAULT_FAST_ROBUST_DICO_OPTIMIZER = - // "fastrobustdico"; - // //////// Inventory-related BOM /////// /** Default Bid-Price. */ const BidPrice_T DEFAULT_BID_PRICE = 0.0; Copied: trunk/stdair/stdair/basic/BasConst_Request.hpp (from rev 143, trunk/stdair/stdair/basic/BasConst_General.hpp) =================================================================== --- trunk/stdair/stdair/basic/BasConst_Request.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasConst_Request.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -0,0 +1,16 @@ +#ifndef __STDAIR_BAS_BASCONST_REQUEST_HPP +#define __STDAIR_BAS_BASCONST_REQUEST_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Default party size in a request. */ + extern const PartySize_T DEFAULT_PARTY_SIZE; + +} +#endif // __STDAIR_BAS_BASCONST_REQUEST_HPP Modified: trunk/stdair/stdair/basic/CategoricalAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -18,69 +18,101 @@ struct CategoricalAttribute { public: + /** Define the probability mass function type. */ + typedef std::map<T, Probability_T> ProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution type. */ + typedef std::map<Probability_T, T> InverseCumulativeDistribution_T; + + public: // ///////////// Getters /////////// /** Get the probability mass function. */ const std::map<T,Probability_T>& getProbabilityMassFunction() const { - return _probability_mass_function; + return _probabilityMassFunction; } /** Get the inverse cumulative distribution. */ - const std::map<Probability_T, T>& getInverseCumulativeDistribution () const { - return _inverse_cumulative_distribution; + const InverseCumulativeDistribution_T& getInverseCumulativeDistribution () const { + return _inverseCumulativeDistribution; } // ///////////// Setters /////////// /** Set the probability mass function */ - void setProbabilityMassFunction (const std::map<T, Probability_T>& iProbabilityMassFunction) { - _probability_mass_function = iProbabilityMassFunction; + void setProbabilityMassFunction (const ProbabilityMassFunction_T& iProbabilityMassFunction) { + _probabilityMassFunction = iProbabilityMassFunction; determineInverseCumulativeDistributionFromProbabilityMassFunction(); } public: // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ - T getValue(Probability_T iCumulativeProbability) { - return _inverse_cumulative_distribution.lower_bound(iCumulativeProbability)->second; + const T getValue (Probability_T iCumulativeProbability) const { + return _inverseCumulativeDistribution. + lower_bound (iCumulativeProbability)->second; } public: // ////////////// Display Support Methods ////////// - /** Display inverse cumulative distribution */ - void displayInverseCumulativeDistribution (std::ostream& ioStream) const { - for (typename std::map<Probability_T, T>::const_iterator it = _inverse_cumulative_distribution.begin(); - it != _inverse_cumulative_distribution.end(); ++it) { - ioStream << "cumulative prob: " << it->first + /** Display probability mass function. */ + const std::string displayProbabilityMassFunction () const { + std::ostringstream oStr; + unsigned int idx = 0; + + for (typename ProbabilityMassFunction_T::const_iterator it = + _probabilityMassFunction.begin(); + it != _probabilityMassFunction.end(); ++it, ++idx) { + if (idx != 0) { + oStr << ", "; + } + oStr << it->first << ":" << it->second; + } + + return oStr.str(); + } + + /** Display inverse cumulative distribution. */ + const std::string displayInverseCumulativeDistribution () const { + std::ostringstream oStr; + + for (typename InverseCumulativeDistribution_T::const_iterator it = + _inverseCumulativeDistribution.begin(); + it != _inverseCumulativeDistribution.end(); ++it) { + oStr << "cumulative prob: " << it->first << " value: " << it->second << std::endl; } + + return oStr.str(); } public: // ////////// Constructors and destructors ///////// /** Constructor by default */ - CategoricalAttribute (const std::map<T, Probability_T>& iProbabilityMassFunction) - : _probability_mass_function (iProbabilityMassFunction) { + CategoricalAttribute (const ProbabilityMassFunction_T& iProbabilityMassFunction) + : _probabilityMassFunction (iProbabilityMassFunction) { determineInverseCumulativeDistributionFromProbabilityMassFunction(); } + /** Default constructors. */ + CategoricalAttribute () { } + CategoricalAttribute (const CategoricalAttribute& iCategoricalAttribute) + : _probabilityMassFunction (iCategoricalAttribute._probabilityMassFunction) { + determineInverseCumulativeDistributionFromProbabilityMassFunction(); + } /** Destructor */ virtual ~CategoricalAttribute () { } - private: - /** Default constructors. */ - CategoricalAttribute (); - CategoricalAttribute (const CategoricalAttribute&); /** Determine inverse cumulative distribution from probability mass function (initialisation). */ void determineInverseCumulativeDistributionFromProbabilityMassFunction () { Probability_T cumulative_probability_so_far = 0.0; - for (typename std::map<T, Probability_T>::const_iterator itProbabilityMassFunction = _probability_mass_function.begin(); - itProbabilityMassFunction != _probability_mass_function.end(); + for (typename ProbabilityMassFunction_T::const_iterator itProbabilityMassFunction = _probabilityMassFunction.begin(); + itProbabilityMassFunction != _probabilityMassFunction.end(); ++itProbabilityMassFunction) { Probability_T attribute_probability_mass = itProbabilityMassFunction->second; if (attribute_probability_mass > 0) { T attribute_value = itProbabilityMassFunction->first; cumulative_probability_so_far += attribute_probability_mass; - _inverse_cumulative_distribution[cumulative_probability_so_far] = attribute_value; + _inverseCumulativeDistribution[cumulative_probability_so_far] = attribute_value; } } } @@ -88,10 +120,10 @@ private: // ////////// Attributes ////////// /** Probability mass function */ - std::map<T, Probability_T> _probability_mass_function; + ProbabilityMassFunction_T _probabilityMassFunction; /** Inverse cumulative distribution */ - std::map<Probability_T, T> _inverse_cumulative_distribution; + InverseCumulativeDistribution_T _inverseCumulativeDistribution; }; } Modified: trunk/stdair/stdair/basic/ContinuousAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -48,7 +48,7 @@ // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ const T getValue (const Probability_T& iCumulativeProbability) const { - typename ContinuousDistribution_T::const_iterator it = + typename ContinuousInverseDistribution_T::const_iterator it = _inverseCumulativeDistribution.lower_bound (iCumulativeProbability); Probability_T cumulativeProbabilityNextPoint = it->first; @@ -63,15 +63,9 @@ Probability_T cumulativeProbabilityPreviousPoint = it->first; T valuePreviousPoint = it->second; if (cumulativeProbabilityNextPoint == cumulativeProbabilityPreviousPoint) { - //std::cout << "hlelo2" << std::endl; return valuePreviousPoint; } - //std::cout << "cumulativeProbabilityPreviousPoint: " << cumulativeProbabilityPreviousPoint << std::endl; - //std::cout << "cumulativeProbabilityNextPoint: " << cumulativeProbabilityNextPoint << std::endl; - //std::cout << "valuePreviousPoint: " << valuePreviousPoint << std::endl; - //std::cout << "valueNextPoint: " << valueNextPoint << std::endl; - return valuePreviousPoint + (valueNextPoint - valuePreviousPoint) * (iCumulativeProbability - cumulativeProbabilityPreviousPoint) / (cumulativeProbabilityNextPoint - cumulativeProbabilityPreviousPoint); @@ -80,7 +74,7 @@ public: // ////////////// Display Support Methods ////////// /** Display cumulative distribution */ - std::string displayCumulativeDistribution() const { + const std::string displayCumulativeDistribution() const { std::ostringstream oStr; unsigned int idx = 0; for (typename ContinuousDistribution_T::const_iterator it = @@ -95,7 +89,7 @@ } /** Display inverse cumulative distribution */ - std::string displayInverseCumulativeDistribution() const { + const std::string displayInverseCumulativeDistribution() const { std::ostringstream oStr; for (typename ContinuousInverseDistribution_T::const_iterator it = _inverseCumulativeDistribution.begin(); @@ -134,8 +128,9 @@ itCumulativeDistribution != _cumulativeDistribution.end(); ++itCumulativeDistribution) { _inverseCumulativeDistribution. - insert (std::pair<float, float> (itCumulativeDistribution->second, - itCumulativeDistribution->first)); + insert (typename ContinuousInverseDistribution_T:: + value_type (itCumulativeDistribution->second, + itCumulativeDistribution->first)); } } Copied: trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp (from rev 143, trunk/stdair/stdair/basic/ArrivalPattern.hpp) =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp (rev 0) +++ trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -0,0 +1,82 @@ +#ifndef __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP +#define __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> +#include <stdair/basic/CategoricalAttribute.hpp> + +namespace stdair { + + /** Type definition for the continuous distribition of the duration + (as a float number). */ + typedef ContinuousAttribute<FloatDuration_T> ContinuousFloatDuration_T; + + /** Type definition for the arrival pattern. */ + typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPattern_T; + + /** Type definition for the arrival pattern cumulative distribution. */ + typedef std::multimap<FloatDuration_T, Probability_T> ArrivalPatternCumulativeDistribution_T; + + /** Type definition for the arrival pattern inverse cumulative distribution. */ + typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; + + /** Define the booking channel probablity mass. */ + typedef CategoricalAttribute<ChannelLabel_T> ChannelProbabilityMass_T; + + /** Define the probability mass function type of booking channel. */ + typedef ChannelProbabilityMass_T::ProbabilityMassFunction_T ChannelProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of channel. */ + typedef ChannelProbabilityMass_T::InverseCumulativeDistribution_T ChannelInverserCumulativeDistribution_T; + + /** Define the trip type probablity mass. */ + typedef CategoricalAttribute<TripType_T> TripTypeProbabilityMass_T; + + /** Define the probability mass function type of trip type. */ + typedef TripTypeProbabilityMass_T::ProbabilityMassFunction_T TripTypeProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of trip type. */ + typedef TripTypeProbabilityMass_T::InverseCumulativeDistribution_T TripTypeInverserCumulativeDistribution_T; + + /** Define the stay duration probablity mass. */ + typedef CategoricalAttribute<DayDuration_T> StayDurationProbabilityMass_T; + + /** Define the probability mass function type of stay duration. */ + typedef StayDurationProbabilityMass_T::ProbabilityMassFunction_T StayDurationProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of stay duration. */ + typedef StayDurationProbabilityMass_T::InverseCumulativeDistribution_T StayDurationInverserCumulativeDistribution_T; + + /** Define the frequent flyer probablity mass. */ + typedef CategoricalAttribute<FrequentFlyer_T> FrequentFlyerProbabilityMass_T; + + /** Define the probability mass function type of frequent flyer. */ + typedef FrequentFlyerProbabilityMass_T::ProbabilityMassFunction_T FrequentFlyerProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of frequent flyer. */ + typedef FrequentFlyerProbabilityMass_T::InverseCumulativeDistribution_T FrequentFlyerInverserCumulativeDistribution_T; + + /** Define the preferred departure time cumulative distribution. */ + typedef ContinuousAttribute<IntDuration_T> PreferredDepartureTimeCumulativeDistribution_T; + + /** Define the preferred departure time continuous distribution. */ + typedef PreferredDepartureTimeCumulativeDistribution_T::ContinuousDistribution_T PreferredDepartureTimeContinuousDistribution_T; + + /** Define the preferred departure time continuous inverse distribution. */ + typedef PreferredDepartureTimeCumulativeDistribution_T::ContinuousInverseDistribution_T PreferredDepartureTimeContinuousInverseDistribution_T; + + /** Define the willingness-to-pay cumulative distribution. */ + typedef ContinuousAttribute<WTP_T> WTPCumulativeDistribution_T; + + /** Define the willingness-to-pay continuous distribution. */ + typedef WTPCumulativeDistribution_T::ContinuousDistribution_T WTPContinuousDistribution_T; + + /** Define the willingness-to-pay continuous inverse distribution. */ + typedef WTPCumulativeDistribution_T::ContinuousInverseDistribution_T WTPContinuousInverseDistribution_T; + +} +#endif // __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-16 16:49:09 UTC (rev 144) @@ -12,8 +12,22 @@ namespace stdair { // ///////////////////////////////////////////////////// - DemandCharacteristics::DemandCharacteristics (const DemandStreamKey_T& iKey) - : _key (iKey) { + DemandCharacteristics:: + DemandCharacteristics (const DemandStreamKey_T& iKey, + const ContinuousFloatDuration_T& iArrivalPattern, + const ChannelProbabilityMass_T& iChannelProbMass, + const TripTypeProbabilityMass_T& iTripTypeProbMass, + const StayDurationProbabilityMass_T& iStayDurationProbMass, + const FrequentFlyerProbabilityMass_T& iFrequentFlyerProbMass, + const PreferredDepartureTimeCumulativeDistribution_T& iPreferredDepartureTimeCumulativeDistribution, + const WTPCumulativeDistribution_T& iWTPCumulativeDistribution) + : _key (iKey), _arrivalPattern (iArrivalPattern), + _channelProbabilityMass (iChannelProbMass), + _tripTypeProbabilityMass (iTripTypeProbMass), + _stayDurationProbabilityMass (iStayDurationProbMass), + _frequentFlyerProbabilityMass (iFrequentFlyerProbMass), + _preferredDepartureTimeCumulativeDistribution (iPreferredDepartureTimeCumulativeDistribution), + _wtpCumulativeDistribution (iWTPCumulativeDistribution) { } // ///////////////////////////////////////////////////// @@ -29,7 +43,13 @@ DemandCharacteristics:: DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) : _key (iDemandCharacteristics._key), - _arrivalPattern (iDemandCharacteristics._arrivalPattern) { + _arrivalPattern (iDemandCharacteristics._arrivalPattern), + _channelProbabilityMass (iDemandCharacteristics._channelProbabilityMass), + _tripTypeProbabilityMass (iDemandCharacteristics._tripTypeProbabilityMass), + _stayDurationProbabilityMass (iDemandCharacteristics._stayDurationProbabilityMass), + _frequentFlyerProbabilityMass (iDemandCharacteristics._frequentFlyerProbabilityMass), + _preferredDepartureTimeCumulativeDistribution (iDemandCharacteristics._preferredDepartureTimeCumulativeDistribution), + _wtpCumulativeDistribution (iDemandCharacteristics._wtpCumulativeDistribution) { } // ///////////////////////////////////////////////////// @@ -68,9 +88,25 @@ oStr << "Preferred cabin .................. : " << _key.getPreferredCabin() << std::endl; oStr << "Arrival pattern (days from departure, proportion): "; + oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; + oStr << "Channel probability mass (channel, propotion): "; + oStr << _channelProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Trip type probability mass (trip type, propotion): "; + oStr << _tripTypeProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Stay duration probability mass (number of days, propotion): "; + oStr << _stayDurationProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Frequent flyer probability mass (frequent flyer, propotion): "; + oStr << _frequentFlyerProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Preferred departure time cumulative distribution (time, proportion: "; + oStr << _preferredDepartureTimeCumulativeDistribution.displayCumulativeDistribution() << std::endl; + oStr << "WTP cumulative distribution (WTP, proportion: "; + oStr << _wtpCumulativeDistribution.displayCumulativeDistribution() + << std::endl; - // - oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; return oStr.str(); } Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -8,7 +8,7 @@ #include <string> // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/ArrivalPattern.hpp> +#include <stdair/basic/DemandCharacteristicTypes.hpp> #include <stdair/bom/DemandStreamKey.hpp> namespace stdair { @@ -40,14 +40,35 @@ return _arrivalPattern; } + /** Get the channel probability mass. */ + const ChannelProbabilityMass_T& getChannelProbabilityMass() const { + return _channelProbabilityMass; + } + + /** Get the trip type probability mass. */ + const TripTypeProbabilityMass_T& getTripTypeProbabilityMass() const { + return _tripTypeProbabilityMass; + } - public: - // ///////////// Setters /////////// - /** Set the arrival pattern. */ - void setArrivalPattern (const ContinuousFloatDuration_T& iArrivalPattern) { - _arrivalPattern = iArrivalPattern; + /** Get the stay duration probability mass. */ + const StayDurationProbabilityMass_T& getStayDurationProbabilityMass() const { + return _stayDurationProbabilityMass; } + /** Get the frequent flyer probability mass. */ + const FrequentFlyerProbabilityMass_T& getFrequentFlyerProbabilityMass() const { + return _frequentFlyerProbabilityMass; + } + + /** Get the preferred departure time cumulative distribution. */ + const PreferredDepartureTimeCumulativeDistribution_T& getPreferredDepartureTimeCumulativeDistribution () const { + return _preferredDepartureTimeCumulativeDistribution; + } + + /** Get the WTP cumulative distribution. */ + const WTPCumulativeDistribution_T& getWTPCumulativeDistribution() const { + return _wtpCumulativeDistribution; + } public: // ////////////// Display Support Methods ////////// @@ -58,7 +79,14 @@ public: // ////////// Constructors and destructors ///////// /** Default constructor. */ - DemandCharacteristics (const DemandStreamKey_T& iKey); + DemandCharacteristics (const DemandStreamKey_T&, + const ContinuousFloatDuration_T&, + const ChannelProbabilityMass_T&, + const TripTypeProbabilityMass_T&, + const StayDurationProbabilityMass_T&, + const FrequentFlyerProbabilityMass_T&, + const PreferredDepartureTimeCumulativeDistribution_T&, + const WTPCumulativeDistribution_T&); /** Default constructor. */ // TODO: That copy constructor should be private @@ -80,13 +108,25 @@ /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date and request date). */ - ContinuousFloatDuration_T _arrivalPattern; + const ContinuousFloatDuration_T _arrivalPattern; + + /** Channel probability mass. */ + const ChannelProbabilityMass_T _channelProbabilityMass; /** Trip type probability mass */ - // CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; + const TripTypeProbabilityMass_T _tripTypeProbabilityMass; + /** Stay duration probability mass */ + const StayDurationProbabilityMass_T _stayDurationProbabilityMass; + + /** Frequent flyer probability mass */ + const FrequentFlyerProbabilityMass_T _frequentFlyerProbabilityMass; + + /** Preferred departure time cumulative distribution. */ + const PreferredDepartureTimeCumulativeDistribution_T _preferredDepartureTimeCumulativeDistribution; + /** Willingness-to-pay cumulative distribution */ - // ContinuousAttribute<MonetaryValue_T> _willingnessToPayCumulativeDistribution; + const WTPCumulativeDistribution_T _wtpCumulativeDistribution; }; Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/sources.mk 2010-02-16 16:49:09 UTC (rev 144) @@ -1,6 +1,7 @@ bas_h_sources = \ $(top_srcdir)/stdair/basic/BasTypes.hpp \ $(top_srcdir)/stdair/basic/BasConst_General.hpp \ + $(top_srcdir)/stdair/basic/BasConst_Request.hpp \ $(top_srcdir)/stdair/basic/BasConst_Inventory.hpp \ $(top_srcdir)/stdair/basic/BasConst_BookingClass.hpp \ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ @@ -14,8 +15,8 @@ $(top_srcdir)/stdair/basic/BasDBParams.hpp \ $(top_srcdir)/stdair/basic/PassengerType.hpp \ $(top_srcdir)/stdair/basic/ContinuousAttribute.hpp \ - $(top_srcdir)/stdair/basic/ArrivalPattern.hpp \ $(top_srcdir)/stdair/basic/CategoricalAttribute.hpp \ + $(top_srcdir)/stdair/basic/DemandCharacteristicTypes.hpp \ $(top_srcdir)/stdair/basic/DemandCharacteristics.hpp \ $(top_srcdir)/stdair/basic/DemandDistribution.hpp \ $(top_srcdir)/stdair/basic/RandomGeneration.hpp \ Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-16 16:49:09 UTC (rev 144) @@ -12,16 +12,26 @@ namespace stdair { // ////////////////////////////////////////////////////////////////////// - BookingRequestStruct::BookingRequestStruct (const AirportCode_T& iOrigin, - const AirportCode_T& iDestination, - const Date_T& iDepartureDate, - const DateTime_T& iRequestDateTime, - const CabinCode_T& iPreferredCabin, - const NbOfSeats_T& iPartySize) + BookingRequestStruct:: + BookingRequestStruct (const AirportCode_T& iOrigin, + const AirportCode_T& iDestination, + const Date_T& iDepartureDate, + const DateTime_T& iRequestDateTime, + const CabinCode_T& iPreferredCabin, + const NbOfSeats_T& iPartySize, + const ChannelLabel_T& iChannel, + const TripType_T& iTripType, + const DayDuration_T& iStayDuration, + const FrequentFlyer_T& iFrequentFlyerType, + const Duration_T& iPreferredDepartureTime, + const WTP_T& iWTP) : _origin (iOrigin), _destination (iDestination), _preferredDepartureDate (iDepartureDate), _requestDateTime (iRequestDateTime), - _preferredCabin (iPreferredCabin), _partySize (iPartySize) { + _preferredCabin (iPreferredCabin), _partySize (iPartySize), + _channel (iChannel), _tripType (iTripType), + _stayDuration (iStayDuration), _frequentFlyerType (iFrequentFlyerType), + _preferredDepartureTime (iPreferredDepartureTime), _wtp (iWTP) { } // ////////////////////////////////////////////////////////////////////// @@ -42,7 +52,9 @@ std::ostringstream oStr; oStr << _origin << " - " << _destination << " " << _preferredDepartureDate << " " << _requestDateTime << " " << _preferredCabin - << " " << _partySize; + << " " << _partySize << " " << _channel << " " << _tripType + << " " << _stayDuration << " " << _frequentFlyerType + << " " << _preferredDepartureTime << " " << _wtp; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -46,40 +46,37 @@ const NbOfSeats_T& getPartySize() const { return _partySize; } - - // /////////////// Setters ///////////////// - /** Set the requested origin. */ - void setOrigin (const AirportCode_T& iOrigin) { - _origin = iOrigin; + /** Get the reservation channel. */ + const ChannelLabel_T& getBookingChannel() const { + return _channel; } - /** Set the requested destination. */ - void setDestination (const AirportCode_T& iDestination) { - _destination = iDestination; + /** Get the trip type. */ + const TripType_T& getTripType() const { + return _tripType; } - /** Set the requested departure date. */ - void setPreferredDepartureDate (const Date_T& iDepartureDate) { - _preferredDepartureDate = iDepartureDate; + /** Get the duration of stay. */ + const DayDuration_T& getStayDuration() const { + return _stayDuration; } - - /** Set the request datetime */ - void setRequestDateTime (const DateTime_T& iRequestDateTime) { - _requestDateTime = iRequestDateTime; + + /** Get the frequent flyer type. */ + const FrequentFlyer_T& getFrequentFlyerType() const { + return _frequentFlyerType; } - - /** Set the preferred cabin. */ - void setPreferredCabin (const CabinCode_T& iPreferredCabin) { - _preferredCabin = iPreferredCabin; + + /** Get the preferred departure time. */ + const Duration_T& getPreferredDepartureTime() const { + return _preferredDepartureTime; } - /** Set the party size. */ - void setPartySize (const NbOfSeats_T& iPartySize) { - _partySize = iPartySize; + /** Get the willingness-to-pay. */ + const WTP_T& getWTP() const { + return _wtp; } - - + // /////////// Display support method ///////////// /** Dump a Business Object into an output stream. @param ostream& the output stream. */ @@ -98,7 +95,10 @@ /** Constructor. */ BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, - const CabinCode_T&, const NbOfSeats_T&); + const CabinCode_T&, const NbOfSeats_T&, + const ChannelLabel_T&, const TripType_T&, + const DayDuration_T&, const FrequentFlyer_T&, + const Duration_T&, const WTP_T&); public : /** Default constructor. */ BookingRequestStruct (); @@ -112,22 +112,41 @@ private: // /////////////// Attributes ///////////////// /** Origin. */ - AirportCode_T _origin; + const AirportCode_T _origin; /** Destination. */ - AirportCode_T _destination; + const AirportCode_T _destination; /** Departure date. */ - Date_T _preferredDepartureDate; + const Date_T _preferredDepartureDate; /** Request date-time */ - DateTime_T _requestDateTime; + const DateTime_T _requestDateTime; /** Preferred cabin. */ - CabinCode_T _preferredCabin; + const CabinCode_T _preferredCabin; /** Party size. */ - NbOfSeats_T _partySize; + const NbOfSeats_T _partySize; + + /** Booking channel (D=direct, I=indirect, N=oNline, F=oFfline). */ + const ChannelLabel_T _channel; + + /** Trip type (RO=outbound of round-trip, RI=inbound of round-trip, + OW=one way). */ + const TripType_T _tripType; + + /** Stay duration (number of days). */ + const DayDuration_T _stayDuration; + + /** Frequent flyer type (P=Platinum, G=Gold, S=Silver, M=Member, N=None). */ + const FrequentFlyer_T _frequentFlyerType; + + /** Preferred departure time. */ + const Duration_T _preferredDepartureTime; + + /** Willingness-To-Pay. */ + const WTP_T _wtp; }; } Modified: trunk/stdair/stdair/bom/DemandStreamContent.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -64,6 +64,36 @@ return _demandCharacteristics.getArrivalPattern(); } + /** Get the channel probability mass. */ + const ChannelProbabilityMass_T& getChannelProbabilityMass() const { + return _demandCharacteristics.getChannelProbabilityMass(); + } + + /** Get the trip type probability mass. */ + const TripTypeProbabilityMass_T& getTripTypeProbabilityMass() const { + return _demandCharacteristics.getTripTypeProbabilityMass(); + } + + /** Get the stay duration probability mass. */ + const StayDurationProbabilityMass_T& getStayDurationProbabilityMass() const { + return _demandCharacteristics.getStayDurationProbabilityMass(); + } + + /** Get the frequent flyer probability mass. */ + const FrequentFlyerProbabilityMass_T& getFrequentFlyerProbabilityMass() const { + return _demandCharacteristics.getFrequentFlyerProbabilityMass(); + } + + /** Get the preferred departure time cumulative distribution. */ + const PreferredDepartureTimeCumulativeDistribution_T& getPreferredDepartureTimeCumulativeDistribution () const { + return _demandCharacteristics.getPreferredDepartureTimeCumulativeDistribution(); + } + + /** Get the WTP cumulative distribution. */ + const WTPCumulativeDistribution_T& getWTPCumulativeDistribution() const { + return _demandCharacteristics.getWTPCumulativeDistribution(); + } + /** Get the mean number of requests. */ const NbOfRequests_T& getMeanNumberOfRequests() const { return _demandDistribution.getMeanNumberOfRequests(); @@ -100,6 +130,16 @@ return _demandCharacteristicsRandomGenerator.getSeed(); } + /** Get the demand characteristics. */ + const DemandCharacteristics& getDemandCharacteristics () const { + return _demandCharacteristics; + } + + /** Get the demand distribution. */ + const DemandDistribution& getDemandDistribution () const { + return _demandDistribution; + } + public: // //////////////// Setters ////////////////// /** Set the cumulative probability of arrival pattern for last This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 19:48:46
|
Revision: 143 http://stdair.svn.sourceforge.net/stdair/?rev=143&view=rev Author: denis_arnaud Date: 2010-02-15 19:48:39 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Dev] Improved the pretty print within the BomManager class. There is still some work to perform on the segment-related branch of the BOM tree. Modified Paths: -------------- trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_General.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BomManager.cpp trunk/stdair/stdair/bom/BomManager.hpp Added Paths: ----------- trunk/stdair/stdair/basic/BasConst_BomManager.hpp Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-02-15 16:25:42 UTC (rev 142) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-02-15 19:48:39 UTC (rev 143) @@ -488,4 +488,51 @@ (Origin & Destination). */ const unsigned short MAXIMUM_NUMBER_OF_SEGMENTS_IN_OND = 3; + + // ////////// BomManager-related constants /////////// + /** Array with the indentation spaces needed for all the BOM + hierachical levels. */ + const std::string DISPLAY_LEVEL_STRING_ARRAY[51] = + { "", " ", " ", " ", + " ", " ", " ", " ", + " ", " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }; + + } Copied: trunk/stdair/stdair/basic/BasConst_BomManager.hpp (from rev 142, trunk/stdair/stdair/basic/BasConst_General.hpp) =================================================================== --- trunk/stdair/stdair/basic/BasConst_BomManager.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasConst_BomManager.hpp 2010-02-15 19:48:39 UTC (rev 143) @@ -0,0 +1,16 @@ +#ifndef __STDAIR_BAS_BASCONST_BOMMANAGER_HPP +#define __STDAIR_BAS_BASCONST_BOMMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> + +namespace stdair { + + /** Array with the indentation spaces needed for all the BOM + hierachical levels. */ + extern const std::string DISPLAY_LEVEL_STRING_ARRAY[51]; +} +#endif // __STDAIR_BAS_BASCONST_BOMMANAGER_HPP Modified: trunk/stdair/stdair/basic/BasConst_General.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-15 16:25:42 UTC (rev 142) +++ trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-15 19:48:39 UTC (rev 143) @@ -4,7 +4,7 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// LATUS Common +// StdAir #include <stdair/STDAIR_Types.hpp> namespace stdair { Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-15 16:25:42 UTC (rev 142) +++ trunk/stdair/stdair/basic/sources.mk 2010-02-15 19:48:39 UTC (rev 143) @@ -6,6 +6,7 @@ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ + $(top_srcdir)/stdair/basic/BasConst_BomManager.hpp \ $(top_srcdir)/stdair/basic/StructAbstract.hpp \ $(top_srcdir)/stdair/basic/BasChronometer.hpp \ $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ Modified: trunk/stdair/stdair/bom/BomManager.cpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.cpp 2010-02-15 16:25:42 UTC (rev 142) +++ trunk/stdair/stdair/bom/BomManager.cpp 2010-02-15 19:48:39 UTC (rev 143) @@ -4,7 +4,8 @@ // STL #include <cassert> #include <ostream> -// STDAIR +// StdAir +#include <stdair/basic/BasConst_BomManager.hpp> #include <stdair/bom/BomRoot.hpp> #include <stdair/bom/AirlineFeatureSet.hpp> #include <stdair/bom/AirlineFeature.hpp> @@ -21,6 +22,7 @@ #include <stdair/bom/NetworkDate.hpp> #include <stdair/bom/AirportDate.hpp> #include <stdair/bom/OutboundPath.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> #include <stdair/bom/BomManager.hpp> namespace stdair { @@ -70,7 +72,7 @@ const FlightDate& lCurrentFD = *itFD; // Call recursively the display() method on the children objects - display (oStream, lCurrentFD); + csvFlightDateDisplay (oStream, lCurrentFD); } // Reset formatting flags of the given output stream @@ -78,24 +80,46 @@ } // ////////////////////////////////////////////////////////////////////// - void BomManager::display (std::ostream& oStream, - const FlightDate& iFlightDate) { + void BomManager::csvFlightDateDisplay (std::ostream& oStream, + const FlightDate& iFlightDate) { // Store current formatting flags of the given output stream std::ios::fmtflags oldFlags = oStream.flags(); - // Flight-date level - oStream << iFlightDate.describeKey() << std::endl; + // Display FlightDate-level information + oStream << "******************************************" << std::endl; + oStream << "FlightDate: " << iFlightDate.describeKey() << std::endl + << "-----------" << std::endl; + oStream << "FlightNb (FlightDate), " + << "SS, Rev, Fare, ASK, Yield, RPK, URev, LF, " + << std::endl << std::endl; + + oStream << iFlightDate.getFlightNumber() + << " (" << iFlightDate.getFlightDate() << "), " + << iFlightDate.getBookingCounter() << ", " + << iFlightDate.getRevenue() << ", " + << iFlightDate.getAverageFare() << ", " + << iFlightDate.getASK() << ", " + << iFlightDate.getYield() << ", " + << iFlightDate.getRPK() << ", " + << iFlightDate.getUnitRevenue() << ", " + << iFlightDate.getLoadFactor() << ", " << std::endl; + oStream << "******************************************" << std::endl; - // Browse the LegDate objects - const LegDateList_T& lLDList = iFlightDate.getLegDateList(); - for (LegDateList_T::iterator itLD = lLDList.begin(); - itLD != lLDList.end(); ++itLD) { - const LegDate& lCurrentLD = *itLD; - - // Call recursively the display() method on the children objects - display (oStream, lCurrentLD); - } + // Display the leg-dates + csvLegDateDisplay (oStream, iFlightDate); + // Display the leg-cabins + csvLegCabinDisplay (oStream, iFlightDate); + + // Display the buckets + csvBPVDisplay (oStream, iFlightDate); + + // Display the segment-cabins + // csvSegmentCabinDisplay (oStream, iFlightDate); + + // Display the booking classes + // csvClassDisplay (oStream, iFlightDate); + // Browse the SegmentDate objects const SegmentDateList_T& lSDList = iFlightDate.getSegmentDateList(); for (SegmentDateList_T::iterator itSD = lSDList.begin(); @@ -111,42 +135,137 @@ } // ////////////////////////////////////////////////////////////////////// - void BomManager::display (std::ostream& oStream, - const LegDate& iLegDate) { + void BomManager::csvLegDateDisplay (std::ostream& oStream, + const FlightDate& iFlightDate) { // Store current formatting flags of the given output stream std::ios::fmtflags oldFlags = oStream.flags(); - // Leg-date level - oStream << iLegDate.describeKey() << std::endl; + // Display the header + oStream << "******************************************" << std::endl; + oStream << "Leg-Dates:" << std::endl + << "----------" << std::endl; + oStream << "FlightNb (FlightDate), Leg, " + << "Dates, Times, Dist, Cap, ASK, SS, LF, " + << std::endl << std::endl; - // Browse the LegCabin objects - const LegCabinList_T& lLCList = iLegDate.getLegCabinList(); - for (LegCabinList_T::iterator itLC = lLCList.begin(); - itLC != lLCList.end(); ++itLC) { - const LegCabin& lCurrentLC = *itLC; - - // Call recursively the display() method on the children objects - display (oStream, lCurrentLC); + // Browse the LegDate objects + const LegDateList_T& lLDList = iFlightDate.getLegDateList(); + for (LegDateList_T::iterator itLD = lLDList.begin(); + itLD != lLDList.end(); ++itLD) { + const LegDate& lCurrentLD = *itLD; + + oStream << iFlightDate.getFlightNumber() + << " (" << iFlightDate.getFlightDate() << "), " + << lCurrentLD.getBoardingPoint() << "-" + << lCurrentLD.getOffPoint() << ", " + << lCurrentLD.getBoardingDate() << " -> " + << lCurrentLD.getOffDate() << " / " + << lCurrentLD.getDateOffSet() << ", " + << lCurrentLD.getBoardingTime() << " -> " + << lCurrentLD.getOffTime() << " (" + << lCurrentLD.getTimeOffSet() << ") / " + << lCurrentLD.getElapsedTime() << ", " + << lCurrentLD.getDistance() << ", " + << lCurrentLD.getCapacity() << ", " + << lCurrentLD.getASK() << ", " + << lCurrentLD.getSoldSeat() << ", " + << lCurrentLD.getLoadFactor() << ", " + << std::endl; } + oStream << "******************************************" << std::endl; // Reset formatting flags of the given output stream oStream.flags (oldFlags); } // ////////////////////////////////////////////////////////////////////// - void BomManager::display (std::ostream& oStream, - const LegCabin& iLegCabin) { + void BomManager::csvLegCabinDisplay (std::ostream& oStream, + const FlightDate& iFlightDate) { // Store current formatting flags of the given output stream std::ios::fmtflags oldFlags = oStream.flags(); - // Leg-cabin level - oStream << iLegCabin.describeKey() << std::endl; - + // Display the header + oStream << "******************************************" << std::endl; + oStream << "LegCabins:" << std::endl + << "----------" << std::endl; + oStream << "FlightNb (FlightDate), Leg, Cabin, " + << "Cap, SS, CS, AvlPool, Avl, BP, " + << std::endl; + + // Browse the LegDate objects + const LegDateList_T& lLDList = iFlightDate.getLegDateList(); + for (LegDateList_T::iterator itLD = lLDList.begin(); + itLD != lLDList.end(); ++itLD) { + const LegDate& lCurrentLD = *itLD; + + // Browse the LegCabin objects + const LegCabinList_T& lLCList = lCurrentLD.getLegCabinList(); + for (LegCabinList_T::iterator itLC = lLCList.begin(); + itLC != lLCList.end(); ++itLC) { + const LegCabin& lCurrentLC = *itLC; + + oStream << iFlightDate.getFlightNumber() + << " (" << iFlightDate.getFlightDate() << "), " + << lCurrentLD.getBoardingPoint() << "-" + << lCurrentLD.getOffPoint() << ", " + << lCurrentLC.getCabinCode() << ", " + << lCurrentLC.getCapacity() << ", " + << lCurrentLC.getSoldSeat() << ", " + << lCurrentLC.getCommitedSpace() << ", " + << lCurrentLC.getAvailabilityPool() << ", " + << lCurrentLC.getAvailability() << ", " + << lCurrentLC.getCurrentBidPrice() << ", " << std::endl; + } + } + oStream << "******************************************" << std::endl; + // Reset formatting flags of the given output stream oStream.flags (oldFlags); } // ////////////////////////////////////////////////////////////////////// + void BomManager::csvBPVDisplay (std::ostream& oStream, + const FlightDate& iFlightDate) { + // Store current formatting flags of the given output stream + std::ios::fmtflags oldFlags = oStream.flags(); + + // Display the header + oStream << "******************************************" << std::endl; + oStream << "Bid-Price Vector:" << std::endl; + oStream << "Leg, Cabin, Yield, AV0, DSE, AV1, AV2, AV3, AV, SI" << std::endl; + + // Browse the LegDate objects + const LegDateList_T& lLDList = iFlightDate.getLegDateList(); + for (LegDateList_T::iterator itLD = lLDList.begin(); + itLD != lLDList.end(); ++itLD) { + const LegDate& lCurrentLD = *itLD; + + // Browse the LegCabin objects + const LegCabinList_T& lLCList = lCurrentLD.getLegCabinList(); + for (LegCabinList_T::iterator itLC = lLCList.begin(); + itLC != lLCList.end(); ++itLC) { + LegCabin& lCurrentLC = *itLC; + + const BidPriceVector_T& aBidPriceVector = lCurrentLC.getBidPriceVector(); + for (BidPriceVector_T::const_reverse_iterator itBidPrice = + aBidPriceVector.rbegin(); + itBidPrice != aBidPriceVector.rend(); ++itBidPrice) { + const BidPrice_T& aBidPrice = *itBidPrice; + + oStream << lCurrentLD.getBoardingPoint() << "-" + << lCurrentLD.getOffPoint() << ", " + << lCurrentLC.getCabinCode() << ", " + << aBidPrice << ", " << std::endl; + } + } + } + oStream << "******************************************" << std::endl; + + // Reset formatting flags of the given output stream + oStream.flags (oldFlags); + } + + // ////////////////////////////////////////////////////////////////////// void BomManager::display (std::ostream& oStream, const SegmentDate& iSegmentDate) { // Store current formatting flags of the given output stream @@ -292,5 +411,32 @@ // Reset formatting flags of the given output stream oStream.flags (oldFlags); } + + // ////////////////////////////////////////////////////////////////////// + void BomManager::csvDisplay (std::ostream& oStream, + const BookingRequestStruct& iBookingRequest) { + // Store current formatting flags of the given output stream + std::ios::fmtflags oldFlags = oStream.flags(); + + /* + #id, request_date (YYMMDD), request_time (HHMMSS), POS (three-letter code), + origin (three-letter code), destination (three-letter code), + preferred departure date (YYMMDD), preferred departure time (HHMM), + min departure time (HHMM), max departure time (HHMM), + preferred cabin (F/C/M), trip type (OW/RO/RI), duration of stay (days), + frequent flyer tier (G/S/K/N), willingness-to-pay (SGD), + disutility per stop (SGD), preferred arrival date (YYMMDD), + preferred arrival time (HHMM), value of time (SGD per hour) + + #Preferred cabin: F=First, C=Business M=Economy + #Trip type: OW=One-way, RO=Round-trip outbound portion, + RI=Round-trip inbound portion + #Duration of stay: irrelevant in case of one-way, but set to 0 + #Frequent-flyer tier: G=Gold, S=Silver, K=Basic (Krisflyer), N=None + */ + // Reset formatting flags of the given output stream + oStream.flags (oldFlags); + } + } Modified: trunk/stdair/stdair/bom/BomManager.hpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.hpp 2010-02-15 16:25:42 UTC (rev 142) +++ trunk/stdair/stdair/bom/BomManager.hpp 2010-02-15 19:48:39 UTC (rev 143) @@ -22,6 +22,7 @@ class NetworkDate; class AirportDate; class OutboundPath; + struct BookingRequestStruct; /** Utility class for StdAir objects. */ class BomManager { @@ -46,26 +47,33 @@ @param std::ostream& Output stream in which the BOM tree should be logged/dumped. @param const FlightDate& Root of the BOM tree to be displayed. */ - static void display (std::ostream&, const FlightDate&); + static void csvFlightDateDisplay (std::ostream&, const FlightDate&); /** Recursively display (dump in the underlying output log stream) the objects of the given BOM tree. @param std::ostream& Output stream in which the BOM tree should be logged/dumped. @param const LegDate& Root of the BOM tree to be displayed. */ - static void display (std::ostream&, const LegDate&); + static void csvLegDateDisplay (std::ostream&, const FlightDate&); /** Recursively display (dump in the underlying output log stream) the objects of the given BOM tree. @param std::ostream& Output stream in which the BOM tree should be logged/dumped. @param const LegCabin& Root of the BOM tree to be displayed. */ - static void display (std::ostream&, const LegCabin&); + static void csvLegCabinDisplay (std::ostream&, const FlightDate&); /** Recursively display (dump in the underlying output log stream) the objects of the given BOM tree. @param std::ostream& Output stream in which the BOM tree should be logged/dumped. + @param const LegCabin& Root of the BOM tree to be displayed. */ + static void csvBPVDisplay (std::ostream&, const FlightDate&); + + /** Recursively display (dump in the underlying output log stream) + the objects of the given BOM tree. + @param std::ostream& Output stream in which the BOM tree should be + logged/dumped. @param const SegmentDate& Root of the BOM tree to be displayed. */ static void display (std::ostream&, const SegmentDate&); @@ -110,7 +118,15 @@ logged/dumped. @param const OutboundPath& Root of the BOM tree to be displayed. */ static void display (std::ostream&, const OutboundPath&); - }; + /** Recursively display (dump in the underlying output log stream) + the objects of the given BOM tree. + @param std::ostream& Output stream in which the BOM tree should be + logged/dumped. + @param const LegCabin& Root of the BOM tree to be displayed. */ + static void csvDisplay (std::ostream&, + const BookingRequestStruct& iBookingRequest); + }; + } #endif // __STDAIR_BOM_BOMMANAGER_HPP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 16:25:48
|
Revision: 142 http://stdair.svn.sourceforge.net/stdair/?rev=142&view=rev Author: denis_arnaud Date: 2010-02-15 16:25:42 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Dev] The demand distribution parameters (mean value, standard deviation) are now at the end of the line, in the demand input file. Modified Paths: -------------- trunk/stdair/test/samples/demand01.csv Modified: trunk/stdair/test/samples/demand01.csv =================================================================== --- trunk/stdair/test/samples/demand01.csv 2010-02-15 16:12:52 UTC (rev 141) +++ trunk/stdair/test/samples/demand01.csv 2010-02-15 16:25:42 UTC (rev 142) @@ -3,7 +3,7 @@ // Prefered departure date (yyyy-mm-dd) // Origin (3-char airport code) // Destination (3-char airport code) -// Preferred cabin ('F' for First, 'C' for Coach/Business, 'Y' for Economy) +// Preferred cabin ('F' for First, 'C' for Club/Business, 'Y' for Economy) // Distribution with Probability Masses: // POS // Channel (D=direct, I=indirect, N=oNline, F=oFfline) @@ -24,7 +24,11 @@ // Continuous cumulative distribution are defined by comma-separated // 'value:probability' pairs, sorted in increasing order of values. // The meaning of probability is P(random variable <= value) = probability. -// The distribution of number of requests is specified using comma-separated values: distribution, parameter1, parameter2, ... For example, normal with mean 10.0 and standard deviation 1.0 is specified as N, 10.0, 1.0 +// The distribution of number of requests is specified using comma-separated +// values: +// distribution, parameter1, parameter2, ... +// For example, normal with mean 10.0 and standard deviation 1.0 is specified as +// N, 10.0, 1.0 // -2010-02-08; SIN; BKK; Y; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; N, 10.0, 1.0 -2010-02-08; SIN; HND; Y; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; N, 10.0, 2.0 +2010-02-08; SIN; BKK; Y; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; N, 10.0, 1.0; +2010-02-08; SIN; HND; Y; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; N, 10.0, 2.0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-15 16:12:58
|
Revision: 141 http://stdair.svn.sourceforge.net/stdair/?rev=141&view=rev Author: quannaus Date: 2010-02-15 16:12:52 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [dev] A small change in BomRoot. Modified Paths: -------------- trunk/stdair/stdair/bom/BomRootStructure.hpp Modified: trunk/stdair/stdair/bom/BomRootStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-15 15:48:08 UTC (rev 140) +++ trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-15 16:12:52 UTC (rev 141) @@ -84,6 +84,12 @@ return *_secondChildrenHolder; } + /** Get the holder of demand streams. */ + const DemandStreamHolder_T& getDemandStreamHolder() const { + assert (_demandStreamHolder); + return *_demandStreamHolder; + } + /** Get the holder of inventories. */ void getChildrenHolder (ChildrenBomHolder_T*& ioChildrenHolder) { ioChildrenHolder = _childrenHolder; @@ -95,12 +101,6 @@ } /** Get the holder of demand streams. */ - const DemandStreamHolder_T& getDemandStreamHolder() const { - assert (_demandStreamHolder); - return *_demandStreamHolder; - } - - /** Get the holder of demand streams. */ void getDemandStreamHolder (DemandStreamHolder_T*& ioDemandStreamHolder) { ioDemandStreamHolder = _demandStreamHolder; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-15 15:48:17
|
Revision: 140 http://stdair.svn.sourceforge.net/stdair/?rev=140&view=rev Author: quannaus Date: 2010-02-15 15:48:08 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [dev] Trasformed DemandStream into standart stdair BOM. Modified Paths: -------------- trunk/stdair/stdair/bom/AirlineFeature.hpp trunk/stdair/stdair/bom/AirlineFeatureContent.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BomRootStructure.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp trunk/stdair/stdair/bom/Inventory.cpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Added Paths: ----------- trunk/stdair/stdair/bom/DemandStreamContent.cpp trunk/stdair/stdair/bom/DemandStreamContent.hpp trunk/stdair/stdair/bom/DemandStreamStructure.hpp Modified: trunk/stdair/stdair/bom/AirlineFeature.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeature.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/AirlineFeature.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -17,7 +17,6 @@ namespace stdair { // Forward declarations - class FacBomContent; struct AirlineFeatureKey_T; Modified: trunk/stdair/stdair/bom/AirlineFeatureContent.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureContent.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/AirlineFeatureContent.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -21,7 +21,7 @@ public: // /////////// Getters //////////// - /** Get the booking class key. */ + /** Get the airline feature key. */ const BomKey_T& getKey() const { return _key; } Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -43,7 +43,17 @@ NetworkMap_T BomRoot::getNetworkMap () const { return _bomRootStructure.getSecondChildrenHolder(); } + + // ////////////////////////////////////////////////////////////////////// + DemandStreamList_T BomRoot::getDemandStreamList () const { + return _bomRootStructure.getDemandStreamHolder(); + } + // ////////////////////////////////////////////////////////////////////// + DemandStreamMap_T BomRoot::getDemandStreamMap () const { + return _bomRootStructure.getDemandStreamHolder(); + } + // //////////////////////////////////////////////////////////////////// Inventory* BomRoot::getInventory (const AirlineCode_T& iAirlineCode) const { Inventory* oInventory_ptr = NULL; @@ -71,27 +81,25 @@ return oNetwork_ptr; } + + // //////////////////////////////////////////////////////////////////// + DemandStream& BomRoot:: + getDemandStream (const DemandStreamKeyStr_T& iKey) const { + DemandStreamMap_T lDemandStreamMap = getDemandStreamMap (); + + DemandStreamMap_T::iterator itDemandStream = lDemandStreamMap.find (iKey); + assert (itDemandStream != lDemandStreamMap.end()); + + DemandStream* oDemandStream_ptr = itDemandStream->second; + assert (oDemandStream_ptr != NULL); + + return *oDemandStream_ptr; + } // //////////////////////////////////////////////////////////////////// AirlineFeatureSet& BomRoot::getAirlineFeatureSet() const { assert (_airlineFeatureSet != NULL); return *_airlineFeatureSet; } - - // //////////////////////////////////////////////////////////////////// - void BomRoot::addDemandStream (const DemandStreamKeyStr_T& iKeyStr, - DemandStream& ioDemandStream) { - // Insert the reference on the given DemandStream object into the - // dedicated list - const bool hasInsertBeenSuccessfull = - _demandStreamList.insert (DemandStreamList_T:: - value_type (iKeyStr, &ioDemandStream)).second; - if (hasInsertBeenSuccessfull == false) { - STDAIR_LOG_ERROR ("The DemandStream object with key: " << iKeyStr - << " can not be inserted into the dedicated list"); - STDAIR_LOG_ERROR ("DemandStream object: " << ioDemandStream); - assert (false); - } - } } Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -18,6 +18,7 @@ // Forward declarations. class FacBomContent; class AirlineFeatureSet; + class DemandStream; struct BomRootKey_T; /** Class representing the actual functional/business content @@ -66,6 +67,9 @@ /** Definition allowing to retrieve the associated second BOM content child type. */ typedef Network SecondContentChild_T; + + /** Definition allowing to retrieve the specific DemandStream type. */ + typedef DemandStream DemandStreamContent_T; // ///////////////////////////////////////////////////////////////////////// @@ -117,15 +121,16 @@ /** Get a NetworkMap_T for iteration methods. */ NetworkMap_T getNetworkMap () const; + + /** Get a DemandStreamList_T for iteration methods. */ + DemandStreamList_T getDemandStreamList () const; + + /** Get a DemandStreamMap_T for iteration methods. */ + DemandStreamMap_T getDemandStreamMap () const; /** Get the reference of the AirlineFeatureSet object. */ AirlineFeatureSet& getAirlineFeatureSet() const; - /** Get the reference of the list of DemandStream objects. */ - DemandStreamList_T& getDemandStreamList() { - return _demandStreamList; - } - /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). <br>If not existing, return the NULL pointer. */ @@ -136,6 +141,9 @@ <br>If not existing, return the NULL pointer. */ Network* getNetwork (const NetworkID_T&) const; + /** Retrieve the DemandStream which corresponds to the given key. */ + DemandStream& getDemandStream (const DemandStreamKeyStr_T&) const; + public: // //////////// Setters ////////////// @@ -174,8 +182,6 @@ /** Set of all AirlineFeatures. */ AirlineFeatureSet* _airlineFeatureSet; - /** Set of all DemandStream objects. */ - DemandStreamList_T _demandStreamList; }; } Modified: trunk/stdair/stdair/bom/BomRootStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -54,7 +54,16 @@ /** Definition allowing to retrive the second children bom holder type. */ typedef BomChildrenHolderImp<SecondContentChild_T> SecondChildrenBomHolder_T; + /** Define the children demand stream type. */ + typedef typename BOM_CONTENT::DemandStreamContent_T DemandStream_T; + + /** Define the children demand stream holder type. */ + typedef BomChildrenHolderImp<DemandStream_T> DemandStreamHolder_T; + + /** Define the map of demand stream. */ + typedef BomMap_T<DemandStream_T> DemandStreamMap_T; + public: // /////////// Getters ///////////// /** Get the BomRootStructure key. */ @@ -85,6 +94,17 @@ ioChildrenHolder = _secondChildrenHolder; } + /** Get the holder of demand streams. */ + const DemandStreamHolder_T& getDemandStreamHolder() const { + assert (_demandStreamHolder); + return *_demandStreamHolder; + } + + /** Get the holder of demand streams. */ + void getDemandStreamHolder (DemandStreamHolder_T*& ioDemandStreamHolder) { + ioDemandStreamHolder = _demandStreamHolder; + } + private: /////////////// Setters //////////////// /** Default children holder setter. */ @@ -100,6 +120,11 @@ _secondChildrenHolder = &ioChildrenHolder; } + /** Set the demand stream holder. */ + void setDemandStreamHolder (DemandStreamHolder_T& ioDemandStreamHolder) { + _demandStreamHolder = &ioDemandStreamHolder; + } + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -128,7 +153,8 @@ layer. */ /** Default constructors. */ BomRootStructure () : _content (NULL), _childrenHolder (NULL), - _secondChildrenHolder (NULL) { }; + _secondChildrenHolder (NULL), + _demandStreamHolder (NULL) { }; BomRootStructure (const BomRootStructure&); /** Destructor. */ @@ -144,6 +170,9 @@ /** Holder of networks. */ SecondChildrenBomHolder_T* _secondChildrenHolder; + + /** Holder of demand streams. */ + DemandStreamHolder_T* _demandStreamHolder; }; } Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -28,41 +28,15 @@ const DemandDistribution& iDemandDistribution, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed) - : _key (iKey), - _demandCharacteristics (iDemandCharacteristics), - _demandDistribution (iDemandDistribution), - _totalNumberOfRequestsToBeGenerated (0), - _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), - _requestDateTimeRandomGenerator (iRequestDateTimeSeed), - _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { - init(); + const RandomSeed_T& iDemandCharacteristicsSeed, + BomStructure_T& ioDemandStreamStructure) + : DemandStreamContent (iKey, iDemandCharacteristics, + iDemandDistribution, iNumberOfRequestsSeed, + iRequestDateTimeSeed, iDemandCharacteristicsSeed), + _demandStreamStructure (ioDemandStreamStructure) { } // ////////////////////////////////////////////////////////////////////// DemandStream::~DemandStream () { } - - // ////////////////////////////////////////////////////////////////////// - void DemandStream::init() { - // Generate the number of requests - const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); - const RealNumber_T lSigma = - _demandDistribution.getStandardDeviationNumberOfRequests (); - - const RealNumber_T lRealNumberOfRequestsToBeGenerated = - _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); - - NbOfRequests_T lIntegerNumberOfRequestsToBeGenerated = 0; - if (lRealNumberOfRequestsToBeGenerated < 0.5) { - lIntegerNumberOfRequestsToBeGenerated = 0; - - } else { - lIntegerNumberOfRequestsToBeGenerated = - static_cast<NbOfRequests_T> (lRealNumberOfRequestsToBeGenerated + 0.5); - } - - _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; - } - } Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -10,110 +10,43 @@ #include <iosfwd> // STDAIR #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/DemandCharacteristics.hpp> -#include <stdair/basic/DemandDistribution.hpp> -#include <stdair/basic/RandomGeneration.hpp> -#include <stdair/basic/RandomGenerationContext.hpp> -#include <stdair/bom/BomContent.hpp> -#include <stdair/bom/BookingRequestTypes.hpp> -#include <stdair/bom/DemandStreamKey.hpp> +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/DemandStreamStructure.hpp> +#include <stdair/bom/DemandStreamContent.hpp> +#include <stdair/bom/BomRootTypes.hpp> #include <stdair/bom/DemandStreamTypes.hpp> -#include <stdair/service/Logger.hpp> namespace stdair { + + // Forward declarations + struct DemandStreamKey_T; /** Class modeling a demand stream. */ - class DemandStream : public BomContent { + class DemandStream : public DemandStreamContent { friend class FacBomContent; public: - // ///////////// Getters /////////// - /** Get the key */ - const DemandStreamKey_T& getKey () const { - return _key; - } - - /** Get the total number of requests to be generated. */ - const NbOfRequests_T& getTotalNumberOfRequestsToBeGenerated() const { - return _totalNumberOfRequestsToBeGenerated; - } + // //////////// Type definitions ////////////// + /** Definition allowing to retrieve the associated parent + BOM content type. */ + typedef BomRoot Parent_T; - /** Get the origin. */ - const AirportCode_T& getOrigin() const { - return _demandCharacteristics.getOrigin(); - } - - /** Get the destination. */ - const AirportCode_T& getDestination() const { - return _demandCharacteristics.getDestination(); - } - - /** Get the preferred departure date. */ - const Date_T& getPreferredDepartureDate() const { - return _demandCharacteristics.getPreferredDepartureDate(); - } + /** Definition allowing to retrieve the associated BOM structure type. */ + typedef DemandStreamStructure_T BomStructure_T; - /** Get the preferred cabin. */ - const CabinCode_T& getPreferredCabin() const { - return _demandCharacteristics.getPreferredCabin(); - } - - /** Get the arrival pattern. */ - const ContinuousFloatDuration_T& getArrivalPattern() const { - return _demandCharacteristics.getArrivalPattern(); - } + /** Definition allowing to retrieve the associated BOM key type. */ + typedef DemandStreamKey_T BomKey_T; - /** Get the mean number of requests. */ - const NbOfRequests_T& getMeanNumberOfRequests() const { - return _demandDistribution.getMeanNumberOfRequests(); - } - - /** Get the standard deviation of number of requests. */ - const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { - return _demandDistribution.getStandardDeviationNumberOfRequests(); - } - - /** Get the cumulative probability of arrival pattern for last - request generated so far. */ - const Probability_T& getCumulativeProbabilitySoFar () const { - return _randomGenerationContext.getCumulativeProbabilitySoFar(); - } - - /** Get the number of requests generated so far. */ - const Count_T getNumberOfRequestsGeneratedSoFar() const { - return _randomGenerationContext.getCumulativeProbabilitySoFar();; - } - - /** Get the seed of the random generator for the number of requests. */ - const RandomSeed_T& getNumberOfRequestsRandomGeneratorSeed () const { - return _numberOfRequestsRandomGenerator.getSeed(); - } + /** Definition allowing to retrieve the associated + BOM content child type. */ + typedef DemandStream ContentChild_T; - /** Get the seed of the random generator for the request datetime. */ - const RandomSeed_T& getRequestDateTimeRandomGeneratorSeed () const { - return _requestDateTimeRandomGenerator.getSeed(); + private: + /** Retrieve the BOM structure object. */ + BomStructure_T& getBomStructure () { + return _demandStreamStructure; } - - /** Get the seed of the random generator for the demand characteristics. */ - const RandomSeed_T& getDemandCharacteristicsRandomGeneratorSeed () const { - return _demandCharacteristicsRandomGenerator.getSeed(); - } - - public: - // //////////////// Setters ////////////////// - /** Set the cumulative probability of arrival pattern for last - request generated so far. */ - void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { - _randomGenerationContext. - setCumulativeProbabilitySoFar (iCumulativeProbability); - } - /** Set the number of requests generated so far. */ - void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { - _randomGenerationContext. - setNumberOfRequestsGeneratedSoFar (iNumberOfRequests); - } - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -136,62 +69,15 @@ const std::string describeShortKey() const { return std::string (""); } - public: - // /////////////// Business Methods ////////// - /** Increment counter of requests generated so far */ - void incrementGeneratedRequestsCounter () { - _randomGenerationContext.incrementGeneratedRequestsCounter(); - } - - - /** Generate a randomized number following a uniform distribution - between 0 (included) and 1 (excluded). */ - RealNumber_T generateUniform01WithNumberOfRequestRandomGenerator () { - return _numberOfRequestsRandomGenerator.generateUniform01(); - } - RealNumber_T generateUniform01WithRequestDateTimeRandomGenerator() { - return _requestDateTimeRandomGenerator.generateUniform01(); - } - RealNumber_T generateUniform01WithDemandCharacteristicsRandomGenerator() { - return _demandCharacteristicsRandomGenerator.generateUniform01(); - } - - /** Generate a randomized number following a uniform distribution - between a minimum (included) and a maximum (excluded) - value. */ - RealNumber_T generateUniformWithNumberOfRequestRandomGenerator (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { - return _numberOfRequestsRandomGenerator.generateUniform (iMinValue, - iMaxValue); - } - RealNumber_T generateUniformWithRequestDateTimeRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { - return _requestDateTimeRandomGenerator.generateUniform (iMinValue, - iMaxValue); - } - RealNumber_T generateUniformWithDemandCharacteristicsRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { - return _demandCharacteristicsRandomGenerator.generateUniform (iMinValue, - iMaxValue); - } - - /** Generate a randomized number following a normal distribution - specified by a mean and a standard deviation. */ - RealNumber_T generateNormalWithNumberOfRequestRandomGenerator (const RealNumber_T& mu, const RealNumber_T& sigma) { - return _numberOfRequestsRandomGenerator.generateNormal (mu, sigma); - } - RealNumber_T generateNormalWithRequestDateTimeRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { - return _requestDateTimeRandomGenerator.generateNormal (mu, sigma); - } - RealNumber_T generateNormalWithDemandCharacteristicsRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { - return _demandCharacteristicsRandomGenerator.generateNormal (mu, sigma); - } - protected: // ////////// Constructors and destructors ///////// /** Constructor by default */ - DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, + DemandStream (const BomKey_T&, const DemandCharacteristics&, const DemandDistribution&, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed); + const RandomSeed_T& iDemandCharacteristicsSeed, + BomStructure_T&); /** Default constructors. */ DemandStream (); DemandStream (const DemandStream&); @@ -203,29 +89,8 @@ protected: // ////////// Attributes ////////// - /** Key */ - DemandStreamKey_T _key; - - /** Demand characteristics */ - DemandCharacteristics _demandCharacteristics; - - /** Demand distribution */ - DemandDistribution _demandDistribution; - - /** Total number of requests to be generated*/ - NbOfRequests_T _totalNumberOfRequestsToBeGenerated; - - /** Random generation context */ - RandomGenerationContext _randomGenerationContext; - - /** Random generator for number of requests */ - RandomGeneration _numberOfRequestsRandomGenerator; - - /** Random generator for request datetime */ - RandomGeneration _requestDateTimeRandomGenerator; - - /** Random generator for demand characteristics */ - RandomGeneration _demandCharacteristicsRandomGenerator; + /** Reference structure. */ + BomStructure_T& _demandStreamStructure; }; } Copied: trunk/stdair/stdair/bom/DemandStreamContent.cpp (from rev 136, trunk/stdair/stdair/bom/DemandStream.cpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamContent.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -0,0 +1,65 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <ostream> +#include <sstream> +// Boost +#include <boost/math/distributions/normal.hpp> +// Math +#include <math.h> +// STDAIR +#include <stdair/basic/BasConst_General.hpp> +#include <stdair/bom/DemandStreamContent.hpp> +#include <stdair/service/Logger.hpp> + + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + DemandStreamContent:: + DemandStreamContent (const BomKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) + : _key (iKey), + _demandCharacteristics (iDemandCharacteristics), + _demandDistribution (iDemandDistribution), + _totalNumberOfRequestsToBeGenerated (0), + _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), + _requestDateTimeRandomGenerator (iRequestDateTimeSeed), + _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { + init(); + } + + // ////////////////////////////////////////////////////////////////////// + DemandStreamContent::~DemandStreamContent () { + } + + // ////////////////////////////////////////////////////////////////////// + void DemandStreamContent::init() { + // Generate the number of requests + const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lSigma = + _demandDistribution.getStandardDeviationNumberOfRequests (); + + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); + + NbOfRequests_T lIntegerNumberOfRequestsToBeGenerated = 0; + if (lRealNumberOfRequestsToBeGenerated < 0.5) { + lIntegerNumberOfRequestsToBeGenerated = 0; + + } else { + lIntegerNumberOfRequestsToBeGenerated = + static_cast<NbOfRequests_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + } + + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; + } + +} Copied: trunk/stdair/stdair/bom/DemandStreamContent.hpp (from rev 136, trunk/stdair/stdair/bom/DemandStream.hpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -0,0 +1,232 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMCONTENT_HPP +#define __STDAIR_BOM_DEMANDSTREAMCONTENT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/DemandDistribution.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BomContent.hpp> +#include <stdair/bom/DemandStreamKey.hpp> + +namespace stdair { + + /** Class modeling a demand stream. */ + class DemandStreamContent : public BomContent { + + public: + // Type definitions. + /** Definition allowing to retrieve the associated BOM key type. */ + typedef DemandStreamKey_T BomKey_T; + + public: + // ///////////// Getters /////////// + /** Get the key */ + const BomKey_T& getKey () const { + return _key; + } + + /** Get the total number of requests to be generated. */ + const NbOfRequests_T& getTotalNumberOfRequestsToBeGenerated() const { + return _totalNumberOfRequestsToBeGenerated; + } + + /** Get the origin. */ + const AirportCode_T& getOrigin() const { + return _demandCharacteristics.getOrigin(); + } + + /** Get the destination. */ + const AirportCode_T& getDestination() const { + return _demandCharacteristics.getDestination(); + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate() const { + return _demandCharacteristics.getPreferredDepartureDate(); + } + + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _demandCharacteristics.getPreferredCabin(); + } + + /** Get the arrival pattern. */ + const ContinuousFloatDuration_T& getArrivalPattern() const { + return _demandCharacteristics.getArrivalPattern(); + } + + /** Get the mean number of requests. */ + const NbOfRequests_T& getMeanNumberOfRequests() const { + return _demandDistribution.getMeanNumberOfRequests(); + } + + /** Get the standard deviation of number of requests. */ + const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { + return _demandDistribution.getStandardDeviationNumberOfRequests(); + } + + /** Get the cumulative probability of arrival pattern for last + request generated so far. */ + const Probability_T& getCumulativeProbabilitySoFar () const { + return _randomGenerationContext.getCumulativeProbabilitySoFar(); + } + + /** Get the number of requests generated so far. */ + const Count_T getNumberOfRequestsGeneratedSoFar() const { + return _randomGenerationContext.getCumulativeProbabilitySoFar();; + } + + /** Get the seed of the random generator for the number of requests. */ + const RandomSeed_T& getNumberOfRequestsRandomGeneratorSeed () const { + return _numberOfRequestsRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the request datetime. */ + const RandomSeed_T& getRequestDateTimeRandomGeneratorSeed () const { + return _requestDateTimeRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the demand characteristics. */ + const RandomSeed_T& getDemandCharacteristicsRandomGeneratorSeed () const { + return _demandCharacteristicsRandomGenerator.getSeed(); + } + + public: + // //////////////// Setters ////////////////// + /** Set the cumulative probability of arrival pattern for last + request generated so far. */ + void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { + _randomGenerationContext. + setCumulativeProbabilitySoFar (iCumulativeProbability); + } + + /** Set the number of requests generated so far. */ + void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { + _randomGenerationContext. + setNumberOfRequestsGeneratedSoFar (iNumberOfRequests); + } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + virtual void toStream (std::ostream& ioOut) const = 0; + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + virtual void fromStream (std::istream& ioIn) = 0; + + /** Get the serialised version of the Business Object. */ + virtual std::string toString() const = 0; + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + virtual const std::string describeKey() const = 0; + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + virtual const std::string describeShortKey() const = 0; + + public: + // /////////////// Business Methods ////////// + /** Increment counter of requests generated so far */ + void incrementGeneratedRequestsCounter () { + _randomGenerationContext.incrementGeneratedRequestsCounter(); + } + + + /** Generate a randomized number following a uniform distribution + between 0 (included) and 1 (excluded). */ + RealNumber_T generateUniform01WithNumberOfRequestRandomGenerator () { + return _numberOfRequestsRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithRequestDateTimeRandomGenerator() { + return _requestDateTimeRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithDemandCharacteristicsRandomGenerator() { + return _demandCharacteristicsRandomGenerator.generateUniform01(); + } + + /** Generate a randomized number following a uniform distribution + between a minimum (included) and a maximum (excluded) + value. */ + RealNumber_T generateUniformWithNumberOfRequestRandomGenerator (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _numberOfRequestsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithRequestDateTimeRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _requestDateTimeRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithDemandCharacteristicsRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _demandCharacteristicsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + + /** Generate a randomized number following a normal distribution + specified by a mean and a standard deviation. */ + RealNumber_T generateNormalWithNumberOfRequestRandomGenerator (const RealNumber_T& mu, const RealNumber_T& sigma) { + return _numberOfRequestsRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithRequestDateTimeRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _requestDateTimeRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithDemandCharacteristicsRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _demandCharacteristicsRandomGenerator.generateNormal (mu, sigma); + } + + protected: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandStreamContent (const BomKey_T&, const DemandCharacteristics&, + const DemandDistribution&, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed); + /** Default constructors. */ + DemandStreamContent (); + DemandStreamContent (const DemandStreamContent&); + /** Initialization. */ + void init(); + /** Destructor. */ + ~DemandStreamContent (); + + + protected: + // ////////// Attributes ////////// + /** Key */ + BomKey_T _key; + + /** Demand characteristics */ + DemandCharacteristics _demandCharacteristics; + + /** Demand distribution */ + DemandDistribution _demandDistribution; + + /** Total number of requests to be generated*/ + NbOfRequests_T _totalNumberOfRequestsToBeGenerated; + + /** Random generation context */ + RandomGenerationContext _randomGenerationContext; + + /** Random generator for number of requests */ + RandomGeneration _numberOfRequestsRandomGenerator; + + /** Random generator for request datetime */ + RandomGeneration _requestDateTimeRandomGenerator; + + /** Random generator for demand characteristics */ + RandomGeneration _demandCharacteristicsRandomGenerator; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMCONTENT_HPP Copied: trunk/stdair/stdair/bom/DemandStreamStructure.hpp (from rev 136, trunk/stdair/stdair/bom/AirlineFeatureStructure.hpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamStructure.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamStructure.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -0,0 +1,113 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMSTRUCTURE_HPP +#define __STDAIR_BOM_DEMANDSTREAMSTRUCTURE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// MPL +#include <boost/mpl/vector.hpp> +// STDAIR +#include <stdair/bom/BomStopStructure.hpp> +#include <stdair/bom/BomStopContent.hpp> + +namespace stdair { + /** Wrapper class aimed at holding the actual content, modeled + by an external specific DemandStream class (for instance, + in the AIRSCHED library). */ + template <class BOM_CONTENT> + class DemandStreamStructure : public BomStructure { + friend class FacBomStructure; + friend class FacBomContent; + friend class BomStructure; + + public: + // Type definitions + /** Definition allowing to retrieve the associated BOM content type. */ + typedef BOM_CONTENT Content_T; + + /** Definition allowing to retrieve the associated BOM key type. */ + typedef typename BOM_CONTENT::BomKey_T BomKey_T; + + /** Definition allowing to retrieve the associated parent + BOM structure type. */ + typedef typename BOM_CONTENT::Parent_T::BomStructure_T ParentBomStructure_T; + + /** Definition allowing to retrieve the associated children type. */ + typedef boost::mpl::vector <BomStopStructure, + BomStopStructure> ChildrenBomTypeList_T; + + /** Definition allowing to retrieve the default children bom holder type. */ + typedef BomChildrenHolderImp<BomStopContent> DefaultChildrenBomHolder_T; + + public: + // /////////// Getters ///////////// + /** Get the (parent) BomRootStructure object. */ + ParentBomStructure_T* getBomRootStructurePtr() const { + return _parent; + } + + /** Get the (parent) BomRootStructure object. */ + ParentBomStructure_T& getBomRootStructure() const; + + /** Get the segment-cabin key. */ + const BomKey_T& getKey() const { + assert (_content != NULL); + return _content->getKey(); + } + + private: + // /////////// Setters ///////////// + /** Set the (parent) BomRootStructure object. */ + void setBomRootStructure (ParentBomStructure_T& ioBomRootStructure){ + _parent = &ioBomRootStructure; + } + + /** Default children holder setter. */ + void setChildrenHolder (DefaultChildrenBomHolder_T&) { } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { + ioOut << toString() << std::endl; + } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) { } + + /** Get the serialised version of the Business Object. */ + std::string toString() const { return describeKey(); } + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const { return getKey().toString(); } + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + const std::string describeShortKey() const { return getKey().toString(); } + + private: + /** Constructors are private so as to force the usage of the Factory + layer. */ + /** Default constructors. */ + DemandStreamStructure () : _parent (NULL), _content (NULL) { } + DemandStreamStructure (const DemandStreamStructure&); + + /** Destructor. */ + virtual ~DemandStreamStructure() { } + + private: + // Attributes + /** Parent segment-cabin. */ + ParentBomStructure_T* _parent; + + /** The actual functional (Business Object) content. */ + BOM_CONTENT* _content; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMSTRUCTURE_HPP Modified: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -6,19 +6,30 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <map> -// Boost -#include <boost/shared_ptr.hpp> -// STDAIR -#include <stdair/STDAIR_Types.hpp> +#include <vector> namespace stdair { - // Forward declaration + // Forward declarations. + template <typename BOM_CONTENT> class DemandStreamStructure; + template <typename BOM> struct BomList_T; + template <typename BOM> struct BomMap_T; class DemandStream; + + /** Define the airline feature structure. */ + typedef DemandStreamStructure<DemandStream> DemandStreamStructure_T; + + /** Define the airline feature structure list. */ + typedef std::vector<DemandStreamStructure_T*> DemandStreamStructureList_T; + /** Define the airline feature structure map. */ + typedef std::map<const std::string, DemandStreamStructure_T*> DemandStreamStructureMap_T; + + /** Define the airline feature list. */ + typedef BomList_T<DemandStream> DemandStreamList_T; + + /** Define the airline feature map. */ + typedef BomMap_T<DemandStream> DemandStreamMap_T; - /** Define a map of demand strams. */ - typedef std::map<const DemandStreamKeyStr_T, DemandStream*> DemandStreamList_T; - } #endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/Inventory.cpp =================================================================== --- trunk/stdair/stdair/bom/Inventory.cpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/Inventory.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -74,13 +74,5 @@ getFlightDate (const FlightDateKey_T& iKey) const { return _inventoryStructure.getContentChild (iKey); } - -// BookingClass* getBookingClass (const std::string&) const; - -// /** Clean the list of classes. */ -// void cleanClassList(); - -// FlightDate* -// getFlightDateInternal (const std::string& iFlightDateKey) const; } Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-15 15:48:08 UTC (rev 140) @@ -86,6 +86,8 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamStructure.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamContent.hpp \ $(top_srcdir)/stdair/bom/DemandStream.hpp \ $(top_srcdir)/stdair/bom/DemandStreamTypes.hpp \ $(top_srcdir)/stdair/bom/EventStruct.hpp \ @@ -141,6 +143,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ + $(top_srcdir)/stdair/bom/DemandStreamContent.cpp \ $(top_srcdir)/stdair/bom/DemandStream.cpp \ $(top_srcdir)/stdair/bom/EventStruct.cpp \ $(top_srcdir)/stdair/bom/EventQueue.cpp \ Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -174,6 +174,29 @@ iReferenceOutboundPath._flightPathCode; } + /** Add a demand stream into the bom root. */ + template <typename DEMAND_STREAM> + static bool addDemandStream (typename DEMAND_STREAM::Parent_T& ioBomRoot, + DEMAND_STREAM& ioDemandStream) { + // Definition allowing to retrieve the corresponding BomRoot type. + typedef typename DEMAND_STREAM::Parent_T BOM_ROOT_T; + // Definition allowing to retrieve the corresponding BomRootStructure type. + typedef typename BOM_ROOT_T::BomStructure_T BOM_ROOT_STRUCTURE_T; + // Definition allowing to retrieve the corresponding + // DemandStreamStructure type. + typedef typename DEMAND_STREAM::BomStructure_T DEMAND_STREAM_STRUCTURE_T; + + // Retrieve the bom root structure and the demand stream structure. + BOM_ROOT_STRUCTURE_T& lBomRootStructure = ioBomRoot.getBomStructure(); + DEMAND_STREAM_STRUCTURE_T& lDemandStreamStructure = + ioDemandStream.getBomStructure(); + + // Forward the call to FacBomStructure. + return FacBomStructure:: + addDemandStream<DEMAND_STREAM_STRUCTURE_T> (lBomRootStructure, + lDemandStreamStructure); + } + // ////////////////////////////////////////////////////////////////// // /////////////////////// Dedicated factories ////////////////////// // ////////////////////////////////////////////////////////////////// @@ -184,14 +207,23 @@ const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, const RandomSeed_T& iDemandCharacteristicsSeed) { + // Create the structure/holder object + typedef typename DEMAND_STREAM::BomStructure_T DEMAND_STREAM_STRUCTURE_T; + DEMAND_STREAM_STRUCTURE_T& lBomStructure = + FacBomStructure::instance().create<DEMAND_STREAM_STRUCTURE_T> (); + DEMAND_STREAM* aDemandStream_ptr = new DEMAND_STREAM (iKey, iDemandCharacteristics, iDemandDistribution, iNumberOfRequestsSeed, iRequestDateTimeSeed, - iDemandCharacteristicsSeed); + iDemandCharacteristicsSeed, lBomStructure); assert (aDemandStream_ptr != NULL); // The new object is added to the pool of content objects _contentPool.push_back (aDemandStream_ptr); + + // Link the structure/holder object with its corresponding content object + setContent<DEMAND_STREAM_STRUCTURE_T, DEMAND_STREAM> (lBomStructure, + *aDemandStream_ptr); return *aDemandStream_ptr; } Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -603,6 +603,31 @@ } // ////////////////////////////////////////////////////////////////// + + // ////////////////////////////////////////////////////////////////// + /** Add a demand stream into the bom root. */ + template <typename DEMAND_STREAM_STRUCTURE> + static bool addDemandStream (typename DEMAND_STREAM_STRUCTURE::ParentBomStructure_T& ioBomRootStructure, DEMAND_STREAM_STRUCTURE& ioDemandStreamStructure) { + // Set the parent for the demand stream. + ioDemandStreamStructure._parent = &ioBomRootStructure; + + // Retrieve the DemandStream holder within the BomRoot, if this + // holder has not been created yet, then create it. + typedef typename DEMAND_STREAM_STRUCTURE::Content_T DEMAND_STREAM_T; + typedef BomChildrenHolderImp<DEMAND_STREAM_T> DEMAND_STREAM_HOLDER_T; + DEMAND_STREAM_HOLDER_T* lDemandStreamHolder = NULL; + ioBomRootStructure.getDemandStreamHolder (lDemandStreamHolder); + + if (lDemandStreamHolder == NULL) { + lDemandStreamHolder = + &FacBomStructure::instance().createBomHolder<DEMAND_STREAM_T> (); + ioBomRootStructure.setDemandStreamHolder (*lDemandStreamHolder); + } + + return addBomObjecdToBomHolder <DEMAND_STREAM_T> (*lDemandStreamHolder, + ioDemandStreamStructure); + } + private: /** The unique instance.*/ static FacBomStructure* _instance; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 15:22:22
|
Revision: 139 http://stdair.svn.sourceforge.net/stdair/?rev=139&view=rev Author: denis_arnaud Date: 2010-02-15 15:22:16 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Dev] The passenger type has become the preferred cabin. Modified Paths: -------------- trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamKey.cpp trunk/stdair/stdair/bom/DemandStreamKey.hpp Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////// DemandCharacteristics::DemandCharacteristics () - : _key (DemandStreamKey_T("", "", DEFAULT_DATE, PassengerType::LAST_VALUE)) { + : _key (DemandStreamKey_T ("", "", DEFAULT_DATE, "")) { } // ///////////////////////////////////////////////////// @@ -48,8 +48,8 @@ } // ///////////////////////////////////////////////////// - const PassengerType& DemandCharacteristics::getPaxType() const { - return _key.getPassengerType(); + const CabinCode_T& DemandCharacteristics::getPreferredCabin() const { + return _key.getPreferredCabin(); } // ///////////////////////////////////////////////////// @@ -65,7 +65,7 @@ << std::endl; oStr << "Preferred departure date ......... : " << _key.getPreferredDepartureDate() << std::endl; - oStr << "Passenger type ................... : " << _key.getPassengerType() + oStr << "Preferred cabin .................. : " << _key.getPreferredCabin() << std::endl; oStr << "Arrival pattern (days from departure, proportion): "; Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -32,8 +32,8 @@ /** Get the preferred departure date. */ const Date_T& getPreferredDepartureDate() const; - /** Get the passenger type. */ - const PassengerType& getPaxType() const; + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const; /** Get the arrival pattern. */ const ContinuousFloatDuration_T& getArrivalPattern() const { Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -16,12 +16,12 @@ const AirportCode_T& iDestination, const Date_T& iDepartureDate, const DateTime_T& iRequestDateTime, - const PassengerType& iPaxType, + const CabinCode_T& iPreferredCabin, const NbOfSeats_T& iPartySize) : _origin (iOrigin), _destination (iDestination), _preferredDepartureDate (iDepartureDate), _requestDateTime (iRequestDateTime), - _paxType (iPaxType), _partySize (iPartySize) { + _preferredCabin (iPreferredCabin), _partySize (iPartySize) { } // ////////////////////////////////////////////////////////////////////// @@ -41,7 +41,8 @@ const std::string BookingRequestStruct::describe() const { std::ostringstream oStr; oStr << _origin << " - " << _destination << " " << _preferredDepartureDate - << " " << _requestDateTime << " " << _paxType << " " << _partySize; + << " " << _requestDateTime << " " << _preferredCabin + << " " << _partySize; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -10,7 +10,6 @@ // StdAir #include <stdair/STDAIR_Types.hpp> #include <stdair/basic/StructAbstract.hpp> -#include <stdair/basic/PassengerType.hpp> namespace stdair { @@ -38,9 +37,9 @@ return _requestDateTime; } - /** Get the passenger type. */ - const PassengerType& getPaxType() const { - return _paxType; + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _preferredCabin; } /** Get the party size. */ @@ -70,9 +69,9 @@ _requestDateTime = iRequestDateTime; } - /** Set the passenger type. */ - void setPaxType (const PassengerType& iPaxType) { - _paxType = iPaxType; + /** Set the preferred cabin. */ + void setPreferredCabin (const CabinCode_T& iPreferredCabin) { + _preferredCabin = iPreferredCabin; } /** Set the party size. */ @@ -99,7 +98,7 @@ /** Constructor. */ BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, - const PassengerType&, const NbOfSeats_T&); + const CabinCode_T&, const NbOfSeats_T&); public : /** Default constructor. */ BookingRequestStruct (); @@ -121,11 +120,11 @@ /** Departure date. */ Date_T _preferredDepartureDate; - /** Request datetime */ + /** Request date-time */ DateTime_T _requestDateTime; - /** Passenger type. */ - PassengerType _paxType; + /** Preferred cabin. */ + CabinCode_T _preferredCabin; /** Party size. */ NbOfSeats_T _partySize; Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -6,11 +6,10 @@ #include <iosfwd> #include <ostream> #include <sstream> +#include <cmath> // Boost #include <boost/math/distributions/normal.hpp> -// Math -#include <math.h> -// STDAIR +// StdAir #include <stdair/basic/BasConst_General.hpp> #include <stdair/basic/DemandCharacteristics.hpp> #include <stdair/basic/RandomGeneration.hpp> Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -53,9 +53,9 @@ return _demandCharacteristics.getPreferredDepartureDate(); } - /** Get the passenger type. */ - const PassengerType& getPaxType() const { - return _demandCharacteristics.getPaxType(); + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _demandCharacteristics.getPreferredCabin(); } /** Get the arrival pattern. */ Modified: trunk/stdair/stdair/bom/DemandStreamKey.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStreamKey.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -7,24 +7,24 @@ namespace stdair { // //////////////////////////////////////////////////////////////////// - DemandStreamKey_T::DemandStreamKey_T () - : _paxType (PassengerType::LAST_VALUE) { + DemandStreamKey_T::DemandStreamKey_T () { } // //////////////////////////////////////////////////////////////////// DemandStreamKey_T::DemandStreamKey_T (const AirportCode_T& iOrigin, const AirportCode_T& iDestination, const Date_T& iPreferredDepartureDate, - const PassengerType& iPaxType) + const CabinCode_T& iPreferredCabin) : _origin (iOrigin), _destination (iDestination), - _preferredDepartureDate (iPreferredDepartureDate), _paxType (iPaxType) { + _preferredDepartureDate (iPreferredDepartureDate), + _preferredCabin (iPreferredCabin) { } // //////////////////////////////////////////////////////////////////// DemandStreamKey_T::DemandStreamKey_T (const DemandStreamKey_T& iKey) : _origin (iKey._origin), _destination (iKey._destination), _preferredDepartureDate (iKey._preferredDepartureDate), - _paxType (iKey._paxType) { + _preferredCabin (iKey._preferredCabin) { } // //////////////////////////////////////////////////////////////////// @@ -44,7 +44,7 @@ const std::string DemandStreamKey_T::toString() const { std::ostringstream oStr; oStr << _origin << "-" << _destination << " " << _preferredDepartureDate - << " " << _paxType; + << " " << _preferredCabin; return oStr.str(); } Modified: trunk/stdair/stdair/bom/DemandStreamKey.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStreamKey.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -6,7 +6,6 @@ // ////////////////////////////////////////////////////////////////////// // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/PassengerType.hpp> #include <stdair/bom/BomKey.hpp> #include <stdair/bom/BomRootKey.hpp> @@ -25,7 +24,7 @@ DemandStreamKey_T (const AirportCode_T& iOrigin, const AirportCode_T& iDestination, const Date_T& iPreferredDepartureDate, - const PassengerType& iPaxType); + const CabinCode_T& iPreferredCabin); DemandStreamKey_T (const DemandStreamKey_T&); /** Destructor. */ @@ -53,9 +52,9 @@ return _preferredDepartureDate; } - /** Get the passenger type. */ - const PassengerType& getPassengerType() const { - return _paxType; + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _preferredCabin; } @@ -89,8 +88,8 @@ /** Preferred departure date */ Date_T _preferredDepartureDate; - /** Passenger type. */ - PassengerType _paxType; + /** Preferred cabin. */ + CabinCode_T _preferredCabin; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2010-02-15 15:20:32
|
Revision: 138 http://stdair.svn.sourceforge.net/stdair/?rev=138&view=rev Author: carobelin Date: 2010-02-15 15:20:23 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [input] Changed pax type to preferred cabin, made the specification of the distribution of number of requests a bit more general Modified Paths: -------------- trunk/stdair/test/samples/README_Demand trunk/stdair/test/samples/demand01.csv Modified: trunk/stdair/test/samples/README_Demand =================================================================== --- trunk/stdair/test/samples/README_Demand 2010-02-15 13:13:27 UTC (rev 137) +++ trunk/stdair/test/samples/README_Demand 2010-02-15 15:20:23 UTC (rev 138) @@ -1,21 +1,30 @@ -preferred departure date: fixed (yymmdd) -origin: fixed -destination: fixed -cabin: fixed -pos: probability mass -channel: probability mass (D=direct, I=indirect, N=oNline, F=oFfline) -trip type: probability mass (RO=outbound of round-trip, RI=inbound of round-trip, OW=one way) -stay duration: probability mass (number of days) -frequent flyer: probability mass (P=Platinum, G=Gold, S=Silver, M=Member, N=None) -preferred departure time: continuous cumulative distribution (hours in decimal form, e.g. 8.5 = 8:30) -wtp: continuous cumulative distribution (moneraty value) -preferred arrival date and time: on va hard-coder celui-là et le mettre égal à preferred departure date and time -value of time: continuous cumulative distribution -arrival pattern: continuous cumulative distribution (dtd as a positive value) - -The main fields are separated by ';'. -Probability mass distributions are defined by comma-separated 'value:probability' pairs -Continuous cumulative distribution are defined by comma-separated 'value:probability' pairs, sorted in increasing order of values. The meaning of probability is P(random variable<=value) = probability. - -100208;SIN;BKK;M;SIN:0.7,BKK:0.2,row:0.1;DF:0.1,DN:0.3,IF:0.4,IN:0.2;RO:0.6,RI:0.2,OW:0.2;0:0.1,1:0.1,2:0.15,3:0.15,4:0.15,5:0.35;P:0.01,G:0.05,S:0.15,M:0.3,N:0.49;6:0,7:0.1,9:0.3,17:0.4,19:0.8,20:0.95,22:1;100:0,500:0.8,2000:1;0;15:0,60:1;330:0,40:0.2,20:0.6,1:1 -100208;SIN;HND;M;SIN:0.5,HND:0.4,row:0.1;DF:0.2,DN:0.2,IF:0.5,IN:0.1;RO:0.5,RI:0.4,OW:0.1;1:0.9,2:0.1;P:0.1,G:0.01,S:0.09,M:0.4,N:0.4;6:0,7:0.1,9:0.8,12:0.9,22:1;300:0,800:0.8,3000:1;0;15:0,60:1;330:0,1:1 +// Demand: +// Fixed: +// Prefered departure date (yyyy-mm-dd) +// Origin (3-char airport code) +// Destination (3-char airport code) +// Preferred cabin ('F' for First, 'C' for Coach/Business, 'Y' for Economy) +// Distribution with Probability Masses: +// POS +// Channel (D=direct, I=indirect, N=oNline, F=oFfline) +// Trip type (RO=outbound of round-trip, RI=inbound of round-trip,OW=one way) +// Stay duration (number of days) +// Frequent flyer (P=Platinum, G=Gold, S=Silver, M=Member, N=None) +// Continuous cumulative distribution: +// Preferred departure time (hh.mm) +// WTP (moneraty value) +// Preferred arrival date (equal to prefered departure date) +// Preferred arrival time (equal to prefered departure time) +// Value of time +// Arrival pattern (DTD as a positive value) +// Distribution of number of requests (distribution and parameters) +// The main fields are separated by ';' +// Probability mass distributions are defined by comma-separated +// 'value:probability' pairs +// Continuous cumulative distribution are defined by comma-separated +// 'value:probability' pairs, sorted in increasing order of values. +// The meaning of probability is P(random variable <= value) = probability. +// The distribution of number of requests is specified using comma-separated values: distribution, parameter1, parameter2, ... For example, normal with mean 10.0 and standard deviation 1.0 is specified as N, 10.0, 1.0 +// +2010-02-08; SIN; BKK; Y; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; N, 10.0, 1.0 +2010-02-08; SIN; HND; Y; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; N, 10.0, 2.0 Modified: trunk/stdair/test/samples/demand01.csv =================================================================== --- trunk/stdair/test/samples/demand01.csv 2010-02-15 13:13:27 UTC (rev 137) +++ trunk/stdair/test/samples/demand01.csv 2010-02-15 15:20:23 UTC (rev 138) @@ -3,10 +3,7 @@ // Prefered departure date (yyyy-mm-dd) // Origin (3-char airport code) // Destination (3-char airport code) -// Passenger type (1-char, e.g., 'L' for Leisure, 'B' for Business) -// Observable: -// Mean -// StdDev +// Preferred cabin ('F' for First, 'C' for Coach/Business, 'Y' for Economy) // Distribution with Probability Masses: // POS // Channel (D=direct, I=indirect, N=oNline, F=oFfline) @@ -20,12 +17,14 @@ // Preferred arrival time (equal to prefered departure time) // Value of time // Arrival pattern (DTD as a positive value) +// Distribution of number of requests (distribution and parameters) // The main fields are separated by ';' // Probability mass distributions are defined by comma-separated // 'value:probability' pairs // Continuous cumulative distribution are defined by comma-separated // 'value:probability' pairs, sorted in increasing order of values. // The meaning of probability is P(random variable <= value) = probability. +// The distribution of number of requests is specified using comma-separated values: distribution, parameter1, parameter2, ... For example, normal with mean 10.0 and standard deviation 1.0 is specified as N, 10.0, 1.0 // -2010-02-08; SIN; BKK; L; 10.0; 1.0; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; -2010-02-08; SIN; HND; L; 10.0; 1.0; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; +2010-02-08; SIN; BKK; Y; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; N, 10.0, 1.0 +2010-02-08; SIN; HND; Y; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; N, 10.0, 2.0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-15 13:13:40
|
Revision: 137 http://stdair.svn.sourceforge.net/stdair/?rev=137&view=rev Author: quannaus Date: 2010-02-15 13:13:27 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [samples] A small change in the schedule for matching the demand. Modified Paths: -------------- trunk/stdair/test/samples/schedule01.csv Modified: trunk/stdair/test/samples/schedule01.csv =================================================================== --- trunk/stdair/test/samples/schedule01.csv 2010-02-15 12:53:32 UTC (rev 136) +++ trunk/stdair/test/samples/schedule01.csv 2010-02-15 13:13:27 UTC (rev 137) @@ -3,6 +3,6 @@ // ElapsedTime; LegCabins; // LegCabins: CabinCode; Capacity; // Segments: Specific; -BA; 117; 2010-01-15; 2010-01-28; 1111100; LHR; JFK; 08:20; 11:00; 07:40; Y; 300; 0; Y; YM; -BA; 117; 2010-01-15; 2010-01-28; 0000011; LHR; JFK; 09:20; 12:00; 07:40; Y; 200; 0; Y; YM; +SQ; 11; 2010-01-15; 2010-02-28; 1111111; SIN; BKK; 08:20; 11:00; 07:40; Y; 300; 0; Y; YM; +SQ; 12; 2010-01-15; 2010-02-28; 1111111; SIN; HND; 09:20; 12:00; 07:40; Y; 200; 0; Y; YM; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-15 12:53:39
|
Revision: 136 http://stdair.svn.sourceforge.net/stdair/?rev=136&view=rev Author: quannaus Date: 2010-02-15 12:53:32 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [dev] Some small changes. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp trunk/stdair/stdair/command/CmdBomManager.cpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -447,5 +447,8 @@ /** Real number */ typedef double RealNumber_T; + + /** Type definition for the hashed key of the DemandStreamKey object. */ + typedef std::string DemandStreamKeyStr_T; } #endif // __STDAIR_STDAIR_TYPES_HPP Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -75,7 +75,7 @@ private: // //////////////////// Attributes ///////////////////// /** DemandStream Key */ - const DemandStreamKey_T& _key; + const DemandStreamKey_T _key; /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 12:53:32 UTC (rev 136) @@ -79,23 +79,13 @@ } // //////////////////////////////////////////////////////////////////// - DemandStreamList_T& BomRoot::getDemandStreamListRef() const { - // TODO: check that the Boost smart pointer is not NULL - STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); - return *_demandStreamList; - } - - // //////////////////////////////////////////////////////////////////// void BomRoot::addDemandStream (const DemandStreamKeyStr_T& iKeyStr, DemandStream& ioDemandStream) { - // TODO: check that the Boost smart pointer is not NULL - STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); - // Insert the reference on the given DemandStream object into the // dedicated list const bool hasInsertBeenSuccessfull = - _demandStreamList->insert (DemandStreamList_T:: - value_type (iKeyStr, &ioDemandStream)).second; + _demandStreamList.insert (DemandStreamList_T:: + value_type (iKeyStr, &ioDemandStream)).second; if (hasInsertBeenSuccessfull == false) { STDAIR_LOG_ERROR ("The DemandStream object with key: " << iKeyStr << " can not be inserted into the dedicated list"); Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -122,13 +122,10 @@ AirlineFeatureSet& getAirlineFeatureSet() const; /** Get the reference of the list of DemandStream objects. */ - DemandStreamListPtr_T getDemandStreamList() const { - return _demandStreamList; + DemandStreamList_T& getDemandStreamList() { + return _demandStreamList; } - /** Get the reference of the list of DemandStream objects. */ - DemandStreamList_T& getDemandStreamListRef() const; - /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). <br>If not existing, return the NULL pointer. */ @@ -147,11 +144,6 @@ _airlineFeatureSet = ioAirlineFeatureSet_ptr; } - /** Set the reference to the DemandStreamList object. */ - void setDemandStreamList (DemandStreamListPtr_T ioDemandStreamList_ptr) { - _demandStreamList = ioDemandStreamList_ptr; - } - /** Add a demand stream object to the dedicated list. @param const DemandStreamKeyStr_T& (String) Key of the DemandStream object to be added. @@ -183,7 +175,7 @@ AirlineFeatureSet* _airlineFeatureSet; /** Set of all DemandStream objects. */ - DemandStreamListPtr_T _demandStreamList; + DemandStreamList_T _demandStreamList; }; } Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -18,6 +18,7 @@ #include <stdair/bom/BookingRequestTypes.hpp> #include <stdair/bom/DemandStreamKey.hpp> #include <stdair/bom/DemandStreamTypes.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -16,13 +16,9 @@ // Forward declaration class DemandStream; - /** Type definition for the hashed key of the DemandStreamKey object. */ - typedef std::string DemandStreamKeyStr_T; /** Define a map of demand strams. */ typedef std::map<const DemandStreamKeyStr_T, DemandStream*> DemandStreamList_T; - /** Type definition for a reference on a list of DemandStream objects. */ - typedef boost::shared_ptr<DemandStreamList_T> DemandStreamListPtr_T; } #endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-15 12:53:32 UTC (rev 136) @@ -11,7 +11,7 @@ // ////////////////////////////////////////////////////////////////////// EventStruct:: EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, - const DemandStreamKey_T& iDemandStreamKey, + const DemandStreamKeyStr_T& iDemandStreamKey, BookingRequestPtr_T ioRequestPtr) : _eventType (iEventType), _eventDateTime (iDateTime), _demandStreamKey (iDemandStreamKey) { @@ -30,7 +30,7 @@ // ////////////////////////////////////////////////////////////////////// EventStruct::EventStruct (const DateTime_T& iDateTime) : _eventType (""), _eventDateTime (iDateTime), - _demandStreamKey ("", "", DEFAULT_DATE, PassengerType::LAST_VALUE) { + _demandStreamKey ("") { } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -33,7 +33,7 @@ } /** Get the demand stream of the event. */ - const DemandStreamKey_T& getDemandStreamKey () const { + const DemandStreamKeyStr_T& getDemandStreamKey () const { return _demandStreamKey; } @@ -45,7 +45,7 @@ // ////////// Constructors and destructors ///////// /** Constructor. */ EventStruct (const EventType_T&, const DateTime_T&, - const DemandStreamKey_T&, BookingRequestPtr_T); + const DemandStreamKeyStr_T&, BookingRequestPtr_T); EventStruct (const DateTime_T&); /** Copy constructor. */ @@ -69,7 +69,7 @@ DateTime_T _eventDateTime; /** The demand stream which generated this event. */ - DemandStreamKey_T _demandStreamKey; + DemandStreamKeyStr_T _demandStreamKey; /** Pointer to Request event */ BookingRequestPtr_T _request; Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-15 12:53:32 UTC (rev 136) @@ -51,12 +51,6 @@ // ////////////////////////////////////////////////////////////////////// void CmdBomManager::initDemandStreamList (BomRoot& ioBomRoot) { - // Initialise the set of required airline features - DemandStreamListPtr_T lDemandStreamList_ptr = - boost::make_shared<DemandStreamList_T>(); - - // Set the AirlineFeatureSet for the BomRoot. - ioBomRoot.setDemandStreamList (lDemandStreamList_ptr); } // ////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 12:35:13
|
Revision: 135 http://stdair.svn.sourceforge.net/stdair/?rev=135&view=rev Author: denis_arnaud Date: 2010-02-15 12:35:06 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Dev] Suppressed the duplicated bom/StructAbstract (as there is already one in the basic layer). Modified Paths: -------------- trunk/stdair/stdair/basic/PassengerType.cpp trunk/stdair/stdair/basic/PassengerType.hpp trunk/stdair/stdair/bom/AirlineStruct.hpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DoWStruct.hpp trunk/stdair/stdair/bom/EventQueue.hpp trunk/stdair/stdair/bom/TravelSolutionStruct.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/command/DBManagerForAirlines.cpp Removed Paths: ------------- trunk/stdair/stdair/bom/StructAbstract.hpp Modified: trunk/stdair/stdair/basic/PassengerType.cpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.cpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/basic/PassengerType.cpp 2010-02-15 12:35:06 UTC (rev 135) @@ -47,11 +47,18 @@ } // ////////////////////////////////////////////////////////////////////// - char PassengerType::getTypeLabel(const EN_PassengerType& iType) { + char PassengerType::getTypeLabel (const EN_PassengerType& iType) { return _typeLabels[iType]; } // ////////////////////////////////////////////////////////////////////// + std::string PassengerType::getTypeLabelAsString(const EN_PassengerType& iType){ + std::ostringstream oStr; + oStr << _typeLabels[iType]; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// std::string PassengerType::describeLabels() { std::ostringstream ostr; for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) { @@ -69,10 +76,22 @@ } // ////////////////////////////////////////////////////////////////////// + std::string PassengerType::getTypeAsString() const { + std::ostringstream oStr; + oStr << _typeLabels[_type]; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// const std::string PassengerType::describe() const { std::ostringstream ostr; ostr << _labels[_type]; return ostr.str(); } + // ////////////////////////////////////////////////////////////////////// + bool PassengerType::operator== (const EN_PassengerType& iType) const { + return (_type == iType); + } + } Modified: trunk/stdair/stdair/basic/PassengerType.hpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/basic/PassengerType.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -7,7 +7,7 @@ // STL #include <string> // StdAir -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> namespace stdair { @@ -21,21 +21,30 @@ LAST_VALUE } EN_PassengerType; - /** Get the label as a string. */ + /** Get the label as a string (e.g., "Leisure" or "Business"). */ static const std::string& getLabel (const EN_PassengerType&); - /** Get the label as a single char. */ + /** Get the label as a single char (e.g., 'L' or 'B'). */ static char getTypeLabel (const EN_PassengerType&); + /** Get the label as a single char (e.g., 'L' or 'B'). */ + static std::string getTypeLabelAsString (const EN_PassengerType&); + /** List the labels. */ static std::string describeLabels(); /** Get the enumerated value. */ EN_PassengerType getType() const; - /** Give a description of the structure (for display purposes). */ + /** Get the enumerated value as a short string (e.g., 'L' or 'B'). */ + std::string getTypeAsString() const; + + /** Give a description of the structure (e.g., "Leisure" or "Business"). */ const std::string describe() const; + public: + /** Comparison operator. */ + bool operator== (const EN_PassengerType&) const; public: /** Constructor. */ Modified: trunk/stdair/stdair/bom/AirlineStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -10,7 +10,7 @@ #include <vector> // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -9,8 +9,8 @@ #include <string> // StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/StructAbstract.hpp> #include <stdair/basic/PassengerType.hpp> -#include <stdair/bom/StructAbstract.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/DoWStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/DoWStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/DoWStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -8,7 +8,7 @@ #include <string> #include <vector> // STDAIR -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/EventQueue.hpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -4,9 +4,11 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// STDAIR +// STL +#include <iosfwd> +// StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> #include <stdair/bom/EventTypes.hpp> namespace stdair { Deleted: trunk/stdair/stdair/bom/StructAbstract.hpp =================================================================== --- trunk/stdair/stdair/bom/StructAbstract.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/StructAbstract.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -1,83 +0,0 @@ -#ifndef __STDAIR_BOM_STRUCTABSTRACT_HPP -#define __STDAIR_BOM_STRUCTABSTRACT_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <iosfwd> - -namespace stdair { - - /** Base class for the Structures of the Business Object Model (BOM) - layer. */ - struct StructAbstract { - public: - - /** Destructor. */ - virtual ~StructAbstract() {} - - /** Dump a Business Object into an output stream. - @param ostream& the output stream. */ - void toStream (std::ostream& ioOut) const { - ioOut << describe(); - } - - /** Read a Business Object from an input stream. - @param istream& the input stream. */ - virtual void fromStream (std::istream& ioIn) {} - - /** Display of the structure. */ - virtual const std::string describe() const = 0; - - protected: - /** Protected Default Constructor to ensure this class is abtract. */ - StructAbstract() {} - }; -} - -/** - Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing - Output Operators" (p653) of his book "The C++ Standard Library: A Tutorial - and Reference", published by Addison-Wesley. -*/ -template <class charT, class traits> -inline -std::basic_ostream<charT, traits>& -operator<< (std::basic_ostream<charT, traits>& ioOut, - const stdair::StructAbstract& iStruct) { - /** - string stream: - - with same format - - without special field width - */ - std::basic_ostringstream<charT,traits> ostr; - ostr.copyfmt (ioOut); - ostr.width (0); - - // Fill string stream - iStruct.toStream (ostr); - - // Print string stream - ioOut << ostr.str(); - - return ioOut; -} - -/** - Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing - Output Operators" (pp655-657) of his book "The C++ Standard Library: - A Tutorial and Reference", published by Addison-Wesley. -*/ -template <class charT, class traits> -inline -std::basic_istream<charT, traits>& -operator>> (std::basic_istream<charT, traits>& ioIn, - stdair::StructAbstract& ioStruct) { - // Fill the Structure object with the input stream. - ioStruct.fromStream (ioIn); - return ioIn; - -} - -#endif // __STDAIR_BOM_STRUCTABSTRACT_HPP Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -9,7 +9,7 @@ #include <string> #include <vector> // StdAir -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> #include <stdair/bom/BookingClassTypes.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-15 12:35:06 UTC (rev 135) @@ -1,5 +1,4 @@ bom_h_sources = \ - $(top_srcdir)/stdair/bom/StructAbstract.hpp \ $(top_srcdir)/stdair/bom/BomList.hpp \ $(top_srcdir)/stdair/bom/BomMap.hpp \ $(top_srcdir)/stdair/bom/BomKey.hpp \ Modified: trunk/stdair/stdair/command/DBManagerForAirlines.cpp =================================================================== --- trunk/stdair/stdair/command/DBManagerForAirlines.cpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/command/DBManagerForAirlines.cpp 2010-02-15 12:35:06 UTC (rev 135) @@ -143,14 +143,14 @@ prepareSelectOnAirlineCodeStatement (ioSociSession, lSelectStatement, iAirlineCode, ioAirline); - const bool shouldDoReset = true; + // const bool shouldDoReset = true; bool hasStillData = iterateOnStatement (lSelectStatement, ioAirline); if (hasStillData == true) { oHasRetrievedAirline = true; } // Sanity check - const bool shouldNotDoReset = false; + // const bool shouldNotDoReset = false; hasStillData = iterateOnStatement (lSelectStatement, ioAirline); // Debug This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 01:22:32
|
Revision: 134 http://stdair.svn.sourceforge.net/stdair/?rev=134&view=rev Author: denis_arnaud Date: 2010-02-15 01:22:24 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Demand] Added support for Demand-related object creation from the new demand input file parser. Modified Paths: -------------- trunk/stdair/test/samples/demand01.csv Modified: trunk/stdair/test/samples/demand01.csv =================================================================== --- trunk/stdair/test/samples/demand01.csv 2010-02-15 01:20:27 UTC (rev 133) +++ trunk/stdair/test/samples/demand01.csv 2010-02-15 01:22:24 UTC (rev 134) @@ -3,7 +3,7 @@ // Prefered departure date (yyyy-mm-dd) // Origin (3-char airport code) // Destination (3-char airport code) -// Cabin (1-char cabin code) +// Passenger type (1-char, e.g., 'L' for Leisure, 'B' for Business) // Observable: // Mean // StdDev @@ -27,5 +27,5 @@ // 'value:probability' pairs, sorted in increasing order of values. // The meaning of probability is P(random variable <= value) = probability. // -2010-02-08; SIN; BKK; M; 10.0; 1.0; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; -2010-02-08; SIN; HND; M; 10.0; 1.0; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; +2010-02-08; SIN; BKK; L; 10.0; 1.0; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; +2010-02-08; SIN; HND; L; 10.0; 1.0; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 01:20:35
|
Revision: 133 http://stdair.svn.sourceforge.net/stdair/?rev=133&view=rev Author: denis_arnaud Date: 2010-02-15 01:20:27 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Demand] Added support for Demand-related object creation from the new demand input file parser. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/ContinuousAttribute.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/basic/DemandDistribution.cpp trunk/stdair/stdair/basic/DemandDistribution.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp trunk/stdair/stdair/bom/InventoryKey.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/command/CmdBomManager.cpp trunk/stdair/stdair/command/CmdBomManager.hpp trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Added Paths: ----------- trunk/stdair/stdair/basic/ArrivalPattern.hpp trunk/stdair/stdair/basic/PassengerType.cpp trunk/stdair/stdair/basic/PassengerType.hpp trunk/stdair/stdair/bom/DemandStreamKey.cpp trunk/stdair/stdair/bom/DemandStreamKey.hpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -97,6 +97,10 @@ BomRoot. */ void initAirlineFeatureSet (); + /** Initialise the DemandStreamList object, and attach it to the + BomRoot. */ + void initDemandStreamList (); + /** Finalise. */ void finalise (); Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -47,6 +47,15 @@ class MemoryAllocationException : public RootException { }; + class ParserException : public RootException { + }; + + class CodeConversionException : public ParserException { + }; + + class CodeDuplicationException : public ParserException { + }; + class ObjectNotFoundException : public RootException { }; @@ -438,9 +447,5 @@ /** Real number */ typedef double RealNumber_T; - - // ////////////////////////////////////////////////////////////////////// - // Demand - typedef int DemandStreamKey_T; } #endif // __STDAIR_STDAIR_TYPES_HPP Added: trunk/stdair/stdair/basic/ArrivalPattern.hpp =================================================================== --- trunk/stdair/stdair/basic/ArrivalPattern.hpp (rev 0) +++ trunk/stdair/stdair/basic/ArrivalPattern.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,27 @@ +#ifndef __STDAIR_BAS_ARRIVALPATTERN_HPP +#define __STDAIR_BAS_ARRIVALPATTERN_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> + +namespace stdair { + + /** Type definition for the continuous distribition of the duration + (as a float number). */ + typedef ContinuousAttribute<FloatDuration_T> ContinuousFloatDuration_T; + + /** Type definition for the arrival pattern. */ + typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPattern_T; + + /** Type definition for the arrival pattern cumulative distribution. */ + typedef std::multimap<FloatDuration_T, Probability_T> ArrivalPatternCumulativeDistribution_T; + + /** Type definition for the arrival pattern inverse cumulative distribution. */ + typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; + +} +#endif // __STDAIR_BAS_ARRIVALPATTERN_HPP Modified: trunk/stdair/stdair/basic/ContinuousAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -9,6 +9,7 @@ #include <map> // STDAIR #include <stdair/STDAIR_Types.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { @@ -17,22 +18,28 @@ template <class T> struct ContinuousAttribute { public: + + // ///////////// Type definitions ////////////// + /** */ + typedef std::multimap<T, Probability_T> ContinuousDistribution_T; + typedef std::multimap<Probability_T, T> ContinuousInverseDistribution_T; + + // ///////////// Getters /////////// /** Get the cumulative distribution. */ - const std::multimap<T,Probability_T>& getCumulativeDistribution() const { + const ContinuousDistribution_T& getCumulativeDistribution() const { return _cumulativeDistribution; } /** Get the inverse cumulative distribution. */ - const std::multimap<Probability_T, T>& - getInverseCumulativeDistribution () const { + const ContinuousInverseDistribution_T& getInverseCumulativeDistribution () const { return _inverseCumulativeDistribution; } public: // ///////////// Setters /////////// /** Set the cumulative distribution */ - void setCumulativeDistribution (const std::multimap<T, Probability_T>& iCumulativeDistribution) { + void setCumulativeDistribution (const ContinuousDistribution_T& iCumulativeDistribution) { _cumulativeDistribution = iCumulativeDistribution; determineInverseCumulativeDistributionFromCumulativeDistribution(); } @@ -40,15 +47,15 @@ public: // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ - const T getValue(const Probability_T& iCumulativeProbability) const { - typename std::multimap<Probability_T, T>::const_iterator it = + const T getValue (const Probability_T& iCumulativeProbability) const { + typename ContinuousDistribution_T::const_iterator it = _inverseCumulativeDistribution.lower_bound (iCumulativeProbability); Probability_T cumulativeProbabilityNextPoint = it->first; T valueNextPoint = it->second; if (it == _inverseCumulativeDistribution.begin()) { - std::cout << "hello" << std::endl; + STDAIR_LOG_DEBUG ("Last element"); return valueNextPoint; } --it; @@ -75,11 +82,14 @@ /** Display cumulative distribution */ std::string displayCumulativeDistribution() const { std::ostringstream oStr; - for (typename std::multimap<T, Probability_T>::const_iterator it = + unsigned int idx = 0; + for (typename ContinuousDistribution_T::const_iterator it = _cumulativeDistribution.begin(); - it != _cumulativeDistribution.end(); ++it) { - oStr << "value: " << it->first - << " cumulative probability: " << it->second << std::endl; + it != _cumulativeDistribution.end(); ++it, ++idx) { + if (idx != 0) { + oStr << ", "; + } + oStr << it->first << ":" << it->second; } return oStr.str(); } @@ -87,7 +97,7 @@ /** Display inverse cumulative distribution */ std::string displayInverseCumulativeDistribution() const { std::ostringstream oStr; - for (typename std::multimap<Probability_T, T>::const_iterator it = + for (typename ContinuousInverseDistribution_T::const_iterator it = _inverseCumulativeDistribution.begin(); it != _inverseCumulativeDistribution.end(); ++it) { oStr << "cumulative prob: " << it->first @@ -102,7 +112,8 @@ ContinuousAttribute () { } /** Constructor */ - ContinuousAttribute (const std::multimap<T, Probability_T>& iCumulativeDistribution) : _cumulativeDistribution (iCumulativeDistribution) { + ContinuousAttribute (const ContinuousDistribution_T& iCumulativeDistribution) + : _cumulativeDistribution (iCumulativeDistribution) { determineInverseCumulativeDistributionFromCumulativeDistribution(); } @@ -118,13 +129,13 @@ /** Determine inverse cumulative distribution from cumulative distribution (initialisation). */ void determineInverseCumulativeDistributionFromCumulativeDistribution () { - for (typename std::multimap<T, Probability_T>::iterator itCumulativeDistribution = + for (typename ContinuousDistribution_T::iterator itCumulativeDistribution = _cumulativeDistribution.begin(); itCumulativeDistribution != _cumulativeDistribution.end(); ++itCumulativeDistribution) { _inverseCumulativeDistribution. - insert ( std::pair<float, float> (itCumulativeDistribution->second, - itCumulativeDistribution->first) ); + insert (std::pair<float, float> (itCumulativeDistribution->second, + itCumulativeDistribution->first)); } } @@ -132,11 +143,10 @@ // ////////// Attributes ////////// /** Cumulative distribution */ - std::multimap<T, Probability_T> _cumulativeDistribution; + ContinuousDistribution_T _cumulativeDistribution; /** Inverse cumulative distribution */ - std::multimap<Probability_T, T> _inverseCumulativeDistribution; - + ContinuousInverseDistribution_T _inverseCumulativeDistribution; }; } Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -4,15 +4,21 @@ // STL #include <cassert> #include <sstream> -// STDAIR +// StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasConst_General.hpp> #include <stdair/basic/DemandCharacteristics.hpp> namespace stdair { // ///////////////////////////////////////////////////// + DemandCharacteristics::DemandCharacteristics (const DemandStreamKey_T& iKey) + : _key (iKey) { + } + + // ///////////////////////////////////////////////////// DemandCharacteristics::DemandCharacteristics () - : _origin ("") { + : _key (DemandStreamKey_T("", "", DEFAULT_DATE, PassengerType::LAST_VALUE)) { } // ///////////////////////////////////////////////////// @@ -22,28 +28,49 @@ // ///////////////////////////////////////////////////// DemandCharacteristics:: DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) - : _origin (iDemandCharacteristics._origin), - _destination (iDemandCharacteristics._destination), - _preferredDepartureDate (iDemandCharacteristics._preferredDepartureDate), - _paxType (iDemandCharacteristics._paxType), + : _key (iDemandCharacteristics._key), _arrivalPattern (iDemandCharacteristics._arrivalPattern) { } // ///////////////////////////////////////////////////// + const AirportCode_T& DemandCharacteristics::getOrigin() const { + return _key.getOrigin(); + } + + // ///////////////////////////////////////////////////// + const AirportCode_T& DemandCharacteristics::getDestination() const { + return _key.getDestination(); + } + + // ///////////////////////////////////////////////////// + const Date_T& DemandCharacteristics::getPreferredDepartureDate() const { + return _key.getPreferredDepartureDate(); + } + + // ///////////////////////////////////////////////////// + const PassengerType& DemandCharacteristics::getPaxType() const { + return _key.getPassengerType(); + } + + // ///////////////////////////////////////////////////// std::string DemandCharacteristics::display() const { std::ostringstream oStr; // - oStr << "****************** Demand characteristics ******************"; - oStr << "Origin ........................... : " - << _origin << std::endl; + oStr << "****************** Demand characteristics ******************" + << std::endl; + oStr << "Origin ........................... : " << _key.getOrigin() + << std::endl; + oStr << "Destination ...................... : " << _key.getDestination() + << std::endl; oStr << "Preferred departure date ......... : " - << _preferredDepartureDate << std::endl; - oStr << "Arrival pattern (days from departure, proportion):" - << std::endl; + << _key.getPreferredDepartureDate() << std::endl; + oStr << "Passenger type ................... : " << _key.getPassengerType() + << std::endl; + oStr << "Arrival pattern (days from departure, proportion): "; // - oStr << _arrivalPattern.displayCumulativeDistribution(); + oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; return oStr.str(); } Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -6,9 +6,10 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <string> -// STDAIR +// StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/ContinuousAttribute.hpp> +#include <stdair/basic/ArrivalPattern.hpp> +#include <stdair/bom/DemandStreamKey.hpp> namespace stdair { @@ -17,58 +18,37 @@ public: // ///////////// Getters /////////// - /** Get the origin. */ - const AirportCode_T& getOrigin() const { - return _origin; + /** Get the key. */ + const DemandStreamKey_T& getKey() const { + return _key; } + /** Get the origin. */ + const AirportCode_T& getOrigin() const; + /** Get the destination. */ - const AirportCode_T& getDestination() const { - return _destination; - } + const AirportCode_T& getDestination() const; /** Get the preferred departure date. */ - const Date_T& getPreferredDepartureDate() const { - return _preferredDepartureDate; - } + const Date_T& getPreferredDepartureDate() const; /** Get the passenger type. */ - const PassengerType_T& getPaxType() const { - return _paxType; - } + const PassengerType& getPaxType() const; /** Get the arrival pattern. */ - const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + const ContinuousFloatDuration_T& getArrivalPattern() const { return _arrivalPattern; } + public: // ///////////// Setters /////////// - /** Set the origin. */ - void setOrigin (const AirportCode_T& iOrigin) { - _origin = iOrigin; - } - - /** Set the destination. */ - void setDestination (const AirportCode_T& iDestination) { - _destination = iDestination; - } - - /** Set the preferred departure date. */ - void setPreferredDepartureDate (const Date_T& iPreferredDepartureDate) { - _preferredDepartureDate = iPreferredDepartureDate; - } - - /** Set the passenger type. */ - void setPaxType (const PassengerType_T& iPaxType) { - _paxType = iPaxType; - } - /** Set the arrival pattern. */ - void setArrivalPattern (const ContinuousAttribute<FloatDuration_T>& iArrivalPattern) { + void setArrivalPattern (const ContinuousFloatDuration_T& iArrivalPattern) { _arrivalPattern = iArrivalPattern; } + public: // ////////////// Display Support Methods ////////// /** Display demand characteristics */ @@ -77,34 +57,30 @@ public: // ////////// Constructors and destructors ///////// - /** Constructor by default */ + /** Default constructor. */ + DemandCharacteristics (const DemandStreamKey_T& iKey); + + /** Default constructor. */ + // TODO: That copy constructor should be private DemandCharacteristics (); - /** Copy constructor */ - DemandCharacteristics (const DemandCharacteristics&); // Should be private, but well... + /** Copy constructor. */ + // TODO: That copy constructor should be private + DemandCharacteristics (const DemandCharacteristics&); /** Destructor */ virtual ~DemandCharacteristics (); - + private: - // ////////// Attributes ////////// - /** Origin */ - AirportCode_T _origin; + // //////////////////// Attributes ///////////////////// + /** DemandStream Key */ + const DemandStreamKey_T& _key; - /** Origin */ - AirportCode_T _destination; - - /** Preferred departure date */ - Date_T _preferredDepartureDate; - - /** Passenger type. */ - PassengerType_T _paxType; - /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date - and request date)*/ - ContinuousAttribute<FloatDuration_T> _arrivalPattern; + and request date). */ + ContinuousFloatDuration_T _arrivalPattern; /** Trip type probability mass */ // CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; Modified: trunk/stdair/stdair/basic/DemandDistribution.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandDistribution.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -9,6 +9,14 @@ #include <stdair/basic/DemandDistribution.hpp> namespace stdair { + + // ///////////////////////////////////////////////////// + DemandDistribution:: + DemandDistribution (const NbOfRequests_T& iMean, + const StandardDeviationValue_T& iStandardDeviation) + : _meanNumberOfRequests (iMean), + _standardDeviationNumberOfRequests (iStandardDeviation){ + } // ///////////////////////////////////////////////////// DemandDistribution::DemandDistribution () { @@ -20,10 +28,9 @@ // ///////////////////////////////////////////////////// DemandDistribution:: - DemandDistribution (const DemandDistribution& iDemandDistribution) { - _meanNumberOfRequests = iDemandDistribution._meanNumberOfRequests; - _standardDeviationNumberOfRequests = - iDemandDistribution._standardDeviationNumberOfRequests; + DemandDistribution (const DemandDistribution& iDemandDistribution) + : _meanNumberOfRequests (iDemandDistribution._meanNumberOfRequests), + _standardDeviationNumberOfRequests (iDemandDistribution._standardDeviationNumberOfRequests) { } // ///////////////////////////////////////////////////// @@ -31,11 +38,11 @@ std::ostringstream oStr; oStr << "****************** Demand distribution ******************" - << std::endl; + << std::endl; oStr << "Mean number of requests .......... : " - << _meanNumberOfRequests << std::endl; + << _meanNumberOfRequests << std::endl; oStr << "Std dev of number of requests .... : " - << _standardDeviationNumberOfRequests << std::endl; + << _standardDeviationNumberOfRequests << std::endl; return oStr.str(); } Modified: trunk/stdair/stdair/basic/DemandDistribution.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandDistribution.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -18,24 +18,24 @@ // ///////////// Getters /////////// /** Get the mean number of requests. */ - const RealNumber_T& getMeanNumberOfRequests() const { + const NbOfRequests_T& getMeanNumberOfRequests() const { return _meanNumberOfRequests; } /** Get the standard deviation of number of requests. */ - const RealNumber_T& getStandardDeviationNumberOfRequests() const { + const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { return _standardDeviationNumberOfRequests; } public: // ///////////// Setters /////////// /** Set the mean number of requests. */ - void setMeanNumberOfRequests (const RealNumber_T& iMean) { + void setMeanNumberOfRequests (const NbOfRequests_T& iMean) { _meanNumberOfRequests = iMean; } /** Set the standard deviation of number of requests. */ - void setStandardDeviationNumberOfRequests (const RealNumber_T& iStandardDeviation) { + void setStandardDeviationNumberOfRequests (const StandardDeviationValue_T& iStandardDeviation) { _standardDeviationNumberOfRequests = iStandardDeviation; } @@ -47,23 +47,29 @@ public: // ////////// Constructors and destructors ///////// - /** Constructor by default */ + /** Constructor. */ + DemandDistribution (const NbOfRequests_T& iMean, + const StandardDeviationValue_T& iStandardDeviation); + + /** Default constructor. */ + // TODO: That constructor should be private DemandDistribution (); - /** Copy constructor */ - DemandDistribution (const DemandDistribution&); // Should be private, but well... + /** Copy constructor. */ + // TODO: That constructor should be private + DemandDistribution (const DemandDistribution&); - /** Destructor */ + /** Destructor. */ virtual ~DemandDistribution (); - - + + private: // ////////// Attributes ////////// /** Mean number of requests */ - RealNumber_T _meanNumberOfRequests; + NbOfRequests_T _meanNumberOfRequests; /** Standard deviation of number of requests */ - RealNumber_T _standardDeviationNumberOfRequests; + StandardDeviationValue_T _standardDeviationNumberOfRequests; }; } Added: trunk/stdair/stdair/basic/PassengerType.cpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.cpp (rev 0) +++ trunk/stdair/stdair/basic/PassengerType.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,78 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <sstream> +// StdAir +#include <stdair/service/Logger.hpp> +// Stdair +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/PassengerType.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + const std::string PassengerType::_labels[LAST_VALUE] = + { "Leisure", "Business", "First" }; + + const char PassengerType::_typeLabels[LAST_VALUE] = { 'L', 'B', 'F' }; + + + // ////////////////////////////////////////////////////////////////////// + PassengerType::PassengerType (const EN_PassengerType& iPassengerType) + : _type (iPassengerType) { + } + + // ////////////////////////////////////////////////////////////////////// + PassengerType::PassengerType (const char iType) { + switch (iType) { + case 'L': _type = LEISURE; break; + case 'B': _type = BUSINESS; break; + case 'F': _type = FIRST; break; + default: _type = LAST_VALUE; break; + } + + if (_type == LAST_VALUE) { + const std::string& lLabels = describeLabels(); + STDAIR_LOG_ERROR ("The passenger type '" << iType + << "' is not known. Known passenger types: " << lLabels); + throw CodeConversionException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + const std::string& PassengerType::getLabel (const EN_PassengerType& iType) { + return _labels[iType]; + } + + // ////////////////////////////////////////////////////////////////////// + char PassengerType::getTypeLabel(const EN_PassengerType& iType) { + return _typeLabels[iType]; + } + + // ////////////////////////////////////////////////////////////////////// + std::string PassengerType::describeLabels() { + std::ostringstream ostr; + for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) { + if (idx != 0) { + ostr << ", "; + } + ostr << _labels[idx]; + } + return ostr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + PassengerType::EN_PassengerType PassengerType::getType() const { + return _type; + } + + // ////////////////////////////////////////////////////////////////////// + const std::string PassengerType::describe() const { + std::ostringstream ostr; + ostr << _labels[_type]; + return ostr.str(); + } + +} Added: trunk/stdair/stdair/basic/PassengerType.hpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.hpp (rev 0) +++ trunk/stdair/stdair/basic/PassengerType.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,61 @@ +#ifndef __STDAIR_BAS_PASSENGERTYPE_HPP +#define __STDAIR_BAS_PASSENGERTYPE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// StdAir +#include <stdair/bom/StructAbstract.hpp> + +namespace stdair { + + /** Enumeration of Frequent Flyer types. */ + struct PassengerType : public StructAbstract { + public: + typedef enum { + LEISURE = 0, + BUSINESS, + FIRST, + LAST_VALUE + } EN_PassengerType; + + /** Get the label as a string. */ + static const std::string& getLabel (const EN_PassengerType&); + + /** Get the label as a single char. */ + static char getTypeLabel (const EN_PassengerType&); + + /** List the labels. */ + static std::string describeLabels(); + + /** Get the enumerated value. */ + EN_PassengerType getType() const; + + /** Give a description of the structure (for display purposes). */ + const std::string describe() const; + + + public: + /** Constructor. */ + PassengerType (const EN_PassengerType&); + /** Constructor. */ + PassengerType (const char iType); + + + private: + /** String version of the enumeration. */ + static const std::string _labels[LAST_VALUE]; + /** Type version of the enumeration. */ + static const char _typeLabels[LAST_VALUE]; + + + private: + // //////// Attributes ///////// + /** Frequent flyer type. */ + EN_PassengerType _type; + }; + +} +#endif // __STDAIR_BAS_PASSENGERTYPE_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/sources.mk 2010-02-15 01:20:27 UTC (rev 133) @@ -11,7 +11,9 @@ $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ $(top_srcdir)/stdair/basic/BasLogParams.hpp \ $(top_srcdir)/stdair/basic/BasDBParams.hpp \ + $(top_srcdir)/stdair/basic/PassengerType.hpp \ $(top_srcdir)/stdair/basic/ContinuousAttribute.hpp \ + $(top_srcdir)/stdair/basic/ArrivalPattern.hpp \ $(top_srcdir)/stdair/basic/CategoricalAttribute.hpp \ $(top_srcdir)/stdair/basic/DemandCharacteristics.hpp \ $(top_srcdir)/stdair/basic/DemandDistribution.hpp \ @@ -23,6 +25,7 @@ $(top_srcdir)/stdair/basic/BasFileMgr.cpp \ $(top_srcdir)/stdair/basic/BasLogParams.cpp \ $(top_srcdir)/stdair/basic/BasDBParams.cpp \ + $(top_srcdir)/stdair/basic/PassengerType.cpp \ $(top_srcdir)/stdair/basic/DemandCharacteristics.cpp \ $(top_srcdir)/stdair/basic/DemandDistribution.cpp \ $(top_srcdir)/stdair/basic/RandomGeneration.cpp \ Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -10,6 +10,8 @@ #include <stdair/bom/BomMap.hpp> #include <stdair/bom/Inventory.hpp> #include <stdair/bom/Network.hpp> +#include <stdair/bom/DemandStream.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { @@ -75,5 +77,31 @@ assert (_airlineFeatureSet != NULL); return *_airlineFeatureSet; } + + // //////////////////////////////////////////////////////////////////// + DemandStreamList_T& BomRoot::getDemandStreamListRef() const { + // TODO: check that the Boost smart pointer is not NULL + STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); + return *_demandStreamList; + } + // //////////////////////////////////////////////////////////////////// + void BomRoot::addDemandStream (const DemandStreamKeyStr_T& iKeyStr, + DemandStream& ioDemandStream) { + // TODO: check that the Boost smart pointer is not NULL + STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); + + // Insert the reference on the given DemandStream object into the + // dedicated list + const bool hasInsertBeenSuccessfull = + _demandStreamList->insert (DemandStreamList_T:: + value_type (iKeyStr, &ioDemandStream)).second; + if (hasInsertBeenSuccessfull == false) { + STDAIR_LOG_ERROR ("The DemandStream object with key: " << iKeyStr + << " can not be inserted into the dedicated list"); + STDAIR_LOG_ERROR ("DemandStream object: " << ioDemandStream); + assert (false); + } + } + } Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -12,6 +12,7 @@ #include <stdair/bom/BomRootTypes.hpp> #include <stdair/bom/InventoryTypes.hpp> #include <stdair/bom/NetworkTypes.hpp> +#include <stdair/bom/DemandStreamTypes.hpp> namespace stdair { // Forward declarations. @@ -102,6 +103,7 @@ at the same level). */ const std::string describeShortKey() const { return std::string (""); } + public: // /////////// Getters ///////////// /** Get a InventoryList_T for iteration methods. */ @@ -119,6 +121,14 @@ /** Get the reference of the AirlineFeatureSet object. */ AirlineFeatureSet& getAirlineFeatureSet() const; + /** Get the reference of the list of DemandStream objects. */ + DemandStreamListPtr_T getDemandStreamList() const { + return _demandStreamList; + } + + /** Get the reference of the list of DemandStream objects. */ + DemandStreamList_T& getDemandStreamListRef() const; + /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). <br>If not existing, return the NULL pointer. */ @@ -128,6 +138,7 @@ given airline code (Network key). <br>If not existing, return the NULL pointer. */ Network* getNetwork (const NetworkID_T&) const; + public: // //////////// Setters ////////////// @@ -136,6 +147,17 @@ _airlineFeatureSet = ioAirlineFeatureSet_ptr; } + /** Set the reference to the DemandStreamList object. */ + void setDemandStreamList (DemandStreamListPtr_T ioDemandStreamList_ptr) { + _demandStreamList = ioDemandStreamList_ptr; + } + + /** Add a demand stream object to the dedicated list. + @param const DemandStreamKeyStr_T& (String) Key of the DemandStream + object to be added. + @param DemandStreamList_T& List of DemandStream objects. */ + void addDemandStream (const DemandStreamKeyStr_T&, DemandStream&); + private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { @@ -157,8 +179,11 @@ /** Reference structure. */ BomStructure_T& _bomRootStructure; - /** Set of all AirlineFeatures.*/ + /** Set of all AirlineFeatures. */ AirlineFeatureSet* _airlineFeatureSet; + + /** Set of all DemandStream objects. */ + DemandStreamListPtr_T _demandStreamList; }; } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -16,7 +16,7 @@ const AirportCode_T& iDestination, const Date_T& iDepartureDate, const DateTime_T& iRequestDateTime, - const PassengerType_T& iPaxType, + const PassengerType& iPaxType, const NbOfSeats_T& iPartySize) : _origin (iOrigin), _destination (iDestination), _preferredDepartureDate (iDepartureDate), Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -8,14 +8,14 @@ #include <iosfwd> #include <string> // StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/PassengerType.hpp> #include <stdair/bom/StructAbstract.hpp> -#include <stdair/STDAIR_Types.hpp> namespace stdair { /** Structure holding the elements of a booking request. */ struct BookingRequestStruct : public StructAbstract { - public: // /////////////// Getters ///////////////// /** Get the requested origin. */ @@ -39,7 +39,7 @@ } /** Get the passenger type. */ - const PassengerType_T& getPaxType() const { + const PassengerType& getPaxType() const { return _paxType; } @@ -71,7 +71,7 @@ } /** Set the passenger type. */ - void setPaxType (const PassengerType_T& iPaxType) { + void setPaxType (const PassengerType& iPaxType) { _paxType = iPaxType; } @@ -93,15 +93,20 @@ /** Display of the structure. */ const std::string describe() const; + // /////////////// Constructors and Destructors ///////////////// public : + /** Constructor. */ BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, - const PassengerType_T&, const NbOfSeats_T&); + const PassengerType&, const NbOfSeats_T&); public : + /** Default constructor. */ BookingRequestStruct (); + /** Copy constructor. */ BookingRequestStruct (const BookingRequestStruct&); public: + /** Destructor. */ ~BookingRequestStruct(); @@ -120,7 +125,7 @@ DateTime_T _requestDateTime; /** Passenger type. */ - PassengerType_T _paxType; + PassengerType _paxType; /** Party size. */ NbOfSeats_T _partySize; Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -47,19 +47,22 @@ // ////////////////////////////////////////////////////////////////////// void DemandStream::init() { // Generate the number of requests - const RealNumber_T lMu = - _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); const RealNumber_T lSigma = _demandDistribution.getStandardDeviationNumberOfRequests (); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); - Count_T lIntegerNumberOfRequestsToBeGenerated = 0; + + NbOfRequests_T lIntegerNumberOfRequestsToBeGenerated = 0; if (lRealNumberOfRequestsToBeGenerated < 0.5) { lIntegerNumberOfRequestsToBeGenerated = 0; + } else { - lIntegerNumberOfRequestsToBeGenerated = - static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + lIntegerNumberOfRequestsToBeGenerated = + static_cast<NbOfRequests_T> (lRealNumberOfRequestsToBeGenerated + 0.5); } + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; } Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -16,6 +16,7 @@ #include <stdair/basic/RandomGenerationContext.hpp> #include <stdair/bom/BomContent.hpp> #include <stdair/bom/BookingRequestTypes.hpp> +#include <stdair/bom/DemandStreamKey.hpp> #include <stdair/bom/DemandStreamTypes.hpp> namespace stdair { @@ -32,7 +33,7 @@ } /** Get the total number of requests to be generated. */ - const Count_T& getTotalNumberOfRequestsToBeGenerated() const { + const NbOfRequests_T& getTotalNumberOfRequestsToBeGenerated() const { return _totalNumberOfRequestsToBeGenerated; } @@ -52,22 +53,22 @@ } /** Get the passenger type. */ - const PassengerType_T& getPaxType() const { + const PassengerType& getPaxType() const { return _demandCharacteristics.getPaxType(); } /** Get the arrival pattern. */ - const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + const ContinuousFloatDuration_T& getArrivalPattern() const { return _demandCharacteristics.getArrivalPattern(); } /** Get the mean number of requests. */ - const RealNumber_T& getMeanNumberOfRequests() const { + const NbOfRequests_T& getMeanNumberOfRequests() const { return _demandDistribution.getMeanNumberOfRequests(); } /** Get the standard deviation of number of requests. */ - const RealNumber_T& getStandardDeviationNumberOfRequests() const { + const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { return _demandDistribution.getStandardDeviationNumberOfRequests(); } @@ -185,10 +186,11 @@ protected: // ////////// Constructors and destructors ///////// /** Constructor by default */ - DemandStream (const DemandStreamKey_T&, - const DemandCharacteristics&, - const DemandDistribution&, const RandomSeed_T&, - const RandomSeed_T&, const RandomSeed_T&); + DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, + const DemandDistribution&, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed); /** Default constructors. */ DemandStream (); DemandStream (const DemandStream&); @@ -210,7 +212,7 @@ DemandDistribution _demandDistribution; /** Total number of requests to be generated*/ - Count_T _totalNumberOfRequestsToBeGenerated; + NbOfRequests_T _totalNumberOfRequestsToBeGenerated; /** Random generation context */ RandomGenerationContext _randomGenerationContext; Copied: trunk/stdair/stdair/bom/DemandStreamKey.cpp (from rev 129, trunk/stdair/stdair/bom/FlightDateKey.cpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamKey.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,58 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/DemandStreamKey.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::DemandStreamKey_T () + : _paxType (PassengerType::LAST_VALUE) { + } + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::DemandStreamKey_T (const AirportCode_T& iOrigin, + const AirportCode_T& iDestination, + const Date_T& iPreferredDepartureDate, + const PassengerType& iPaxType) + : _origin (iOrigin), _destination (iDestination), + _preferredDepartureDate (iPreferredDepartureDate), _paxType (iPaxType) { + } + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::DemandStreamKey_T (const DemandStreamKey_T& iKey) + : _origin (iKey._origin), _destination (iKey._destination), + _preferredDepartureDate (iKey._preferredDepartureDate), + _paxType (iKey._paxType) { + } + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::~DemandStreamKey_T () { + } + + // //////////////////////////////////////////////////////////////////// + void DemandStreamKey_T::toStream (std::ostream& ioOut) const { + ioOut << "DemandStreamKey: " << toString() << std::endl; + } + + // //////////////////////////////////////////////////////////////////// + void DemandStreamKey_T::fromStream (std::istream& ioIn) { + } + + // //////////////////////////////////////////////////////////////////// + const std::string DemandStreamKey_T::toString() const { + std::ostringstream oStr; + oStr << _origin << "-" << _destination << " " << _preferredDepartureDate + << " " << _paxType; + return oStr.str(); + } + + // //////////////////////////////////////////////////////////////////// + const std::string DemandStreamKey_T::describe() const { + std::ostringstream oStr; + oStr << toString(); + return oStr.str(); + } + +} Copied: trunk/stdair/stdair/bom/DemandStreamKey.hpp (from rev 129, trunk/stdair/stdair/bom/FlightDateKey.hpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamKey.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,97 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMKEY_HPP +#define __STDAIR_BOM_DEMANDSTREAMKEY_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/PassengerType.hpp> +#include <stdair/bom/BomKey.hpp> +#include <stdair/bom/BomRootKey.hpp> + +namespace stdair { + + /** Key of demand-stream. */ + struct DemandStreamKey_T : public BomKey_T { + public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef BomRootKey_T ParentKey_T; + + public: + // /////////// Construction /////////// + /** Constructors. */ + DemandStreamKey_T (const AirportCode_T& iOrigin, + const AirportCode_T& iDestination, + const Date_T& iPreferredDepartureDate, + const PassengerType& iPaxType); + DemandStreamKey_T (const DemandStreamKey_T&); + + /** Destructor. */ + ~DemandStreamKey_T (); + + public: + /** Default constructor */ + // TODO: that constructor should be private + DemandStreamKey_T (); + + + // /////////// Getters ////////// + /** Get the origin. */ + const AirportCode_T& getOrigin() const { + return _origin; + } + + /** Get the destination. */ + const AirportCode_T& getDestination() const { + return _destination; + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate () const { + return _preferredDepartureDate; + } + + /** Get the passenger type. */ + const PassengerType& getPassengerType() const { + return _paxType; + } + + + // /////////// Display support methods ///////// + /** Dump a Business Object Key into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a Business Object Key from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn); + + /** Get the serialised version of the Business Object Key. + <br>That string is unique, at the level of a given Business Object, + when among children of a given parent Business Object. + <br>For instance, "H" and "K" allow to differentiate among two + marketing classes for the same segment-stream. */ + const std::string toString() const; + + /** Display of the key. */ + const std::string describe() const; + + private: + // Attributes + /** Origin */ + AirportCode_T _origin; + + /** Origin */ + AirportCode_T _destination; + + /** Preferred departure date */ + Date_T _preferredDepartureDate; + + /** Passenger type. */ + PassengerType _paxType; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMKEY_HPP Modified: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -6,6 +6,8 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <map> +// Boost +#include <boost/shared_ptr.hpp> // STDAIR #include <stdair/STDAIR_Types.hpp> @@ -13,9 +15,14 @@ // Forward declaration class DemandStream; + + /** Type definition for the hashed key of the DemandStreamKey object. */ + typedef std::string DemandStreamKeyStr_T; /** Define a map of demand strams. */ - typedef std::map<const DemandStreamKey_T, DemandStream*> DemandStreamList_T; + typedef std::map<const DemandStreamKeyStr_T, DemandStream*> DemandStreamList_T; + /** Type definition for a reference on a list of DemandStream objects. */ + typedef boost::shared_ptr<DemandStreamList_T> DemandStreamListPtr_T; } #endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -13,8 +13,7 @@ EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, const DemandStreamKey_T& iDemandStreamKey, BookingRequestPtr_T ioRequestPtr) - : _eventType (iEventType), - _eventDateTime (iDateTime), + : _eventType (iEventType), _eventDateTime (iDateTime), _demandStreamKey (iDemandStreamKey) { _request = ioRequestPtr; } @@ -30,9 +29,8 @@ // ////////////////////////////////////////////////////////////////////// EventStruct::EventStruct (const DateTime_T& iDateTime) - : _eventType (""), - _eventDateTime (iDateTime), - _demandStreamKey (-1) { + : _eventType (""), _eventDateTime (iDateTime), + _demandStreamKey ("", "", DEFAULT_DATE, PassengerType::LAST_VALUE) { } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -7,6 +7,7 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BookingRequestTypes.hpp> +#include <stdair/bom/DemandStreamKey.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/InventoryKey.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryKey.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/InventoryKey.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -10,10 +10,10 @@ #include <stdair/bom/BomRootKey.hpp> namespace stdair { + /** Key of inventory. */ struct InventoryKey_T : public BomKey_T { friend struct FlightDateKey_T; - public: // /////////// Typedefs //////////// /** Definition allowing to retrieve the parent key type. */ Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-15 01:20:27 UTC (rev 133) @@ -17,6 +17,7 @@ $(top_srcdir)/stdair/bom/OutboundPathKey.hpp \ $(top_srcdir)/stdair/bom/AirlineFeatureSetKey.hpp \ $(top_srcdir)/stdair/bom/AirlineFeatureKey.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamKey.hpp \ $(top_srcdir)/stdair/bom/BomRootTypes.hpp \ $(top_srcdir)/stdair/bom/BomRoot.hpp \ $(top_srcdir)/stdair/bom/BomContent.hpp \ @@ -107,6 +108,7 @@ $(top_srcdir)/stdair/bom/OutboundPathKey.cpp \ $(top_srcdir)/stdair/bom/AirlineFeatureSetKey.cpp \ $(top_srcdir)/stdair/bom/AirlineFeatureKey.cpp \ + $(top_srcdir)/stdair/bom/DemandStreamKey.cpp \ $(top_srcdir)/stdair/bom/BomRoot.cpp \ $(top_srcdir)/stdair/bom/BomRootContent.cpp \ $(top_srcdir)/stdair/bom/Inventory.cpp \ Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -3,10 +3,13 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> +// Boost +#include <boost/make_shared.hpp> // StdAir #include <stdair/bom/BomRoot.hpp> #include <stdair/bom/AirlineFeatureSet.hpp> #include <stdair/bom/AirlineFeature.hpp> +#include <stdair/bom/DemandStreamTypes.hpp> // Inventory: child of BomRoot, needed for creation of BomRoot #include <stdair/bom/Inventory.hpp> // Network: child of BomRoot, needed for creation of BomRoot @@ -30,9 +33,8 @@ } // ////////////////////////////////////////////////////////////////////// - void CmdBomManager:: - addAirlineFeature (BomRoot& ioBomRoot, - const AirlineCode_T& iAirlineCode) { + void CmdBomManager::addAirlineFeature (BomRoot& ioBomRoot, + const AirlineCode_T& iAirlineCode) { // Initialise an AirlineFeature object AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); @@ -48,6 +50,16 @@ } // ////////////////////////////////////////////////////////////////////// + void CmdBomManager::initDemandStreamList (BomRoot& ioBomRoot) { + // Initialise the set of required airline features + DemandStreamListPtr_T lDemandStreamList_ptr = + boost::make_shared<DemandStreamList_T>(); + + // Set the AirlineFeatureSet for the BomRoot. + ioBomRoot.setDemandStreamList (lDemandStreamList_ptr); + } + + // ////////////////////////////////////////////////////////////////////// Inventory& CmdBomManager:: createInventoryInternal (BomRoot& ioBomRoot, const AirlineCode_T& iAirlineCode) { Modified: trunk/stdair/stdair/command/CmdBomManager.hpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/command/CmdBomManager.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -30,8 +30,7 @@ created . */ static Inventory& getOrCreateInventory (BomRoot&, const AirlineCode_T&); - /** Initialise the AirlineFeatureSet object, and attach it to the - BomRoot. + /** Initialise the AirlineFeatureSet object, and attach it to the BomRoot. @param BomRoot& Root of the BOM tree. */ static void initAirlineFeatureSet (BomRoot&); @@ -41,6 +40,11 @@ @param const AirlineCode_T& Airline code for the inventory to be created . */ static void addAirlineFeature (BomRoot&, const AirlineCode_T& iAirlineCode); + + /** Initialise the DemandStreamList object, and attach it to the BomRoot. + @param BomRoot& Root of the BOM tree. */ + static void initDemandStreamList (BomRoot&); + private: // ///////////////////// Internal support methods //////////////////////// Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -24,6 +24,7 @@ struct OptimizerStruct_T; struct DemandCharacteristics; struct DemandDistribution; + struct DemandStreamKey_T; /** Base class for Factory layer. */ class FacBomContent { Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -38,6 +38,8 @@ // Initialise the AirlineFeatureSet object, and attach it to the BomRoot initAirlineFeatureSet (); + // Initialise the DemandStreamList object, and attach it to the BomRoot + initDemandStreamList (); // Set the log file logInit (iLogParams); @@ -55,6 +57,8 @@ // Initialise the AirlineFeatureSet object, and attach it to the BomRoot initAirlineFeatureSet (); + // Initialise the DemandStreamList object, and attach it to the BomRoot + initDemandStreamList (); // Set the log file logInit (iLogParams); @@ -91,6 +95,12 @@ // Delegate to the dedicated command CmdBomManager::initAirlineFeatureSet (_bomRoot); } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::initDemandStreamList () { + // Delegate to the dedicated command + CmdBomManager::initDemandStreamList (_bomRoot); + } // ////////////////////////////////////////////////////////////////////// void STDAIR_Service:: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-14 16:21:54
|
Revision: 132 http://stdair.svn.sourceforge.net/stdair/?rev=132&view=rev Author: denis_arnaud Date: 2010-02-14 16:21:47 +0000 (Sun, 14 Feb 2010) Log Message: ----------- [TraDemGen] The parser for the demand input file has been completed. There is still some work to copy the parsed content to the BOM. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-14 16:20:19 UTC (rev 131) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-14 16:21:47 UTC (rev 132) @@ -83,12 +83,6 @@ /** Database request statement handler. */ typedef soci::statement DBRequestStatement_T; - /** Define the type for durations (e.g., elapsed in-flight time). */ - typedef boost::posix_time::time_duration Duration_T; - - /** Define the type for date (e.g., departure date of a flight). */ - typedef boost::gregorian::date Date_T; - /** Define the type for network ID. */ typedef std::string NetworkID_T; @@ -120,12 +114,12 @@ B: booked, C: cancelled, R: Rejected). */ typedef std::string RequestStatus_T; - /** Define the Date (e.g., flight-date departure date). */ - typedef boost::gregorian::date Date_T; - - /** Define the Duration (e.g., elapsed in-flight time). */ + /** Define the type for durations (e.g., elapsed in-flight time). */ typedef boost::posix_time::time_duration Duration_T; + /** Define the type for date (e.g., departure date of a flight). */ + typedef boost::gregorian::date Date_T; + /** Time */ typedef boost::posix_time::time_duration Time_T; @@ -145,7 +139,7 @@ typedef boost::gregorian::date_duration DateOffSet_T; /** Define a duration in number of days. */ - typedef long DayDuration_T; + typedef unsigned int DayDuration_T; /** Define the Saturday stay status of a travel. */ typedef bool SaturdayStay_T; @@ -204,6 +198,9 @@ /** Define a price currency (e.g., EUR for Euros). */ typedef std::string PriceCurrency_T; + /** Define a Willingness-To-Pay (WTP) (e.g., 1000.0 Euros). */ + typedef double WTP_T; + /** Define the number of seats required by a demand. */ typedef unsigned short NbOfSeats_T; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-14 16:20:25
|
Revision: 131 http://stdair.svn.sourceforge.net/stdair/?rev=131&view=rev Author: denis_arnaud Date: 2010-02-14 16:20:19 +0000 (Sun, 14 Feb 2010) Log Message: ----------- [Dev] The parser for the demand input file has been completed. There is still some work to copy the parsed content to the BOM. Modified Paths: -------------- trunk/stdair/test/samples/demand01.csv Modified: trunk/stdair/test/samples/demand01.csv =================================================================== --- trunk/stdair/test/samples/demand01.csv 2010-02-13 01:28:05 UTC (rev 130) +++ trunk/stdair/test/samples/demand01.csv 2010-02-14 16:20:19 UTC (rev 131) @@ -1,6 +1,6 @@ // Demand: // Fixed: -// Prefered departure date (yyyy/mm/dd) +// Prefered departure date (yyyy-mm-dd) // Origin (3-char airport code) // Destination (3-char airport code) // Cabin (1-char cabin code) @@ -14,10 +14,10 @@ // Stay duration (number of days) // Frequent flyer (P=Platinum, G=Gold, S=Silver, M=Member, N=None) // Continuous cumulative distribution: -// Preferred departure time (hh:mm:ss) +// Preferred departure time (hh.mm) // WTP (moneraty value) -// Preferred arrival date (equal to Prefered departure date) -// Preferred arrival time (equal to Prefered departure time) +// Preferred arrival date (equal to prefered departure date) +// Preferred arrival time (equal to prefered departure time) // Value of time // Arrival pattern (DTD as a positive value) // The main fields are separated by ';' @@ -25,10 +25,7 @@ // 'value:probability' pairs // Continuous cumulative distribution are defined by comma-separated // 'value:probability' pairs, sorted in increasing order of values. -// The meaning of probability is P(random variable<=value) = probability. +// The meaning of probability is P(random variable <= value) = probability. // -// Temporary commented the following lines, until the parser be fully ready -// 2010-02-08; SIN; BKK; M; 10.0; 1.0; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 6:0, 7:0.1, 9:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; -// 2010-02-08; SIN; HND; M; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 6:0, 7:0.1, 9:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; -// -2010-02-08; SIN; BKK; M; 10.0; 1.0; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; +2010-02-08; SIN; BKK; M; 10.0; 1.0; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 06:0, 07:0.1, 09:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; +2010-02-08; SIN; HND; M; 10.0; 1.0; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 06:0, 07:0.1, 09:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-13 01:28:16
|
Revision: 130 http://stdair.svn.sourceforge.net/stdair/?rev=130&view=rev Author: denis_arnaud Date: 2010-02-13 01:28:05 +0000 (Sat, 13 Feb 2010) Log Message: ----------- [Test/Demand] Simplified the entries to that the parser can recognise it for now. Modified Paths: -------------- trunk/stdair/test/samples/demand01.csv Modified: trunk/stdair/test/samples/demand01.csv =================================================================== --- trunk/stdair/test/samples/demand01.csv 2010-02-12 13:55:43 UTC (rev 129) +++ trunk/stdair/test/samples/demand01.csv 2010-02-13 01:28:05 UTC (rev 130) @@ -1,6 +1,6 @@ // Demand: // Fixed: -// Prefered departure date (dd/mm/yyyy) +// Prefered departure date (yyyy/mm/dd) // Origin (3-char airport code) // Destination (3-char airport code) // Cabin (1-char cabin code) @@ -27,5 +27,8 @@ // 'value:probability' pairs, sorted in increasing order of values. // The meaning of probability is P(random variable<=value) = probability. // -100208;SIN;BKK;M;SIN:0.7,BKK:0.2,row:0.1;DF:0.1,DN:0.3,IF:0.4,IN:0.2;RO:0.6,RI:0.2,OW:0.2;0:0.1,1:0.1,2:0.15,3:0.15,4:0.15,5:0.35;P:0.01,G:0.05,S:0.15,M:0.3,N:0.49;6:0,7:0.1,9:0.3,17:0.4,19:0.8,20:0.95,22:1;100:0,500:0.8,2000:1;0;15:0,60:1;330:0,40:0.2,20:0.6,1:1 -100208;SIN;HND;M;SIN:0.5,HND:0.4,row:0.1;DF:0.2,DN:0.2,IF:0.5,IN:0.1;RO:0.5,RI:0.4,OW:0.1;1:0.9,2:0.1;P:0.1,G:0.01,S:0.09,M:0.4,N:0.4;6:0,7:0.1,9:0.8,12:0.9,22:1;300:0,800:0.8,3000:1;0;15:0,60:1;330:0,1:1 +// Temporary commented the following lines, until the parser be fully ready +// 2010-02-08; SIN; BKK; M; 10.0; 1.0; SIN:0.7, BKK:0.2, row:0.1; DF:0.1, DN:0.3, IF:0.4, IN:0.2; RO:0.6, RI:0.2, OW:0.2; 0:0.1, 1:0.1, 2:0.15, 3:0.15, 4:0.15, 5:0.35; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; 6:0, 7:0.1, 9:0.3, 17:0.4, 19:0.8, 20:0.95, 22:1; 100:0, 500:0.8, 2000:1; 15:0, 60:1; 330:0, 40:0.2, 20:0.6, 1:1; +// 2010-02-08; SIN; HND; M; SIN:0.5, HND:0.4, row:0.1; DF:0.2, DN:0.2, IF:0.5, IN:0.1; RO:0.5, RI:0.4, OW:0.1; 1:0.9, 2:0.1; P:0.1, G:0.01, S:0.09, M:0.4, N:0.4; 6:0, 7:0.1, 9:0.8, 12:0.9, 22:1; 300:0, 800:0.8, 3000:1; 15:0, 60:1; 330:0, 1:1; +// +2010-02-08; SIN; BKK; M; 10.0; 1.0; P:0.01, G:0.05, S:0.15, M:0.3, N:0.49; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-12 13:55:54
|
Revision: 129 http://stdair.svn.sourceforge.net/stdair/?rev=129&view=rev Author: quannaus Date: 2010-02-12 13:55:43 +0000 (Fri, 12 Feb 2010) Log Message: ----------- [dev] Added a description for AirlineFeatureSet. Modified Paths: -------------- trunk/stdair/stdair/bom/AirlineFeatureSet.cpp Modified: trunk/stdair/stdair/bom/AirlineFeatureSet.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSet.cpp 2010-02-11 14:38:06 UTC (rev 128) +++ trunk/stdair/stdair/bom/AirlineFeatureSet.cpp 2010-02-12 13:55:43 UTC (rev 129) @@ -43,7 +43,7 @@ // ////////////////////////////////////////////////////////////////////// const std::string AirlineFeatureSet::describeKey() const { - return std::string (""); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-11 14:38:12
|
Revision: 128 http://stdair.svn.sourceforge.net/stdair/?rev=128&view=rev Author: denis_arnaud Date: 2010-02-11 14:38:06 +0000 (Thu, 11 Feb 2010) Log Message: ----------- [Test] Added a sample for the demand generation (by TraDemGen). Modified Paths: -------------- trunk/stdair/test/samples/demand01.csv Added Paths: ----------- trunk/stdair/test/samples/README_Demand Added: trunk/stdair/test/samples/README_Demand =================================================================== --- trunk/stdair/test/samples/README_Demand (rev 0) +++ trunk/stdair/test/samples/README_Demand 2010-02-11 14:38:06 UTC (rev 128) @@ -0,0 +1,21 @@ +preferred departure date: fixed (yymmdd) +origin: fixed +destination: fixed +cabin: fixed +pos: probability mass +channel: probability mass (D=direct, I=indirect, N=oNline, F=oFfline) +trip type: probability mass (RO=outbound of round-trip, RI=inbound of round-trip, OW=one way) +stay duration: probability mass (number of days) +frequent flyer: probability mass (P=Platinum, G=Gold, S=Silver, M=Member, N=None) +preferred departure time: continuous cumulative distribution (hours in decimal form, e.g. 8.5 = 8:30) +wtp: continuous cumulative distribution (moneraty value) +preferred arrival date and time: on va hard-coder celui-là et le mettre égal à preferred departure date and time +value of time: continuous cumulative distribution +arrival pattern: continuous cumulative distribution (dtd as a positive value) + +The main fields are separated by ';'. +Probability mass distributions are defined by comma-separated 'value:probability' pairs +Continuous cumulative distribution are defined by comma-separated 'value:probability' pairs, sorted in increasing order of values. The meaning of probability is P(random variable<=value) = probability. + +100208;SIN;BKK;M;SIN:0.7,BKK:0.2,row:0.1;DF:0.1,DN:0.3,IF:0.4,IN:0.2;RO:0.6,RI:0.2,OW:0.2;0:0.1,1:0.1,2:0.15,3:0.15,4:0.15,5:0.35;P:0.01,G:0.05,S:0.15,M:0.3,N:0.49;6:0,7:0.1,9:0.3,17:0.4,19:0.8,20:0.95,22:1;100:0,500:0.8,2000:1;0;15:0,60:1;330:0,40:0.2,20:0.6,1:1 +100208;SIN;HND;M;SIN:0.5,HND:0.4,row:0.1;DF:0.2,DN:0.2,IF:0.5,IN:0.1;RO:0.5,RI:0.4,OW:0.1;1:0.9,2:0.1;P:0.1,G:0.01,S:0.09,M:0.4,N:0.4;6:0,7:0.1,9:0.8,12:0.9,22:1;300:0,800:0.8,3000:1;0;15:0,60:1;330:0,1:1 Modified: trunk/stdair/test/samples/demand01.csv =================================================================== --- trunk/stdair/test/samples/demand01.csv 2010-02-11 12:59:00 UTC (rev 127) +++ trunk/stdair/test/samples/demand01.csv 2010-02-11 14:38:06 UTC (rev 128) @@ -1,4 +1,31 @@ -// Demand: Origin; Destination; PreferedDepartureDate; Mean; StdDev; -NCE; JFK; 2011-01-15; 50; 0; -NCE; LHR; 2011-01-15; 300; 0; - +// Demand: +// Fixed: +// Prefered departure date (dd/mm/yyyy) +// Origin (3-char airport code) +// Destination (3-char airport code) +// Cabin (1-char cabin code) +// Observable: +// Mean +// StdDev +// Distribution with Probability Masses: +// POS +// Channel (D=direct, I=indirect, N=oNline, F=oFfline) +// Trip type (RO=outbound of round-trip, RI=inbound of round-trip,OW=one way) +// Stay duration (number of days) +// Frequent flyer (P=Platinum, G=Gold, S=Silver, M=Member, N=None) +// Continuous cumulative distribution: +// Preferred departure time (hh:mm:ss) +// WTP (moneraty value) +// Preferred arrival date (equal to Prefered departure date) +// Preferred arrival time (equal to Prefered departure time) +// Value of time +// Arrival pattern (DTD as a positive value) +// The main fields are separated by ';' +// Probability mass distributions are defined by comma-separated +// 'value:probability' pairs +// Continuous cumulative distribution are defined by comma-separated +// 'value:probability' pairs, sorted in increasing order of values. +// The meaning of probability is P(random variable<=value) = probability. +// +100208;SIN;BKK;M;SIN:0.7,BKK:0.2,row:0.1;DF:0.1,DN:0.3,IF:0.4,IN:0.2;RO:0.6,RI:0.2,OW:0.2;0:0.1,1:0.1,2:0.15,3:0.15,4:0.15,5:0.35;P:0.01,G:0.05,S:0.15,M:0.3,N:0.49;6:0,7:0.1,9:0.3,17:0.4,19:0.8,20:0.95,22:1;100:0,500:0.8,2000:1;0;15:0,60:1;330:0,40:0.2,20:0.6,1:1 +100208;SIN;HND;M;SIN:0.5,HND:0.4,row:0.1;DF:0.2,DN:0.2,IF:0.5,IN:0.1;RO:0.5,RI:0.4,OW:0.1;1:0.9,2:0.1;P:0.1,G:0.01,S:0.09,M:0.4,N:0.4;6:0,7:0.1,9:0.8,12:0.9,22:1;300:0,800:0.8,3000:1;0;15:0,60:1;330:0,1:1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-11 14:05:05
|
Revision: 127 http://stdair.svn.sourceforge.net/stdair/?rev=127&view=rev Author: quannaus Date: 2010-02-11 12:59:00 +0000 (Thu, 11 Feb 2010) Log Message: ----------- [dev] Re-added DemandStream. Modified Paths: -------------- trunk/stdair/stdair/basic/RandomGeneration.cpp trunk/stdair/stdair/basic/RandomGeneration.hpp trunk/stdair/stdair/bom/BookingRequestTypes.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.hpp Added Paths: ----------- trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp Modified: trunk/stdair/stdair/basic/RandomGeneration.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-11 12:59:00 UTC (rev 127) @@ -23,6 +23,13 @@ } // ////////////////////////////////////////////////////////////////////// + RandomGeneration::RandomGeneration () + : _seed (0), _generator (0), + _uniformGenerator (_generator, boost::uniform_real<> (0, 1)) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// RandomGeneration::~RandomGeneration () { } Modified: trunk/stdair/stdair/basic/RandomGeneration.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -22,28 +22,30 @@ } // //////////// Business Methods ///////////// - /** Generate a randomized number following a uniform distribution between 0 (included) and 1 (excluded). */ + /** Generate a randomized number following a uniform distribution + between 0 (included) and 1 (excluded). */ RealNumber_T generateUniform01 (); - /** Generate a randomized number following a uniform distribution between a minimum (included) and a maximum (excluded) value. */ + /** Generate a randomized number following a uniform distribution + between a minimum (included) and a maximum (excluded) + value. */ RealNumber_T generateUniform (const RealNumber_T&, const RealNumber_T&); - /** Generate a randomized number following a normal distribution specified by a mean and a standard deviation. */ + /** Generate a randomized number following a normal distribution + specified by a mean and a standard deviation. */ RealNumber_T generateNormal (const RealNumber_T&, const RealNumber_T&); public: // ////////// Constructors and destructors ///////// /** Constructor. */ RandomGeneration (const RandomSeed_T&); - + /** Default constructors. */ + RandomGeneration (); + RandomGeneration (const RandomGeneration&); + /** Destructor. */ virtual ~RandomGeneration (); - public : - /** Default constructors. */ - RandomGeneration (); - RandomGeneration (const RandomGeneration&); - /** Initialize the random generator. <br>A uniform random number distribution is defined, which produces "real" values between 0 and 1 (0 inclusive, 1 Modified: trunk/stdair/stdair/bom/BookingRequestTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestTypes.hpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/bom/BookingRequestTypes.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -1,6 +1,6 @@ // ////////////////////////////////////////////////////////////////////// -#ifndef __STDAIR_BOM_BOOKINGCLASSTYPES_HPP -#define __STDAIR_BOM_BOOKINGCLASSTYPES_HPP +#ifndef __STDAIR_BOM_BOOKINGREQUESTTYPES_HPP +#define __STDAIR_BOM_BOOKINGREQUESTTYPES_HPP // ////////////////////////////////////////////////////////////////////// // Import section @@ -18,5 +18,5 @@ typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; } -#endif // __STDAIR_BOM_BOOKINGCLASSTYPES_HPP +#endif // __STDAIR_BOM_BOOKINGREQUESTTYPES_HPP Added: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-11 12:59:00 UTC (rev 127) @@ -0,0 +1,66 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <ostream> +#include <sstream> +// Boost +#include <boost/math/distributions/normal.hpp> +// Math +#include <math.h> +// STDAIR +#include <stdair/basic/BasConst_General.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> +#include <stdair/bom/DemandStream.hpp> +#include <stdair/service/Logger.hpp> + + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + DemandStream:: + DemandStream (const DemandStreamKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) + : _key (iKey), + _demandCharacteristics (iDemandCharacteristics), + _demandDistribution (iDemandDistribution), + _totalNumberOfRequestsToBeGenerated (0), + _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), + _requestDateTimeRandomGenerator (iRequestDateTimeSeed), + _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { + init(); + } + + // ////////////////////////////////////////////////////////////////////// + DemandStream::~DemandStream () { + } + + // ////////////////////////////////////////////////////////////////////// + void DemandStream::init() { + // Generate the number of requests + const RealNumber_T lMu = + _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lSigma = + _demandDistribution.getStandardDeviationNumberOfRequests (); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); + Count_T lIntegerNumberOfRequestsToBeGenerated = 0; + if (lRealNumberOfRequestsToBeGenerated < 0.5) { + lIntegerNumberOfRequestsToBeGenerated = 0; + } else { + lIntegerNumberOfRequestsToBeGenerated = + static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + } + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; + } + +} Added: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -0,0 +1,229 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAM_HPP +#define __STDAIR_BOM_DEMANDSTREAM_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/DemandDistribution.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BomContent.hpp> +#include <stdair/bom/BookingRequestTypes.hpp> +#include <stdair/bom/DemandStreamTypes.hpp> + +namespace stdair { + + /** Class modeling a demand stream. */ + class DemandStream : public BomContent { + friend class FacBomContent; + + public: + // ///////////// Getters /////////// + /** Get the key */ + const DemandStreamKey_T& getKey () const { + return _key; + } + + /** Get the total number of requests to be generated. */ + const Count_T& getTotalNumberOfRequestsToBeGenerated() const { + return _totalNumberOfRequestsToBeGenerated; + } + + /** Get the origin. */ + const AirportCode_T& getOrigin() const { + return _demandCharacteristics.getOrigin(); + } + + /** Get the destination. */ + const AirportCode_T& getDestination() const { + return _demandCharacteristics.getDestination(); + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate() const { + return _demandCharacteristics.getPreferredDepartureDate(); + } + + /** Get the passenger type. */ + const PassengerType_T& getPaxType() const { + return _demandCharacteristics.getPaxType(); + } + + /** Get the arrival pattern. */ + const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + return _demandCharacteristics.getArrivalPattern(); + } + + /** Get the mean number of requests. */ + const RealNumber_T& getMeanNumberOfRequests() const { + return _demandDistribution.getMeanNumberOfRequests(); + } + + /** Get the standard deviation of number of requests. */ + const RealNumber_T& getStandardDeviationNumberOfRequests() const { + return _demandDistribution.getStandardDeviationNumberOfRequests(); + } + + /** Get the cumulative probability of arrival pattern for last + request generated so far. */ + const Probability_T& getCumulativeProbabilitySoFar () const { + return _randomGenerationContext.getCumulativeProbabilitySoFar(); + } + + /** Get the number of requests generated so far. */ + const Count_T getNumberOfRequestsGeneratedSoFar() const { + return _randomGenerationContext.getCumulativeProbabilitySoFar();; + } + + /** Get the seed of the random generator for the number of requests. */ + const RandomSeed_T& getNumberOfRequestsRandomGeneratorSeed () const { + return _numberOfRequestsRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the request datetime. */ + const RandomSeed_T& getRequestDateTimeRandomGeneratorSeed () const { + return _requestDateTimeRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the demand characteristics. */ + const RandomSeed_T& getDemandCharacteristicsRandomGeneratorSeed () const { + return _demandCharacteristicsRandomGenerator.getSeed(); + } + + public: + // //////////////// Setters ////////////////// + /** Set the cumulative probability of arrival pattern for last + request generated so far. */ + void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { + _randomGenerationContext. + setCumulativeProbabilitySoFar (iCumulativeProbability); + } + + /** Set the number of requests generated so far. */ + void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { + _randomGenerationContext. + setNumberOfRequestsGeneratedSoFar (iNumberOfRequests); + } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { ioOut << toString(); } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) { } + + /** Get the serialised version of the Business Object. */ + std::string toString() const { return describeKey(); } + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const { return std::string (""); } + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + const std::string describeShortKey() const { return std::string (""); } + + + public: + // /////////////// Business Methods ////////// + /** Increment counter of requests generated so far */ + void incrementGeneratedRequestsCounter () { + _randomGenerationContext.incrementGeneratedRequestsCounter(); + } + + + /** Generate a randomized number following a uniform distribution + between 0 (included) and 1 (excluded). */ + RealNumber_T generateUniform01WithNumberOfRequestRandomGenerator () { + return _numberOfRequestsRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithRequestDateTimeRandomGenerator() { + return _requestDateTimeRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithDemandCharacteristicsRandomGenerator() { + return _demandCharacteristicsRandomGenerator.generateUniform01(); + } + + /** Generate a randomized number following a uniform distribution + between a minimum (included) and a maximum (excluded) + value. */ + RealNumber_T generateUniformWithNumberOfRequestRandomGenerator (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _numberOfRequestsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithRequestDateTimeRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _requestDateTimeRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithDemandCharacteristicsRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _demandCharacteristicsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + + /** Generate a randomized number following a normal distribution + specified by a mean and a standard deviation. */ + RealNumber_T generateNormalWithNumberOfRequestRandomGenerator (const RealNumber_T& mu, const RealNumber_T& sigma) { + return _numberOfRequestsRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithRequestDateTimeRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _requestDateTimeRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithDemandCharacteristicsRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _demandCharacteristicsRandomGenerator.generateNormal (mu, sigma); + } + + protected: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandStream (const DemandStreamKey_T&, + const DemandCharacteristics&, + const DemandDistribution&, const RandomSeed_T&, + const RandomSeed_T&, const RandomSeed_T&); + /** Default constructors. */ + DemandStream (); + DemandStream (const DemandStream&); + /** Initialization. */ + void init(); + /** Destructor. */ + ~DemandStream (); + + + protected: + // ////////// Attributes ////////// + /** Key */ + DemandStreamKey_T _key; + + /** Demand characteristics */ + DemandCharacteristics _demandCharacteristics; + + /** Demand distribution */ + DemandDistribution _demandDistribution; + + /** Total number of requests to be generated*/ + Count_T _totalNumberOfRequestsToBeGenerated; + + /** Random generation context */ + RandomGenerationContext _randomGenerationContext; + + /** Random generator for number of requests */ + RandomGeneration _numberOfRequestsRandomGenerator; + + /** Random generator for request datetime */ + RandomGeneration _requestDateTimeRandomGenerator; + + /** Random generator for demand characteristics */ + RandomGeneration _demandCharacteristicsRandomGenerator; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAM_HPP Added: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -0,0 +1,21 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMTYPES_HPP +#define __STDAIR_BOM_DEMANDSTREAMTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + // Forward declaration + class DemandStream; + + /** Define a map of demand strams. */ + typedef std::map<const DemandStreamKey_T, DemandStream*> DemandStreamList_T; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-11 12:59:00 UTC (rev 127) @@ -86,6 +86,8 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ + $(top_srcdir)/stdair/bom/DemandStream.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamTypes.hpp \ $(top_srcdir)/stdair/bom/EventStruct.hpp \ $(top_srcdir)/stdair/bom/EventQueue.hpp \ $(top_srcdir)/stdair/bom/EventTypes.hpp \ @@ -138,6 +140,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ + $(top_srcdir)/stdair/bom/DemandStream.cpp \ $(top_srcdir)/stdair/bom/EventStruct.cpp \ $(top_srcdir)/stdair/bom/EventQueue.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -173,6 +173,29 @@ iReferenceOutboundPath._flightPathCode; } + // ////////////////////////////////////////////////////////////////// + // /////////////////////// Dedicated factories ////////////////////// + // ////////////////////////////////////////////////////////////////// + template <typename DEMAND_STREAM> + DEMAND_STREAM& create (const DemandStreamKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) { + DEMAND_STREAM* aDemandStream_ptr = + new DEMAND_STREAM (iKey, iDemandCharacteristics, iDemandDistribution, + iNumberOfRequestsSeed, iRequestDateTimeSeed, + iDemandCharacteristicsSeed); + assert (aDemandStream_ptr != NULL); + + // The new object is added to the pool of content objects + _contentPool.push_back (aDemandStream_ptr); + + return *aDemandStream_ptr; + } + + public: /** Provide the unique instance. <br>The singleton is instantiated when first used. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-10 17:13:46
|
Revision: 126 http://stdair.svn.sourceforge.net/stdair/?rev=126&view=rev Author: quannaus Date: 2010-02-10 17:13:38 +0000 (Wed, 10 Feb 2010) Log Message: ----------- [Dev] Moved the demand stream to trademgen. Modified Paths: -------------- trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_General.hpp trunk/stdair/stdair/basic/RandomGeneration.cpp trunk/stdair/stdair/basic/RandomGeneration.hpp trunk/stdair/stdair/basic/RandomGenerationContext.cpp trunk/stdair/stdair/basic/RandomGenerationContext.hpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/EventQueue.cpp trunk/stdair/stdair/bom/EventQueue.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.cpp trunk/stdair/stdair/factory/FacBomContent.hpp Added Paths: ----------- trunk/stdair/stdair/bom/BookingRequestTypes.hpp trunk/stdair/stdair/bom/EventTypes.hpp Removed Paths: ------------- trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -129,12 +129,15 @@ const DateOffSet_T DEFAULT_DATE_OFFSET (0); // // //////// General /////// - /** Default update date for the General. */ + /** Default date for the General. */ const Date_T DEFAULT_DATE (2007, boost::gregorian::Jan, 1); - /** Default update date&time. */ + /** Default date&time. */ const DateTime_T DEFAULT_DATETIME (DEFAULT_DATE, NULL_BOOST_TIME_DURATION); + /** Default epsilon duration (1 nanosecond). */ + const Duration_T DEFAULT_EPSILON_DURATION = Duration_T (0, 0, 0, 1); + /** Number of seconds in one day */ const Count_T SECONDS_IN_ONE_DAY = 86000; Modified: trunk/stdair/stdair/basic/BasConst_General.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -42,10 +42,13 @@ /** Number of milliseconds in one second */ extern const Count_T MILLISECONDS_IN_ONE_SECOND; - /** Default update date for the General. */ + /** Default date for the General. */ extern const Date_T DEFAULT_DATE; - /** Default update date&time. */ + /** Default date&time. */ extern const DateTime_T DEFAULT_DATETIME; + + /** Default epsilon duration. */ + extern const Duration_T DEFAULT_EPSILON_DURATION; } #endif // __STDAIR_BAS_BASCONST_GENERAL_HPP Modified: trunk/stdair/stdair/basic/RandomGeneration.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -16,6 +16,13 @@ } // ////////////////////////////////////////////////////////////////////// + RandomGeneration::RandomGeneration (const RandomGeneration& iRandomGeneration) + : _seed (iRandomGeneration._seed), + _generator (iRandomGeneration._generator), + _uniformGenerator (iRandomGeneration._uniformGenerator) { + } + + // ////////////////////////////////////////////////////////////////////// RandomGeneration::~RandomGeneration () { } Modified: trunk/stdair/stdair/basic/RandomGeneration.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -39,7 +39,7 @@ /** Destructor. */ virtual ~RandomGeneration (); - private: + public : /** Default constructors. */ RandomGeneration (); RandomGeneration (const RandomGeneration&); Modified: trunk/stdair/stdair/basic/RandomGenerationContext.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -15,6 +15,12 @@ } // ////////////////////////////////////////////////////////////////////// + RandomGenerationContext::RandomGenerationContext (const RandomGenerationContext& iRandomGenerationContext) + : _cumulativeProbabilitySoFar (iRandomGenerationContext._cumulativeProbabilitySoFar), + _numberOfRequestsGeneratedSoFar (iRandomGenerationContext._numberOfRequestsGeneratedSoFar) { + } + + // ////////////////////////////////////////////////////////////////////// RandomGenerationContext::~RandomGenerationContext () { } Modified: trunk/stdair/stdair/basic/RandomGenerationContext.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -42,6 +42,8 @@ // ////////// Constructors and destructors ///////// /** Constructor by default */ RandomGenerationContext (); + /** Default constructors. */ + RandomGenerationContext (const RandomGenerationContext&); /** Destructor */ virtual ~RandomGenerationContext (); @@ -51,9 +53,6 @@ /** Increment counter of requests generated so far */ void incrementGeneratedRequestsCounter (); - private: - /** Default constructors. */ - RandomGenerationContext (const RandomGenerationContext&); private: // ////////// Attributes ////////// Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -15,7 +15,6 @@ /** Structure holding the elements of a booking request. */ struct BookingRequestStruct : public StructAbstract { - friend class DemandStream; public: // /////////////// Getters ///////////////// @@ -94,13 +93,13 @@ /** Display of the structure. */ const std::string describe() const; - private : // /////////////// Constructors and Destructors ///////////////// - BookingRequestStruct (); public : BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, const PassengerType_T&, const NbOfSeats_T&); + public : + BookingRequestStruct (); BookingRequestStruct (const BookingRequestStruct&); public: ~BookingRequestStruct(); Added: trunk/stdair/stdair/bom/BookingRequestTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/BookingRequestTypes.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -0,0 +1,22 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_BOOKINGCLASSTYPES_HPP +#define __STDAIR_BOM_BOOKINGCLASSTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> + +namespace stdair { + + // Forward declarations. + struct BookingRequestStruct; + + // Type definitions. + /** Define the smart pointer to a booking request. */ + typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; + +} +#endif // __STDAIR_BOM_BOOKINGCLASSTYPES_HPP + Deleted: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -1,157 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <cassert> -#include <iosfwd> -#include <ostream> -#include <sstream> -// Boost -#include <boost/math/distributions/normal.hpp> -// Math -#include <math.h> -// STDAIR -#include <stdair/basic/BasConst_General.hpp> -#include <stdair/basic/DemandCharacteristics.hpp> -#include <stdair/basic/RandomGeneration.hpp> -#include <stdair/basic/RandomGenerationContext.hpp> -#include <stdair/bom/BookingRequestStruct.hpp> -#include <stdair/bom/DemandStream.hpp> -#include <stdair/service/Logger.hpp> - - -namespace stdair { - - // ////////////////////////////////////////////////////////////////////// - DemandStream::DemandStream(const DemandStreamKey_T& iKey, - const DemandCharacteristics& iDemandCharacteristics, - const DemandDistribution& iDemandDistribution, - const RandomSeed_T& iNumberOfRequestsSeed, - const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed) - : _key (iKey), - _demandCharacteristics (iDemandCharacteristics), - _demandDistribution (iDemandDistribution), - _totalNumberOfRequestsToBeGenerated (0), - _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), - _requestDateTimeRandomGenerator (iRequestDateTimeSeed), - _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { - init(); - } - - // ////////////////////////////////////////////////////////////////////// - DemandStream::~DemandStream () { - } - - // ////////////////////////////////////////////////////////////////////// - void DemandStream::init() { - // Generate the number of requests - const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); - const RealNumber_T lSigma = - _demandDistribution.getStandardDeviationNumberOfRequests (); - const RealNumber_T lRealNumberOfRequestsToBeGenerated = - _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); - Count_T lIntegerNumberOfRequestsToBeGenerated = 0; - if (lRealNumberOfRequestsToBeGenerated < 0.5) { - lIntegerNumberOfRequestsToBeGenerated = 0; - } else { - lIntegerNumberOfRequestsToBeGenerated = - static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); - } - _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; - } - - // //////////////////////////////////////////////////////////////////// - const bool DemandStream::stillHavingRequestsToBeGenerated () const { - // Check whether enough requests have already been generated - const Count_T lNbOfRequestsGeneratedSoFar = - _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); - const Count_T lRemainingNumberOfRequestsToBeGenerated = - _totalNumberOfRequestsToBeGenerated - lNbOfRequestsGeneratedSoFar; - - if (lRemainingNumberOfRequestsToBeGenerated <= 0) { - return false; - } - - return true; - - } - - // ////////////////////////////////////////////////////////////////////// - BookingRequestPtr_T DemandStream::generateNext () { - // Assert that there are requests to be generated. - const Count_T lNbOfRequestsGeneratedSoFar = - _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); - const Count_T lRemainingNumberOfRequestsToBeGenerated = - _totalNumberOfRequestsToBeGenerated - lNbOfRequestsGeneratedSoFar; - assert (lRemainingNumberOfRequestsToBeGenerated > 0); - - - // Origin - const AirportCode_T& lOrigin = _demandCharacteristics.getOrigin (); - // Destination - const AirportCode_T& lDestination = _demandCharacteristics.getDestination (); - // Preferred departure date - const Date_T& lPreferredDepartureDate = - _demandCharacteristics.getPreferredDepartureDate (); - // Passenger type. - const PassengerType_T& lPassengerType = _demandCharacteristics.getPaxType(); - - // Request datetime, determined from departure date and arrival pattern - // Sequential generation - const Probability_T lCumulativeProbabilitySoFar = - _randomGenerationContext.getCumulativeProbabilitySoFar (); - - const Probability_T lVariate = - _requestDateTimeRandomGenerator.generateUniform01 (); - - const Probability_T lCumulativeProbabilityThisRequest = - 1.0 - (1.0 - lCumulativeProbabilitySoFar) * pow(1 - lVariate, 1.0 / static_cast<float> (lRemainingNumberOfRequestsToBeGenerated)); - - const FloatDuration_T lNumberOfDaysBetweenDepartureAndThisRequest = - _demandCharacteristics.getArrivalPattern().getValue (lCumulativeProbabilityThisRequest); - - // convert the number of days in number of seconds + number of milliseconds - const FloatDuration_T lNumberOfSeconds = - lNumberOfDaysBetweenDepartureAndThisRequest - * static_cast<float> (SECONDS_IN_ONE_DAY); - - const IntDuration_T lIntNumberOfSeconds = floor(lNumberOfSeconds); - - const FloatDuration_T lNumberOfMilliseconds = - (lNumberOfSeconds - lIntNumberOfSeconds) - * static_cast<float> (MILLISECONDS_IN_ONE_SECOND); - - const IntDuration_T lIntNumberOfMilliseconds = - floor(lNumberOfMilliseconds) + 1; // +1 is a trick to ensure that the next - // event is strictly later than the current one - - const Duration_T lDifferenceBetweenDepartureAndThisRequest = - boost::posix_time::seconds(lIntNumberOfSeconds) - + boost::posix_time::millisec(lIntNumberOfMilliseconds); - - const Time_T lHardcodedReferenceDepartureTime = boost::posix_time::hours(8); - - const DateTime_T lDepartureDateTime = - boost::posix_time::ptime (lPreferredDepartureDate, - lHardcodedReferenceDepartureTime); - - const DateTime_T lDateTimeThisRequest = - lDepartureDateTime + lDifferenceBetweenDepartureAndThisRequest; - - // Update random generation context - _randomGenerationContext.setCumulativeProbabilitySoFar (lCumulativeProbabilityThisRequest); - _randomGenerationContext.incrementGeneratedRequestsCounter (); - - - // Create the booking request with a hardcoded party size. - BookingRequestPtr_T oBookingRequest_ptr = - BookingRequestPtr_T (new BookingRequestStruct (lOrigin, lDestination, - lPreferredDepartureDate, - lDateTimeThisRequest, - lPassengerType, 1)); - assert (oBookingRequest_ptr != NULL); - return oBookingRequest_ptr; - } - -} Deleted: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -1,125 +0,0 @@ -#ifndef __STDAIR_BAS_DEMAND_STREAM_HPP -#define __STDAIR_BAS_DEMAND_STREAM_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// Boost -#include <boost/shared_ptr.hpp> -// STL -#include <iosfwd> -// STDAIR -#include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/DemandCharacteristics.hpp> -#include <stdair/basic/DemandDistribution.hpp> -#include <stdair/basic/RandomGeneration.hpp> -#include <stdair/basic/RandomGenerationContext.hpp> -#include <stdair/bom/BomContent.hpp> -#include <stdair/bom/BookingRequestStruct.hpp> - -namespace stdair { - - // Type definitions. - /** Define the smart pointer to a booking request. */ - typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; - - /** Class modeling a demand stream. */ - class DemandStream : public BomContent { - friend class FacBomContent; - - public: - // ///////////// Getters /////////// - /** Get the key */ - const DemandStreamKey_T& getKey () const { - return _key; - } - - /** Get the total number of requests to be generated. */ - const Count_T& getTotalNumberOfRequestsToBeGenerated() const { - return _totalNumberOfRequestsToBeGenerated; - } - - public: - // ///////////// Setters /////////// - /** Set the demand characteristics */ - void setKey (const DemandStreamKey_T& iKey) { - _key = iKey; - } - - public: - // /////////// Display support methods ///////// - /** Dump a Business Object into an output stream. - @param ostream& the output stream. */ - void toStream (std::ostream& ioOut) const { ioOut << toString(); } - - /** Read a Business Object from an input stream. - @param istream& the input stream. */ - void fromStream (std::istream& ioIn) { } - - /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } - - /** Get a string describing the whole key (differentiating two objects - at any level). */ - const std::string describeKey() const { return std::string (""); } - - /** Get a string describing the short key (differentiating two objects - at the same level). */ - const std::string describeShortKey() const { return std::string (""); } - - public: - // /////////////// Business Methods ////////////// - /** Check whether enough requests have already been generated. */ - const bool stillHavingRequestsToBeGenerated () const; - - /** Generate the next request. */ - BookingRequestPtr_T generateNext (); - - private: - // ////////// Constructors and destructors ///////// - /** Constructor by default */ - DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, - const DemandDistribution&, const RandomSeed_T&, - const RandomSeed_T&, const RandomSeed_T&); - - /** Destructor */ - virtual ~DemandStream (); - - /** Default constructors. */ - DemandStream (); - DemandStream (const DemandStream&); - - /** Initialization. */ - void init(); - - private: - // ////////// Attributes ////////// - - /** Key */ - DemandStreamKey_T _key; - - /** Demand characteristics */ - DemandCharacteristics _demandCharacteristics; - - /** Demand distribution */ - DemandDistribution _demandDistribution; - - /** Total number of requests to be generated*/ - Count_T _totalNumberOfRequestsToBeGenerated; - - /** Random generation context */ - RandomGenerationContext _randomGenerationContext; - - /** Random generator for number of requests */ - RandomGeneration _numberOfRequestsRandomGenerator; - - /** Random generator for request datetime */ - RandomGeneration _requestDateTimeRandomGenerator; - - /** Random generator for demand characteristics */ - RandomGeneration _demandCharacteristicsRandomGenerator; - - }; - -} -#endif // __STDAIR_BAS_DEMAND_STREAM_HPP Modified: trunk/stdair/stdair/bom/EventQueue.cpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventQueue.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -2,18 +2,13 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR +#include <stdair/bom/EventStruct.hpp> #include <stdair/bom/EventQueue.hpp> namespace stdair { // ////////////////////////////////////////////////////////////////////// - EventQueue::EventQueue (const DateTime_T& iEarliestDateTime) { - // Earliest time is necessary in order to set _currentEvent - // "before" any event. Without it, _currentEvent would need to be - // set to the first event, the first an event is added - EventStruct lEarliestEvent (iEarliestDateTime); - _eventList.insert(EventListElement_T (iEarliestDateTime, lEarliestEvent)); - _currentEvent = _eventList.begin (); + EventQueue::EventQueue () { } // ////////////////////////////////////////////////////////////////////// @@ -21,34 +16,33 @@ } // ////////////////////////////////////////////////////////////////////// - EventStruct* EventQueue::popEvent () { - EventStruct* oEventStruct_ptr = NULL; - if (!isQueueDone ()) { - ++_currentEvent; - oEventStruct_ptr = &(_currentEvent->second); - } - return oEventStruct_ptr; + EventStruct& EventQueue::popEvent () { + assert (isQueueDone() == false); + return _eventList.begin()->second; } // ////////////////////////////////////////////////////////////////////// - void EventQueue::addEvent (const EventStruct& iEventStruct) { - DateTime_T lEventDateTime = iEventStruct.getEventDateTime (); - _eventList.insert( std::pair<DateTime_T, EventStruct> (lEventDateTime, iEventStruct) ); + void EventQueue::addEvent (EventStruct& ioEventStruct) { + const DateTime_T& lEventDateTime = ioEventStruct.getEventDateTime (); + const bool insertionSucceeded = + _eventList.insert (EventListElement_T (lEventDateTime, ioEventStruct)).second; + + // If the insertion is not succeded. + if (insertionSucceeded == false) { + ioEventStruct.moveForwardInTime(); + addEvent (ioEventStruct); + } } + // //////////////////////////////////////////////////////////////////// + void EventQueue::eraseLastUsedEvent () { + assert (isQueueDone () == false); + _eventList.erase (_eventList.begin()); + } + // ////////////////////////////////////////////////////////////////////// const bool EventQueue::isQueueDone () const { - bool oFlagDone = false; - if (_currentEvent == _eventList.end ()) { - oFlagDone = true; - } else { - EventList_T::iterator lNextEvent = _currentEvent; - ++lNextEvent; - if (lNextEvent == _eventList.end ()) { - oFlagDone = true; - } - } - return oFlagDone; + return _eventList.begin() == _eventList.end(); } // ////////////////////////////////////////////////////////////////////// @@ -65,23 +59,4 @@ return _eventList.empty (); } - // ////////////////////////////////////////////////////////////////////// - const Count_T EventQueue::getPositionOfCurrent () const { - int i = 0; - bool flag = false; - for (EventList_T::const_iterator it = _eventList.begin (); - it != _eventList.end (); ++it) { - if (it == _currentEvent) { - flag = true; - break; - } - ++i; - } - if (flag) { - return i; - } else { - return -1; - } - } - } Modified: trunk/stdair/stdair/bom/EventQueue.hpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -1,49 +1,43 @@ -#ifndef __STDAIR_BAS_EVENTQUEUE_HPP -#define __STDAIR_BAS_EVENTQUEUE_HPP +#ifndef __STDAIR_BOM_EVENTQUEUE_HPP +#define __STDAIR_BOM_EVENTQUEUE_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR #include <stdair/STDAIR_Types.hpp> -#include <stdair/bom/EventStruct.hpp> +#include <stdair/bom/StructAbstract.hpp> +#include <stdair/bom/EventTypes.hpp> namespace stdair { /** Event queue. */ - class EventQueue { - + struct EventQueue : public StructAbstract { + public: - typedef std::pair<DateTime_T, EventStruct> EventListElement_T; - typedef std::multimap<DateTime_T, EventStruct> EventList_T; - - public: - // ///////////// Getters /////////// - // /** Get the event type */ - //const EventType_T& getEventType () const { - // return _eventType; - //} + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) {} + + /** Display of the structure. */ + const std::string describe() const { return ""; } public: - // ////////// Constructors and destructors ///////// - /** Constructor. */ - EventQueue (const DateTime_T&); - - /** Destructor. */ - virtual ~EventQueue (); - - public: // ////////// Business methods ///////// - /** Pop event */ - EventStruct* popEvent (); + /** Pop event. */ + EventStruct& popEvent (); - /** Add event */ - void addEvent (const EventStruct&); + /** Add event. + <br>If there already is an event with the same datetime, move the given + event one nanosecond forward and retry the insertion until succeed. */ + void addEvent (EventStruct&); + + /** Erase the last used event. */ + void eraseLastUsedEvent (); /** Is queue done */ const bool isQueueDone () const; - - + // ////////// Debug methods ///////// /** Queue size */ const Count_T getQueueSize () const; @@ -51,23 +45,20 @@ /** Is queue empty */ const bool isQueueEmpty () const; - /** Get position of current */ - const Count_T getPositionOfCurrent () const; - - private: + public: + // ////////// Constructors and destructors ///////// /** Default constructors. */ + EventQueue (); + /** Copy constructor. */ EventQueue (const EventQueue&); + /** Destructor. */ + ~EventQueue (); private: // ////////// Attributes ////////// - /** Event list */ EventList_T _eventList; - - /** Pointer to current event */ - EventList_T::iterator _currentEvent; - }; } -#endif // __STDAIR_BAS_EVENTQUEUE_HPP +#endif // __STDAIR_BOM_EVENTQUEUE_HPP Modified: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -2,6 +2,7 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR +#include <stdair/basic/BasConst_General.hpp> #include <stdair/bom/BookingRequestStruct.hpp> #include <stdair/bom/EventStruct.hpp> @@ -10,10 +11,11 @@ // ////////////////////////////////////////////////////////////////////// EventStruct:: EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, - DemandStream& ioDemandStream, BookingRequestPtr_T ioRequestPtr) + const DemandStreamKey_T& iDemandStreamKey, + BookingRequestPtr_T ioRequestPtr) : _eventType (iEventType), _eventDateTime (iDateTime), - _demandStream (&ioDemandStream) { + _demandStreamKey (iDemandStreamKey) { _request = ioRequestPtr; } @@ -22,7 +24,7 @@ EventStruct (const EventStruct& iEventStruct) : _eventType (iEventStruct._eventType), _eventDateTime (iEventStruct._eventDateTime), - _demandStream (iEventStruct._demandStream) { + _demandStreamKey (iEventStruct._demandStreamKey) { _request = iEventStruct._request; } @@ -30,11 +32,16 @@ EventStruct::EventStruct (const DateTime_T& iDateTime) : _eventType (""), _eventDateTime (iDateTime), - _demandStream (NULL) { + _demandStreamKey (-1) { } // ////////////////////////////////////////////////////////////////////// EventStruct::~EventStruct () { } + // //////////////////////////////////////////////////////////////////// + void EventStruct::moveForwardInTime () { + _eventDateTime += DEFAULT_EPSILON_DURATION; + } + } Modified: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -4,21 +4,12 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// Boost -#include <boost/shared_ptr.hpp> // STDAIR #include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/BookingRequestTypes.hpp> namespace stdair { - - /** Forward declaration */ - struct BookingRequestStruct; - class DemandStream; - // Type definitions. - /** Define the smart pointer to a booking request. */ - typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; - /** Event struct. */ struct EventStruct { @@ -41,16 +32,19 @@ } /** Get the demand stream of the event. */ - DemandStream& getDemandStream () const { - assert (_demandStream != NULL); - return *_demandStream; + const DemandStreamKey_T& getDemandStreamKey () const { + return _demandStreamKey; } + + // ///////////////// Business Methods ///////////////// + /** Move the event forward in time by one nanosecond. */ + void moveForwardInTime (); public: // ////////// Constructors and destructors ///////// /** Constructor. */ EventStruct (const EventType_T&, const DateTime_T&, - DemandStream&, BookingRequestPtr_T); + const DemandStreamKey_T&, BookingRequestPtr_T); EventStruct (const DateTime_T&); /** Copy constructor. */ @@ -74,7 +68,7 @@ DateTime_T _eventDateTime; /** The demand stream which generated this event. */ - DemandStream* _demandStream; + DemandStreamKey_T _demandStreamKey; /** Pointer to Request event */ BookingRequestPtr_T _request; Copied: trunk/stdair/stdair/bom/EventTypes.hpp (from rev 124, trunk/stdair/stdair/bom/InventoryTypes.hpp) =================================================================== --- trunk/stdair/stdair/bom/EventTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/EventTypes.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -0,0 +1,26 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_EVENTTYPES_HPP +#define __STDAIR_BOM_EVENTTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + // Forward declarations. + struct EventStruct; + + // Define a list of events. + typedef std::map<const DateTime_T, EventStruct> EventList_T; + + // Define an element of a event list. + typedef std::pair<const DateTime_T, EventStruct> EventListElement_T; + +} +#endif // __STDAIR_BOM_EVENTTYPES_HPP + Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-10 17:13:38 UTC (rev 126) @@ -86,9 +86,9 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ - $(top_srcdir)/stdair/bom/DemandStream.hpp \ $(top_srcdir)/stdair/bom/EventStruct.hpp \ $(top_srcdir)/stdair/bom/EventQueue.hpp \ + $(top_srcdir)/stdair/bom/EventTypes.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ @@ -138,7 +138,6 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ - $(top_srcdir)/stdair/bom/DemandStream.cpp \ $(top_srcdir)/stdair/bom/EventStruct.cpp \ $(top_srcdir)/stdair/bom/EventQueue.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp Modified: trunk/stdair/stdair/factory/FacBomContent.cpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/factory/FacBomContent.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -5,7 +5,6 @@ #include <cassert> // STDAIR #include <stdair/bom/BomStructure.hpp> -#include <stdair/bom/DemandStream.hpp> #include <stdair/bom/BomContent.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> @@ -48,27 +47,4 @@ _instance = NULL; } - // //////////////////////////////////////////////////////////////////// - DemandStream& FacBomContent:: - createDemandStream (const DemandStreamKey_T& iKey, - const DemandCharacteristics& iDemandCharacteristics, - const DemandDistribution& iDemandDistribution, - const RandomSeed_T& iNumberOfRequestsSeed, - const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed) { - DemandStream* aDemandStream_ptr = NULL; - - aDemandStream_ptr = new DemandStream (iKey, iDemandCharacteristics, - iDemandDistribution, - iNumberOfRequestsSeed, - iRequestDateTimeSeed, - iDemandCharacteristicsSeed); - assert (aDemandStream_ptr != NULL); - - // The new object is added to the BOM pool - _contentPool.push_back (aDemandStream_ptr); - - return *aDemandStream_ptr; - } - } Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -20,7 +20,7 @@ template<typename BOM> struct BomList_T; class BomStructure; class BomContent; - class DemandStream; + class EventQueue; struct OptimizerStruct_T; struct DemandCharacteristics; struct DemandDistribution; @@ -173,16 +173,6 @@ iReferenceOutboundPath._flightPathCode; } - // ////////////////////////////////////////////////////////////////// - // //////////////////////// Normal Factory ////////////////////////// - // ////////////////////////////////////////////////////////////////// - /** Create the DemandStream object. */ - DemandStream& createDemandStream (const DemandStreamKey_T&, - const DemandCharacteristics&, - const DemandDistribution&, - const RandomSeed_T&, - const RandomSeed_T&, const RandomSeed_T&); - public: /** Provide the unique instance. <br>The singleton is instantiated when first used. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-10 10:14:16
|
Revision: 125 http://stdair.svn.sourceforge.net/stdair/?rev=125&view=rev Author: quannaus Date: 2010-02-10 10:14:09 +0000 (Wed, 10 Feb 2010) Log Message: ----------- [dev] Some changes in several objects for the demand generation. Modified Paths: -------------- trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp trunk/stdair/stdair/factory/FacBomContent.cpp trunk/stdair/stdair/factory/FacBomContent.hpp Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-10 10:14:09 UTC (rev 125) @@ -21,10 +21,12 @@ // ///////////////////////////////////////////////////// DemandCharacteristics:: - DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) { - _origin = iDemandCharacteristics._origin; - _preferredDepartureDate = iDemandCharacteristics._preferredDepartureDate; - _arrivalPattern = iDemandCharacteristics._arrivalPattern; + DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) + : _origin (iDemandCharacteristics._origin), + _destination (iDemandCharacteristics._destination), + _preferredDepartureDate (iDemandCharacteristics._preferredDepartureDate), + _paxType (iDemandCharacteristics._paxType), + _arrivalPattern (iDemandCharacteristics._arrivalPattern) { } // ///////////////////////////////////////////////////// Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-10 10:14:09 UTC (rev 125) @@ -18,14 +18,24 @@ // ///////////// Getters /////////// /** Get the origin. */ - const LocationCode_T& getOrigin() const { + const AirportCode_T& getOrigin() const { return _origin; } + /** Get the destination. */ + const AirportCode_T& getDestination() const { + return _destination; + } + /** Get the preferred departure date. */ const Date_T& getPreferredDepartureDate() const { return _preferredDepartureDate; } + + /** Get the passenger type. */ + const PassengerType_T& getPaxType() const { + return _paxType; + } /** Get the arrival pattern. */ const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { @@ -35,15 +45,25 @@ public: // ///////////// Setters /////////// /** Set the origin. */ - void setOrigin (const LocationCode_T& iOrigin) { + void setOrigin (const AirportCode_T& iOrigin) { _origin = iOrigin; } + + /** Set the destination. */ + void setDestination (const AirportCode_T& iDestination) { + _destination = iDestination; + } /** Set the preferred departure date. */ void setPreferredDepartureDate (const Date_T& iPreferredDepartureDate) { _preferredDepartureDate = iPreferredDepartureDate; } + /** Set the passenger type. */ + void setPaxType (const PassengerType_T& iPaxType) { + _paxType = iPaxType; + } + /** Set the arrival pattern. */ void setArrivalPattern (const ContinuousAttribute<FloatDuration_T>& iArrivalPattern) { _arrivalPattern = iArrivalPattern; @@ -70,10 +90,16 @@ private: // ////////// Attributes ////////// /** Origin */ - LocationCode_T _origin; + AirportCode_T _origin; + /** Origin */ + AirportCode_T _destination; + /** Preferred departure date */ Date_T _preferredDepartureDate; + + /** Passenger type. */ + PassengerType_T _paxType; /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date @@ -81,10 +107,10 @@ ContinuousAttribute<FloatDuration_T> _arrivalPattern; /** Trip type probability mass */ - //CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; + // CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; /** Willingness-to-pay cumulative distribution */ - //ContinuousAttribute<MonetaryValue_T> _willingnessToPayCumulativeDistribution; + // ContinuousAttribute<MonetaryValue_T> _willingnessToPayCumulativeDistribution; }; Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-10 10:14:09 UTC (rev 125) @@ -10,10 +10,6 @@ #include <stdair/bom/BookingRequestStruct.hpp> namespace stdair { - - // ////////////////////////////////////////////////////////////////////// - BookingRequestStruct::BookingRequestStruct () { - } // ////////////////////////////////////////////////////////////////////// BookingRequestStruct::BookingRequestStruct (const AirportCode_T& iOrigin, Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-10 10:14:09 UTC (rev 125) @@ -15,6 +15,8 @@ /** Structure holding the elements of a booking request. */ struct BookingRequestStruct : public StructAbstract { + friend class DemandStream; + public: // /////////////// Getters ///////////////// /** Get the requested origin. */ @@ -92,12 +94,15 @@ /** Display of the structure. */ const std::string describe() const; - public: + private : // /////////////// Constructors and Destructors ///////////////// BookingRequestStruct (); + public : BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, const PassengerType_T&, const NbOfSeats_T&); + BookingRequestStruct (const BookingRequestStruct&); + public: ~BookingRequestStruct(); Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-10 10:14:09 UTC (rev 125) @@ -60,9 +60,9 @@ } _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; } - - // ////////////////////////////////////////////////////////////////////// - bool DemandStream::generateNext (BookingRequestStruct& ioRequest) { + + // //////////////////////////////////////////////////////////////////// + const bool DemandStream::stillHavingRequestsToBeGenerated () const { // Check whether enough requests have already been generated const Count_T lNbOfRequestsGeneratedSoFar = _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); @@ -72,17 +72,31 @@ if (lRemainingNumberOfRequestsToBeGenerated <= 0) { return false; } - // DEBUG - STDAIR_LOG_DEBUG ("Here"); + return true; + + } + + // ////////////////////////////////////////////////////////////////////// + BookingRequestPtr_T DemandStream::generateNext () { + // Assert that there are requests to be generated. + const Count_T lNbOfRequestsGeneratedSoFar = + _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); + const Count_T lRemainingNumberOfRequestsToBeGenerated = + _totalNumberOfRequestsToBeGenerated - lNbOfRequestsGeneratedSoFar; + assert (lRemainingNumberOfRequestsToBeGenerated > 0); + + // Origin - ioRequest.setOrigin (_demandCharacteristics.getOrigin ()); - + const AirportCode_T& lOrigin = _demandCharacteristics.getOrigin (); + // Destination + const AirportCode_T& lDestination = _demandCharacteristics.getDestination (); // Preferred departure date - const Date_T lPreferredDepartureDate = + const Date_T& lPreferredDepartureDate = _demandCharacteristics.getPreferredDepartureDate (); - ioRequest.setPreferredDepartureDate (lPreferredDepartureDate); - + // Passenger type. + const PassengerType_T& lPassengerType = _demandCharacteristics.getPaxType(); + // Request datetime, determined from departure date and arrival pattern // Sequential generation const Probability_T lCumulativeProbabilitySoFar = @@ -99,34 +113,45 @@ // convert the number of days in number of seconds + number of milliseconds const FloatDuration_T lNumberOfSeconds = - lNumberOfDaysBetweenDepartureAndThisRequest*static_cast<float> (SECONDS_IN_ONE_DAY); + lNumberOfDaysBetweenDepartureAndThisRequest + * static_cast<float> (SECONDS_IN_ONE_DAY); const IntDuration_T lIntNumberOfSeconds = floor(lNumberOfSeconds); const FloatDuration_T lNumberOfMilliseconds = - (lNumberOfSeconds - lIntNumberOfSeconds) * static_cast<float> (MILLISECONDS_IN_ONE_SECOND); + (lNumberOfSeconds - lIntNumberOfSeconds) + * static_cast<float> (MILLISECONDS_IN_ONE_SECOND); const IntDuration_T lIntNumberOfMilliseconds = - floor(lNumberOfMilliseconds) + 1; // +1 is a trick to ensure that the next event is strictly later than the current one + floor(lNumberOfMilliseconds) + 1; // +1 is a trick to ensure that the next + // event is strictly later than the current one const Duration_T lDifferenceBetweenDepartureAndThisRequest = - boost::posix_time::seconds(lIntNumberOfSeconds) + boost::posix_time::millisec(lIntNumberOfMilliseconds); + boost::posix_time::seconds(lIntNumberOfSeconds) + + boost::posix_time::millisec(lIntNumberOfMilliseconds); const Time_T lHardcodedReferenceDepartureTime = boost::posix_time::hours(8); -const DateTime_T lDepartureDateTime = - boost::posix_time::ptime(lPreferredDepartureDate, lHardcodedReferenceDepartureTime); + const DateTime_T lDepartureDateTime = + boost::posix_time::ptime (lPreferredDepartureDate, + lHardcodedReferenceDepartureTime); const DateTime_T lDateTimeThisRequest = lDepartureDateTime + lDifferenceBetweenDepartureAndThisRequest; - ioRequest.setRequestDateTime (lDateTimeThisRequest); - + // Update random generation context _randomGenerationContext.setCumulativeProbabilitySoFar (lCumulativeProbabilityThisRequest); _randomGenerationContext.incrementGeneratedRequestsCounter (); - - return true; - + + + // Create the booking request with a hardcoded party size. + BookingRequestPtr_T oBookingRequest_ptr = + BookingRequestPtr_T (new BookingRequestStruct (lOrigin, lDestination, + lPreferredDepartureDate, + lDateTimeThisRequest, + lPassengerType, 1)); + assert (oBookingRequest_ptr != NULL); + return oBookingRequest_ptr; } } Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-10 10:14:09 UTC (rev 125) @@ -4,6 +4,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> // STL #include <iosfwd> // STDAIR @@ -12,13 +14,19 @@ #include <stdair/basic/DemandDistribution.hpp> #include <stdair/basic/RandomGeneration.hpp> #include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BomContent.hpp> #include <stdair/bom/BookingRequestStruct.hpp> namespace stdair { + + // Type definitions. + /** Define the smart pointer to a booking request. */ + typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; /** Class modeling a demand stream. */ - class DemandStream { - + class DemandStream : public BomContent { + friend class FacBomContent; + public: // ///////////// Getters /////////// /** Get the key */ @@ -37,13 +45,37 @@ void setKey (const DemandStreamKey_T& iKey) { _key = iKey; } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { ioOut << toString(); } + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) { } + + /** Get the serialised version of the Business Object. */ + std::string toString() const { return describeKey(); } + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const { return std::string (""); } + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + const std::string describeShortKey() const { return std::string (""); } + public: - // /////////////// Business Methods ////////// + // /////////////// Business Methods ////////////// + /** Check whether enough requests have already been generated. */ + const bool stillHavingRequestsToBeGenerated () const; + /** Generate the next request. */ - bool generateNext (BookingRequestStruct&); + BookingRequestPtr_T generateNext (); - public: + private: // ////////// Constructors and destructors ///////// /** Constructor by default */ DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, @@ -53,7 +85,6 @@ /** Destructor */ virtual ~DemandStream (); - private: /** Default constructors. */ DemandStream (); DemandStream (const DemandStream&); Modified: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-10 10:14:09 UTC (rev 125) @@ -10,14 +10,11 @@ // ////////////////////////////////////////////////////////////////////// EventStruct:: EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, - DemandStream& ioDemandStream, BookingRequestStruct* const iRequest) + DemandStream& ioDemandStream, BookingRequestPtr_T ioRequestPtr) : _eventType (iEventType), _eventDateTime (iDateTime), - _demandStream (&ioDemandStream), - _request (NULL) { - if (iEventType == "Request") { - _request = iRequest; - } + _demandStream (&ioDemandStream) { + _request = ioRequestPtr; } // ////////////////////////////////////////////////////////////////////// @@ -25,15 +22,15 @@ EventStruct (const EventStruct& iEventStruct) : _eventType (iEventStruct._eventType), _eventDateTime (iEventStruct._eventDateTime), - _demandStream (iEventStruct._demandStream), - _request (iEventStruct._request) { + _demandStream (iEventStruct._demandStream) { + _request = iEventStruct._request; } // ////////////////////////////////////////////////////////////////////// EventStruct::EventStruct (const DateTime_T& iDateTime) : _eventType (""), _eventDateTime (iDateTime), - _request (NULL) { + _demandStream (NULL) { } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-10 10:14:09 UTC (rev 125) @@ -4,6 +4,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> // STDAIR #include <stdair/STDAIR_Types.hpp> @@ -12,6 +14,10 @@ /** Forward declaration */ struct BookingRequestStruct; class DemandStream; + + // Type definitions. + /** Define the smart pointer to a booking request. */ + typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; /** Event struct. */ struct EventStruct { @@ -28,9 +34,10 @@ return _eventDateTime; } - /** Get the pointer Request event. */ - const BookingRequestStruct* getPointerToRequestEvent () const { - return _request; + /** Get the Request event. */ + const BookingRequestStruct& getBookingRequest () const { + assert (_request != NULL); + return *_request; } /** Get the demand stream of the event. */ @@ -43,7 +50,7 @@ // ////////// Constructors and destructors ///////// /** Constructor. */ EventStruct (const EventType_T&, const DateTime_T&, - DemandStream&, BookingRequestStruct* const); + DemandStream&, BookingRequestPtr_T); EventStruct (const DateTime_T&); /** Copy constructor. */ @@ -70,7 +77,7 @@ DemandStream* _demandStream; /** Pointer to Request event */ - BookingRequestStruct* _request; + BookingRequestPtr_T _request; }; Modified: trunk/stdair/stdair/factory/FacBomContent.cpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.cpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/factory/FacBomContent.cpp 2010-02-10 10:14:09 UTC (rev 125) @@ -5,6 +5,7 @@ #include <cassert> // STDAIR #include <stdair/bom/BomStructure.hpp> +#include <stdair/bom/DemandStream.hpp> #include <stdair/bom/BomContent.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> @@ -47,4 +48,27 @@ _instance = NULL; } + // //////////////////////////////////////////////////////////////////// + DemandStream& FacBomContent:: + createDemandStream (const DemandStreamKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) { + DemandStream* aDemandStream_ptr = NULL; + + aDemandStream_ptr = new DemandStream (iKey, iDemandCharacteristics, + iDemandDistribution, + iNumberOfRequestsSeed, + iRequestDateTimeSeed, + iDemandCharacteristicsSeed); + assert (aDemandStream_ptr != NULL); + + // The new object is added to the BOM pool + _contentPool.push_back (aDemandStream_ptr); + + return *aDemandStream_ptr; + } + } Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-08 16:32:09 UTC (rev 124) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-10 10:14:09 UTC (rev 125) @@ -20,7 +20,10 @@ template<typename BOM> struct BomList_T; class BomStructure; class BomContent; + class DemandStream; struct OptimizerStruct_T; + struct DemandCharacteristics; + struct DemandDistribution; /** Base class for Factory layer. */ class FacBomContent { @@ -169,6 +172,16 @@ ioOutboundPath._flightPathCode = iReferenceOutboundPath._flightPathCode; } + + // ////////////////////////////////////////////////////////////////// + // //////////////////////// Normal Factory ////////////////////////// + // ////////////////////////////////////////////////////////////////// + /** Create the DemandStream object. */ + DemandStream& createDemandStream (const DemandStreamKey_T&, + const DemandCharacteristics&, + const DemandDistribution&, + const RandomSeed_T&, + const RandomSeed_T&, const RandomSeed_T&); public: /** Provide the unique instance. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-08 16:32:16
|
Revision: 124 http://stdair.svn.sourceforge.net/stdair/?rev=124&view=rev Author: quannaus Date: 2010-02-08 16:32:09 +0000 (Mon, 08 Feb 2010) Log Message: ----------- [Dev] Added the objects for trademgen use. Still need to refine the code. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_General.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/sources.mk Added Paths: ----------- trunk/stdair/stdair/basic/CategoricalAttribute.hpp trunk/stdair/stdair/basic/ContinuousAttribute.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/basic/DemandDistribution.cpp trunk/stdair/stdair/basic/DemandDistribution.hpp trunk/stdair/stdair/basic/RandomGeneration.cpp trunk/stdair/stdair/basic/RandomGeneration.hpp trunk/stdair/stdair/basic/RandomGenerationContext.cpp trunk/stdair/stdair/basic/RandomGenerationContext.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/EventQueue.cpp trunk/stdair/stdair/bom/EventQueue.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -7,7 +7,10 @@ // STL #include <string> #include <vector> +#include <list> #include <map> +// Boost Random +#include <boost/random/linear_congruential.hpp> // Boost (Extended STL) #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/posix_time.hpp> @@ -123,6 +126,9 @@ /** Define the Duration (e.g., elapsed in-flight time). */ typedef boost::posix_time::time_duration Duration_T; + /** Time */ + typedef boost::posix_time::time_duration Time_T; + /** Define an accurate time (date +time). */ typedef boost::posix_time::ptime DateTime_T; @@ -388,6 +394,56 @@ /** Pointer on the STDAIR Service handler. */ typedef boost::shared_ptr<STDAIR_Service> STDAIR_ServicePtr_T; + + // ////////////////////////////////////////////////////////////////////// + // Random generation + /** Seed for the random generation, so that it can be reproductible. */ + typedef unsigned long int RandomSeed_T; + /** Random number generator. */ + typedef boost::minstd_rand BaseGenerator_T; + + // ////////////////////////////////////////////////////////////////////// + // Probability + /** Probability */ + typedef float Probability_T; + + // ////////////////////////////////////////////////////////////////////// + // Date / Time + /** Time duration in (integer) number of seconds */ + typedef long int IntDuration_T; + + /** Duration in (float) number of time units */ + typedef float FloatDuration_T; + + // ////////////////////////////////////////////////////////////////////// + // Basic types + /** Event type */ + typedef std::string EventType_T; + + /** Count */ + typedef int Count_T; + + /** Location code */ + typedef std::string LocationCode_T; + + /** Airport code */ + typedef LocationCode_T AirportCode_T; + + /** City code */ + typedef LocationCode_T CityCode_T; + + /** Trip type */ + typedef std::string TripType_T; + + /** Monetary value */ + typedef double MonetaryValue_T; + + /** Real number */ + typedef double RealNumber_T; + + // ////////////////////////////////////////////////////////////////////// + // Demand + typedef int DemandStreamKey_T; } #endif // __STDAIR_STDAIR_TYPES_HPP Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -129,22 +129,18 @@ const DateOffSet_T DEFAULT_DATE_OFFSET (0); // // //////// General /////// - // /** Default update date for the General. */ - // const Date_T DEFAULT_WORLD_SCHEDULE_UPDATE_DATE (2007, - // boost::gregorian::Jan, - // 1); + /** Default update date for the General. */ + const Date_T DEFAULT_DATE (2007, boost::gregorian::Jan, 1); + /** Default update date&time. */ + const DateTime_T DEFAULT_DATETIME (DEFAULT_DATE, NULL_BOOST_TIME_DURATION); - // // //////// WholeDemand /////// - // /** Default update date for the WholeDemand. */ - // const Date_T DEFAULT_WHOLE_DEMAND_UPDATE_DATE (2007, - // boost::gregorian::Jan, - // 1); + /** Number of seconds in one day */ + const Count_T SECONDS_IN_ONE_DAY = 86000; + + /** Number of milliseconds in one second */ + const Count_T MILLISECONDS_IN_ONE_SECOND = 1000; - // /** Default update date&time. */ - // const DateTime_T DEFAULT_DEMAND_DATETIME (DEFAULT_WHOLE_DEMAND_UPDATE_DATE, - // NULL_BOOST_TIME_DURATION); - // //////// Fare Rules /////// /** Default saturdayStay value (false). */ const SaturdayStay_T DEFAULT_SATURDAY_STAY = false; Modified: trunk/stdair/stdair/basic/BasConst_General.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -36,5 +36,16 @@ /** Default booking rate for OnD bookings over overall class bookings. */ extern const BookingRatio_T DEFAULT_OND_BOOKING_RATE; + /** Number of seconds in one day */ + extern const Count_T SECONDS_IN_ONE_DAY; + + /** Number of milliseconds in one second */ + extern const Count_T MILLISECONDS_IN_ONE_SECOND; + + /** Default update date for the General. */ + extern const Date_T DEFAULT_DATE; + + /** Default update date&time. */ + extern const DateTime_T DEFAULT_DATETIME; } #endif // __STDAIR_BAS_BASCONST_GENERAL_HPP Added: trunk/stdair/stdair/basic/CategoricalAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/CategoricalAttribute.hpp (rev 0) +++ trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,98 @@ +#ifndef __STDAIR_BAS_CATEGORICALATTRIBUTE_HPP +#define __STDAIR_BAS_CATEGORICALATTRIBUTE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Class modeling the distribution of values that can be taken by a + categorical attribute. */ + template <class T> + struct CategoricalAttribute { + + public: + // ///////////// Getters /////////// + /** Get the probability mass function. */ + const std::map<T,Probability_T>& getProbabilityMassFunction() const { + return _probability_mass_function; + } + + /** Get the inverse cumulative distribution. */ + const std::map<Probability_T, T>& getInverseCumulativeDistribution () const { + return _inverse_cumulative_distribution; + } + + // ///////////// Setters /////////// + /** Set the probability mass function */ + void setProbabilityMassFunction (const std::map<T, Probability_T>& iProbabilityMassFunction) { + _probability_mass_function = iProbabilityMassFunction; + determineInverseCumulativeDistributionFromProbabilityMassFunction(); + } + + public: + // /////////////// Business Methods ////////// + /** Get value from inverse cumulative distribution. */ + T getValue(Probability_T iCumulativeProbability) { + return _inverse_cumulative_distribution.lower_bound(iCumulativeProbability)->second; + } + + public: + // ////////////// Display Support Methods ////////// + /** Display inverse cumulative distribution */ + void displayInverseCumulativeDistribution (std::ostream& ioStream) const { + for (typename std::map<Probability_T, T>::const_iterator it = _inverse_cumulative_distribution.begin(); + it != _inverse_cumulative_distribution.end(); ++it) { + ioStream << "cumulative prob: " << it->first + << " value: " << it->second << std::endl; + } + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + CategoricalAttribute (const std::map<T, Probability_T>& iProbabilityMassFunction) + : _probability_mass_function (iProbabilityMassFunction) { + determineInverseCumulativeDistributionFromProbabilityMassFunction(); + } + + /** Destructor */ + virtual ~CategoricalAttribute () { } + + private: + /** Default constructors. */ + CategoricalAttribute (); + CategoricalAttribute (const CategoricalAttribute&); + + /** Determine inverse cumulative distribution from probability mass function (initialisation). */ + void determineInverseCumulativeDistributionFromProbabilityMassFunction () { + Probability_T cumulative_probability_so_far = 0.0; + for (typename std::map<T, Probability_T>::const_iterator itProbabilityMassFunction = _probability_mass_function.begin(); + itProbabilityMassFunction != _probability_mass_function.end(); + ++itProbabilityMassFunction) { + Probability_T attribute_probability_mass = itProbabilityMassFunction->second; + if (attribute_probability_mass > 0) { + T attribute_value = itProbabilityMassFunction->first; + cumulative_probability_so_far += attribute_probability_mass; + _inverse_cumulative_distribution[cumulative_probability_so_far] = attribute_value; + } + } + } + + private: + // ////////// Attributes ////////// + /** Probability mass function */ + std::map<T, Probability_T> _probability_mass_function; + + /** Inverse cumulative distribution */ + std::map<Probability_T, T> _inverse_cumulative_distribution; + + }; +} +#endif // __STDAIR_BAS_CATEGORICALATTRIBUTE_HPP Added: trunk/stdair/stdair/basic/ContinuousAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttribute.hpp (rev 0) +++ trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,143 @@ +#ifndef __STDAIR_BAS_CONTINUOUSATTRIBUTE_HPP +#define __STDAIR_BAS_CONTINUOUSATTRIBUTE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +#include <map> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Class modeling the distribution of values that can be taken by a + continuous attribute. */ + template <class T> + struct ContinuousAttribute { + public: + // ///////////// Getters /////////// + /** Get the cumulative distribution. */ + const std::multimap<T,Probability_T>& getCumulativeDistribution() const { + return _cumulativeDistribution; + } + + /** Get the inverse cumulative distribution. */ + const std::multimap<Probability_T, T>& + getInverseCumulativeDistribution () const { + return _inverseCumulativeDistribution; + } + + public: + // ///////////// Setters /////////// + /** Set the cumulative distribution */ + void setCumulativeDistribution (const std::multimap<T, Probability_T>& iCumulativeDistribution) { + _cumulativeDistribution = iCumulativeDistribution; + determineInverseCumulativeDistributionFromCumulativeDistribution(); + } + + public: + // /////////////// Business Methods ////////// + /** Get value from inverse cumulative distribution. */ + const T getValue(const Probability_T& iCumulativeProbability) const { + typename std::multimap<Probability_T, T>::const_iterator it = + _inverseCumulativeDistribution.lower_bound (iCumulativeProbability); + + Probability_T cumulativeProbabilityNextPoint = it->first; + T valueNextPoint = it->second; + + if (it == _inverseCumulativeDistribution.begin()) { + std::cout << "hello" << std::endl; + return valueNextPoint; + } + --it; + + Probability_T cumulativeProbabilityPreviousPoint = it->first; + T valuePreviousPoint = it->second; + if (cumulativeProbabilityNextPoint == cumulativeProbabilityPreviousPoint) { + //std::cout << "hlelo2" << std::endl; + return valuePreviousPoint; + } + + //std::cout << "cumulativeProbabilityPreviousPoint: " << cumulativeProbabilityPreviousPoint << std::endl; + //std::cout << "cumulativeProbabilityNextPoint: " << cumulativeProbabilityNextPoint << std::endl; + //std::cout << "valuePreviousPoint: " << valuePreviousPoint << std::endl; + //std::cout << "valueNextPoint: " << valueNextPoint << std::endl; + + return valuePreviousPoint + (valueNextPoint - valuePreviousPoint) + * (iCumulativeProbability - cumulativeProbabilityPreviousPoint) + / (cumulativeProbabilityNextPoint - cumulativeProbabilityPreviousPoint); + } + + public: + // ////////////// Display Support Methods ////////// + /** Display cumulative distribution */ + std::string displayCumulativeDistribution() const { + std::ostringstream oStr; + for (typename std::multimap<T, Probability_T>::const_iterator it = + _cumulativeDistribution.begin(); + it != _cumulativeDistribution.end(); ++it) { + oStr << "value: " << it->first + << " cumulative probability: " << it->second << std::endl; + } + return oStr.str(); + } + + /** Display inverse cumulative distribution */ + std::string displayInverseCumulativeDistribution() const { + std::ostringstream oStr; + for (typename std::multimap<Probability_T, T>::const_iterator it = + _inverseCumulativeDistribution.begin(); + it != _inverseCumulativeDistribution.end(); ++it) { + oStr << "cumulative prob: " << it->first + << " value: " << it->second << std::endl; + } + return oStr.str(); + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + ContinuousAttribute () { } + + /** Constructor */ + ContinuousAttribute (const std::multimap<T, Probability_T>& iCumulativeDistribution) : _cumulativeDistribution (iCumulativeDistribution) { + determineInverseCumulativeDistributionFromCumulativeDistribution(); + } + + /** Copy constructor */ + ContinuousAttribute (const ContinuousAttribute& iContinuousAttribute) + : _cumulativeDistribution (iContinuousAttribute._cumulativeDistribution), + _inverseCumulativeDistribution (iContinuousAttribute._inverseCumulativeDistribution) { + } + + /** Destructor */ + virtual ~ContinuousAttribute () { } + + /** Determine inverse cumulative distribution from cumulative + distribution (initialisation). */ + void determineInverseCumulativeDistributionFromCumulativeDistribution () { + for (typename std::multimap<T, Probability_T>::iterator itCumulativeDistribution = + _cumulativeDistribution.begin(); + itCumulativeDistribution != _cumulativeDistribution.end(); + ++itCumulativeDistribution) { + _inverseCumulativeDistribution. + insert ( std::pair<float, float> (itCumulativeDistribution->second, + itCumulativeDistribution->first) ); + } + } + + private: + // ////////// Attributes ////////// + + /** Cumulative distribution */ + std::multimap<T, Probability_T> _cumulativeDistribution; + + /** Inverse cumulative distribution */ + std::multimap<Probability_T, T> _inverseCumulativeDistribution; + + }; + +} +#endif // __STDAIR_BAS_CONTINUOUSATTRIBUTE_HPP Added: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp (rev 0) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,50 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <sstream> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> + +namespace stdair { + + // ///////////////////////////////////////////////////// + DemandCharacteristics::DemandCharacteristics () + : _origin ("") { + } + + // ///////////////////////////////////////////////////// + DemandCharacteristics::~DemandCharacteristics () { + } + + // ///////////////////////////////////////////////////// + DemandCharacteristics:: + DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) { + _origin = iDemandCharacteristics._origin; + _preferredDepartureDate = iDemandCharacteristics._preferredDepartureDate; + _arrivalPattern = iDemandCharacteristics._arrivalPattern; + } + + // ///////////////////////////////////////////////////// + std::string DemandCharacteristics::display() const { + std::ostringstream oStr; + + // + oStr << "****************** Demand characteristics ******************"; + oStr << "Origin ........................... : " + << _origin << std::endl; + oStr << "Preferred departure date ......... : " + << _preferredDepartureDate << std::endl; + oStr << "Arrival pattern (days from departure, proportion):" + << std::endl; + + // + oStr << _arrivalPattern.displayCumulativeDistribution(); + + return oStr.str(); + } + +} + Added: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp (rev 0) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,92 @@ +#ifndef __STDAIR_BAS_DEMAND_CHARACTERISTICS_HPP +#define __STDAIR_BAS_DEMAND_CHARACTERISTICS_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> + +namespace stdair { + + /** Class modeling the characteristics of a demand type. */ + struct DemandCharacteristics { + public: + + // ///////////// Getters /////////// + /** Get the origin. */ + const LocationCode_T& getOrigin() const { + return _origin; + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate() const { + return _preferredDepartureDate; + } + + /** Get the arrival pattern. */ + const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + return _arrivalPattern; + } + + public: + // ///////////// Setters /////////// + /** Set the origin. */ + void setOrigin (const LocationCode_T& iOrigin) { + _origin = iOrigin; + } + + /** Set the preferred departure date. */ + void setPreferredDepartureDate (const Date_T& iPreferredDepartureDate) { + _preferredDepartureDate = iPreferredDepartureDate; + } + + /** Set the arrival pattern. */ + void setArrivalPattern (const ContinuousAttribute<FloatDuration_T>& iArrivalPattern) { + _arrivalPattern = iArrivalPattern; + } + + public: + // ////////////// Display Support Methods ////////// + /** Display demand characteristics */ + std::string display() const; + + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandCharacteristics (); + + /** Copy constructor */ + DemandCharacteristics (const DemandCharacteristics&); // Should be private, but well... + + /** Destructor */ + virtual ~DemandCharacteristics (); + + + private: + // ////////// Attributes ////////// + /** Origin */ + LocationCode_T _origin; + + /** Preferred departure date */ + Date_T _preferredDepartureDate; + + /** Arrival pattern (cumulative distribution of timing of arrival + of requests (negative number of days between departure date + and request date)*/ + ContinuousAttribute<FloatDuration_T> _arrivalPattern; + + /** Trip type probability mass */ + //CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; + + /** Willingness-to-pay cumulative distribution */ + //ContinuousAttribute<MonetaryValue_T> _willingnessToPayCumulativeDistribution; + + }; + +} +#endif // __STDAIR_BAS_DEMAND_CHARACTERISTICS_HPP Added: trunk/stdair/stdair/basic/DemandDistribution.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.cpp (rev 0) +++ trunk/stdair/stdair/basic/DemandDistribution.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,44 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <sstream> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandDistribution.hpp> + +namespace stdair { + + // ///////////////////////////////////////////////////// + DemandDistribution::DemandDistribution () { + } + + // ///////////////////////////////////////////////////// + DemandDistribution::~DemandDistribution () { + } + + // ///////////////////////////////////////////////////// + DemandDistribution:: + DemandDistribution (const DemandDistribution& iDemandDistribution) { + _meanNumberOfRequests = iDemandDistribution._meanNumberOfRequests; + _standardDeviationNumberOfRequests = + iDemandDistribution._standardDeviationNumberOfRequests; + } + + // ///////////////////////////////////////////////////// + std::string DemandDistribution::display() const { + std::ostringstream oStr; + + oStr << "****************** Demand distribution ******************" + << std::endl; + oStr << "Mean number of requests .......... : " + << _meanNumberOfRequests << std::endl; + oStr << "Std dev of number of requests .... : " + << _standardDeviationNumberOfRequests << std::endl; + + return oStr.str(); + } + +} + Added: trunk/stdair/stdair/basic/DemandDistribution.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.hpp (rev 0) +++ trunk/stdair/stdair/basic/DemandDistribution.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,70 @@ +#ifndef __STDAIR_BAS_DEMAND_DISTRIBUTION_HPP +#define __STDAIR_BAS_DEMAND_DISTRIBUTION_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> + +namespace stdair { + + /** Class modeling the distribution of a demand type. */ + struct DemandDistribution { + public: + + // ///////////// Getters /////////// + /** Get the mean number of requests. */ + const RealNumber_T& getMeanNumberOfRequests() const { + return _meanNumberOfRequests; + } + + /** Get the standard deviation of number of requests. */ + const RealNumber_T& getStandardDeviationNumberOfRequests() const { + return _standardDeviationNumberOfRequests; + } + + public: + // ///////////// Setters /////////// + /** Set the mean number of requests. */ + void setMeanNumberOfRequests (const RealNumber_T& iMean) { + _meanNumberOfRequests = iMean; + } + + /** Set the standard deviation of number of requests. */ + void setStandardDeviationNumberOfRequests (const RealNumber_T& iStandardDeviation) { + _standardDeviationNumberOfRequests = iStandardDeviation; + } + + public: + // ////////////// Display Support Methods ////////// + /** Display demand distribution */ + std::string display() const; + + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandDistribution (); + + /** Copy constructor */ + DemandDistribution (const DemandDistribution&); // Should be private, but well... + + /** Destructor */ + virtual ~DemandDistribution (); + + + private: + // ////////// Attributes ////////// + /** Mean number of requests */ + RealNumber_T _meanNumberOfRequests; + + /** Standard deviation of number of requests */ + RealNumber_T _standardDeviationNumberOfRequests; + }; + +} +#endif // __STDAIR_BAS_DEMAND_DISTRIBUTION_HPP Added: trunk/stdair/stdair/basic/RandomGeneration.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.cpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,50 @@ +// STL +#include <cassert> +#include <iostream> +// Boost +#include <boost/math/distributions/normal.hpp> +//STDAIR +#include <stdair/basic/RandomGeneration.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + RandomGeneration::RandomGeneration (const RandomSeed_T& iSeed) + : _seed (iSeed), _generator (iSeed), + _uniformGenerator (_generator, boost::uniform_real<> (0, 1)) { + init (); + } + + // ////////////////////////////////////////////////////////////////////// + RandomGeneration::~RandomGeneration () { + } + + // ////////////////////////////////////////////////////////////////////// + void RandomGeneration::init () { + } + + // ////////////////////////////////////////////////////////////////////// + RealNumber_T RandomGeneration::generateUniform01 () { + const RealNumber_T lVariateUnif = _uniformGenerator(); + return lVariateUnif; + } + + // ////////////////////////////////////////////////////////////////////// + RealNumber_T RandomGeneration:: + generateUniform (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue){ + const RealNumber_T lVariateUnif = + iMinValue + _uniformGenerator() * (iMaxValue - iMinValue); + return lVariateUnif; + } + + // ////////////////////////////////////////////////////////////////////// + RealNumber_T RandomGeneration:: + generateNormal (const RealNumber_T& mu, const RealNumber_T& sigma) { + const Probability_T lVariateUnif = generateUniform01 (); + const boost::math::normal lNormal (mu, sigma); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + boost::math::quantile(lNormal, lVariateUnif); + + return lRealNumberOfRequestsToBeGenerated; + } +} Added: trunk/stdair/stdair/basic/RandomGeneration.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.hpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,74 @@ +#ifndef __STDAIR_BAS_BOM_RANDOMGENERATION_HPP +#define __STDAIR_BAS_BOM_RANDOMGENERATION_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost Random +#include <boost/random/uniform_real.hpp> +#include <boost/random/variate_generator.hpp> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Random generator. */ + struct RandomGeneration { + public: + // ///////////// Getters /////////// + /** Get the seed of the random generator. */ + const RandomSeed_T& getSeed () const { + return _seed; + } + + // //////////// Business Methods ///////////// + /** Generate a randomized number following a uniform distribution between 0 (included) and 1 (excluded). */ + RealNumber_T generateUniform01 (); + + /** Generate a randomized number following a uniform distribution between a minimum (included) and a maximum (excluded) value. */ + RealNumber_T generateUniform (const RealNumber_T&, const RealNumber_T&); + + /** Generate a randomized number following a normal distribution specified by a mean and a standard deviation. */ + RealNumber_T generateNormal (const RealNumber_T&, const RealNumber_T&); + + public: + // ////////// Constructors and destructors ///////// + /** Constructor. */ + RandomGeneration (const RandomSeed_T&); + + /** Destructor. */ + virtual ~RandomGeneration (); + + private: + /** Default constructors. */ + RandomGeneration (); + RandomGeneration (const RandomGeneration&); + + /** Initialize the random generator. + <br>A uniform random number distribution is defined, which + produces "real" values between 0 and 1 (0 inclusive, 1 + exclusive). */ + void init (); + + + private: + // ////////// Attributes ////////// + /** The seed of the random generator. + <br>The seed is unsigned, otherwise the wrong overload may be + selected when using mt19937 as the boost::base_generator_type. */ + RandomSeed_T _seed; + + /** Random number generator engine. + <br>The random number generator is currently based on boost::minstd_rand. + Alternates are boost::mt19937, boost::ecuyer1988. */ + BaseGenerator_T _generator; + + /** Random number generator. + <br>It is initialized with a reproducible seed and a uniform + distribution. */ + boost::variate_generator<BaseGenerator_T&, + boost::uniform_real<> > _uniformGenerator; + }; + +} +#endif // __STDAIR_BAS_BOM_RANDOMGENERATION_HPP Added: trunk/stdair/stdair/basic/RandomGenerationContext.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.cpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,26 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// STDAIR +#include <stdair/basic/RandomGenerationContext.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + RandomGenerationContext::RandomGenerationContext () + : _cumulativeProbabilitySoFar (0.0), + _numberOfRequestsGeneratedSoFar (0) { + } + + // ////////////////////////////////////////////////////////////////////// + RandomGenerationContext::~RandomGenerationContext () { + } + + // ////////////////////////////////////////////////////////////////////// + void RandomGenerationContext::incrementGeneratedRequestsCounter () { + _numberOfRequestsGeneratedSoFar++; + } + +} Added: trunk/stdair/stdair/basic/RandomGenerationContext.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.hpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,70 @@ +#ifndef __STDAIR_BAS_RANDOM_GENERATION_CONTEXT_HPP +#define __STDAIR_BAS_RANDOM_GENERATION_CONTEXT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Structure holding the context necessary for demand random generation. */ + struct RandomGenerationContext { + + public: + // ///////////// Getters /////////// + /** Get the cumulative probability of arrival pattern for last + request generated so far. */ + const Probability_T& getCumulativeProbabilitySoFar () const { + return _cumulativeProbabilitySoFar; + } + + /** Get the number of requests generated so far. */ + const Count_T& getNumberOfRequestsGeneratedSoFar() const { + return _numberOfRequestsGeneratedSoFar; + } + + /** Set the cumulative probability of arrival pattern for last + request generated so far. */ + void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { + _cumulativeProbabilitySoFar = iCumulativeProbability; + } + + /** Set the number of requests generated so far. */ + void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { + _numberOfRequestsGeneratedSoFar = iNumberOfRequests; + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + RandomGenerationContext (); + + /** Destructor */ + virtual ~RandomGenerationContext (); + + public: + // /////////////// Business Methods ////////// + /** Increment counter of requests generated so far */ + void incrementGeneratedRequestsCounter (); + + private: + /** Default constructors. */ + RandomGenerationContext (const RandomGenerationContext&); + + private: + // ////////// Attributes ////////// + /** Cumulative probability in arrival pattern for last request + generated so far (needed for sequential generation)*/ + Probability_T _cumulativeProbabilitySoFar; + + /** Number of requests generated so far */ + Count_T _numberOfRequestsGeneratedSoFar; + + }; + +} +#endif // __STDAIR_BAS_RANDOM_GENERATION_CONTEXT_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/basic/sources.mk 2010-02-08 16:32:09 UTC (rev 124) @@ -10,10 +10,20 @@ $(top_srcdir)/stdair/basic/BasChronometer.hpp \ $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ $(top_srcdir)/stdair/basic/BasLogParams.hpp \ - $(top_srcdir)/stdair/basic/BasDBParams.hpp + $(top_srcdir)/stdair/basic/BasDBParams.hpp \ + $(top_srcdir)/stdair/basic/ContinuousAttribute.hpp \ + $(top_srcdir)/stdair/basic/CategoricalAttribute.hpp \ + $(top_srcdir)/stdair/basic/DemandCharacteristics.hpp \ + $(top_srcdir)/stdair/basic/DemandDistribution.hpp \ + $(top_srcdir)/stdair/basic/RandomGeneration.hpp \ + $(top_srcdir)/stdair/basic/RandomGenerationContext.hpp bas_cc_sources = \ $(top_srcdir)/stdair/basic/BasConst.cpp \ $(top_srcdir)/stdair/basic/BasChronometer.cpp \ $(top_srcdir)/stdair/basic/BasFileMgr.cpp \ $(top_srcdir)/stdair/basic/BasLogParams.cpp \ - $(top_srcdir)/stdair/basic/BasDBParams.cpp + $(top_srcdir)/stdair/basic/BasDBParams.cpp \ + $(top_srcdir)/stdair/basic/DemandCharacteristics.cpp \ + $(top_srcdir)/stdair/basic/DemandDistribution.cpp \ + $(top_srcdir)/stdair/basic/RandomGeneration.cpp \ + $(top_srcdir)/stdair/basic/RandomGenerationContext.cpp Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -12,17 +12,27 @@ namespace stdair { // ////////////////////////////////////////////////////////////////////// + BookingRequestStruct::BookingRequestStruct () { + } + + // ////////////////////////////////////////////////////////////////////// BookingRequestStruct::BookingRequestStruct (const AirportCode_T& iOrigin, const AirportCode_T& iDestination, const Date_T& iDepartureDate, + const DateTime_T& iRequestDateTime, const PassengerType_T& iPaxType, const NbOfSeats_T& iPartySize) : _origin (iOrigin), _destination (iDestination), - _departureDate (iDepartureDate), _paxType (iPaxType), - _partySize (iPartySize) { + _preferredDepartureDate (iDepartureDate), + _requestDateTime (iRequestDateTime), + _paxType (iPaxType), _partySize (iPartySize) { } - + // ////////////////////////////////////////////////////////////////////// + BookingRequestStruct::~BookingRequestStruct () { + } + + // ////////////////////////////////////////////////////////////////////// void BookingRequestStruct::toStream (std::ostream& ioOut) const { ioOut << describe(); } @@ -34,8 +44,8 @@ // ////////////////////////////////////////////////////////////////////// const std::string BookingRequestStruct::describe() const { std::ostringstream oStr; - oStr << _origin << " - " << _destination << " " << _departureDate - << " " << _paxType << " " << _partySize; + oStr << _origin << " - " << _destination << " " << _preferredDepartureDate + << " " << _requestDateTime << " " << _paxType << " " << _partySize; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -28,10 +28,15 @@ } /** Get the requested departure date. */ - const Date_T& getDepartureDate() const { - return _departureDate; + const Date_T& getPreferedDepartureDate() const { + return _preferredDepartureDate; } + /** Get the request datetime. */ + const DateTime_T& getRequestDateTime() const { + return _requestDateTime; + } + /** Get the passenger type. */ const PassengerType_T& getPaxType() const { return _paxType; @@ -55,10 +60,15 @@ } /** Set the requested departure date. */ - void setDepartureDate (const Date_T& iDepartureDate) { - _departureDate = iDepartureDate; + void setPreferredDepartureDate (const Date_T& iDepartureDate) { + _preferredDepartureDate = iDepartureDate; } - + + /** Set the request datetime */ + void setRequestDateTime (const DateTime_T& iRequestDateTime) { + _requestDateTime = iRequestDateTime; + } + /** Set the passenger type. */ void setPaxType (const PassengerType_T& iPaxType) { _paxType = iPaxType; @@ -84,9 +94,11 @@ public: // /////////////// Constructors and Destructors ///////////////// + BookingRequestStruct (); BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, - const Date_T&, const PassengerType_T&, - const NbOfSeats_T&); + const Date_T&, const DateTime_T&, + const PassengerType_T&, const NbOfSeats_T&); + ~BookingRequestStruct(); private: @@ -96,10 +108,13 @@ /** Destination. */ AirportCode_T _destination; - + /** Departure date. */ - Date_T _departureDate; + Date_T _preferredDepartureDate; + /** Request datetime */ + DateTime_T _requestDateTime; + /** Passenger type. */ PassengerType_T _paxType; Added: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,132 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <ostream> +#include <sstream> +// Boost +#include <boost/math/distributions/normal.hpp> +// Math +#include <math.h> +// STDAIR +#include <stdair/basic/BasConst_General.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> +#include <stdair/bom/DemandStream.hpp> +#include <stdair/service/Logger.hpp> + + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + DemandStream::DemandStream(const DemandStreamKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) + : _key (iKey), + _demandCharacteristics (iDemandCharacteristics), + _demandDistribution (iDemandDistribution), + _totalNumberOfRequestsToBeGenerated (0), + _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), + _requestDateTimeRandomGenerator (iRequestDateTimeSeed), + _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { + init(); + } + + // ////////////////////////////////////////////////////////////////////// + DemandStream::~DemandStream () { + } + + // ////////////////////////////////////////////////////////////////////// + void DemandStream::init() { + // Generate the number of requests + const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lSigma = + _demandDistribution.getStandardDeviationNumberOfRequests (); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); + Count_T lIntegerNumberOfRequestsToBeGenerated = 0; + if (lRealNumberOfRequestsToBeGenerated < 0.5) { + lIntegerNumberOfRequestsToBeGenerated = 0; + } else { + lIntegerNumberOfRequestsToBeGenerated = + static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + } + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; + } + + // ////////////////////////////////////////////////////////////////////// + bool DemandStream::generateNext (BookingRequestStruct& ioRequest) { + // Check whether enough requests have already been generated + const Count_T lNbOfRequestsGeneratedSoFar = + _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); + const Count_T lRemainingNumberOfRequestsToBeGenerated = + _totalNumberOfRequestsToBeGenerated - lNbOfRequestsGeneratedSoFar; + + if (lRemainingNumberOfRequestsToBeGenerated <= 0) { + return false; + } + // DEBUG + STDAIR_LOG_DEBUG ("Here"); + + // Origin + ioRequest.setOrigin (_demandCharacteristics.getOrigin ()); + + // Preferred departure date + const Date_T lPreferredDepartureDate = + _demandCharacteristics.getPreferredDepartureDate (); + ioRequest.setPreferredDepartureDate (lPreferredDepartureDate); + + // Request datetime, determined from departure date and arrival pattern + // Sequential generation + const Probability_T lCumulativeProbabilitySoFar = + _randomGenerationContext.getCumulativeProbabilitySoFar (); + + const Probability_T lVariate = + _requestDateTimeRandomGenerator.generateUniform01 (); + + const Probability_T lCumulativeProbabilityThisRequest = + 1.0 - (1.0 - lCumulativeProbabilitySoFar) * pow(1 - lVariate, 1.0 / static_cast<float> (lRemainingNumberOfRequestsToBeGenerated)); + + const FloatDuration_T lNumberOfDaysBetweenDepartureAndThisRequest = + _demandCharacteristics.getArrivalPattern().getValue (lCumulativeProbabilityThisRequest); + + // convert the number of days in number of seconds + number of milliseconds + const FloatDuration_T lNumberOfSeconds = + lNumberOfDaysBetweenDepartureAndThisRequest*static_cast<float> (SECONDS_IN_ONE_DAY); + + const IntDuration_T lIntNumberOfSeconds = floor(lNumberOfSeconds); + + const FloatDuration_T lNumberOfMilliseconds = + (lNumberOfSeconds - lIntNumberOfSeconds) * static_cast<float> (MILLISECONDS_IN_ONE_SECOND); + + const IntDuration_T lIntNumberOfMilliseconds = + floor(lNumberOfMilliseconds) + 1; // +1 is a trick to ensure that the next event is strictly later than the current one + + const Duration_T lDifferenceBetweenDepartureAndThisRequest = + boost::posix_time::seconds(lIntNumberOfSeconds) + boost::posix_time::millisec(lIntNumberOfMilliseconds); + + const Time_T lHardcodedReferenceDepartureTime = boost::posix_time::hours(8); + +const DateTime_T lDepartureDateTime = + boost::posix_time::ptime(lPreferredDepartureDate, lHardcodedReferenceDepartureTime); + + const DateTime_T lDateTimeThisRequest = + lDepartureDateTime + lDifferenceBetweenDepartureAndThisRequest; + ioRequest.setRequestDateTime (lDateTimeThisRequest); + + // Update random generation context + _randomGenerationContext.setCumulativeProbabilitySoFar (lCumulativeProbabilityThisRequest); + _randomGenerationContext.incrementGeneratedRequestsCounter (); + + return true; + + } + +} Added: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,94 @@ +#ifndef __STDAIR_BAS_DEMAND_STREAM_HPP +#define __STDAIR_BAS_DEMAND_STREAM_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/DemandDistribution.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> + +namespace stdair { + + /** Class modeling a demand stream. */ + class DemandStream { + + public: + // ///////////// Getters /////////// + /** Get the key */ + const DemandStreamKey_T& getKey () const { + return _key; + } + + /** Get the total number of requests to be generated. */ + const Count_T& getTotalNumberOfRequestsToBeGenerated() const { + return _totalNumberOfRequestsToBeGenerated; + } + + public: + // ///////////// Setters /////////// + /** Set the demand characteristics */ + void setKey (const DemandStreamKey_T& iKey) { + _key = iKey; + } + + public: + // /////////////// Business Methods ////////// + /** Generate the next request. */ + bool generateNext (BookingRequestStruct&); + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, + const DemandDistribution&, const RandomSeed_T&, + const RandomSeed_T&, const RandomSeed_T&); + + /** Destructor */ + virtual ~DemandStream (); + + private: + /** Default constructors. */ + DemandStream (); + DemandStream (const DemandStream&); + + /** Initialization. */ + void init(); + + private: + // ////////// Attributes ////////// + + /** Key */ + DemandStreamKey_T _key; + + /** Demand characteristics */ + DemandCharacteristics _demandCharacteristics; + + /** Demand distribution */ + DemandDistribution _demandDistribution; + + /** Total number of requests to be generated*/ + Count_T _totalNumberOfRequestsToBeGenerated; + + /** Random generation context */ + RandomGenerationContext _randomGenerationContext; + + /** Random generator for number of requests */ + RandomGeneration _numberOfRequestsRandomGenerator; + + /** Random generator for request datetime */ + RandomGeneration _requestDateTimeRandomGenerator; + + /** Random generator for demand characteristics */ + RandomGeneration _demandCharacteristicsRandomGenerator; + + }; + +} +#endif // __STDAIR_BAS_DEMAND_STREAM_HPP Added: trunk/stdair/stdair/bom/EventQueue.cpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.cpp (rev 0) +++ trunk/stdair/stdair/bom/EventQueue.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,87 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/EventQueue.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + EventQueue::EventQueue (const DateTime_T& iEarliestDateTime) { + // Earliest time is necessary in order to set _currentEvent + // "before" any event. Without it, _currentEvent would need to be + // set to the first event, the first an event is added + EventStruct lEarliestEvent (iEarliestDateTime); + _eventList.insert(EventListElement_T (iEarliestDateTime, lEarliestEvent)); + _currentEvent = _eventList.begin (); + } + + // ////////////////////////////////////////////////////////////////////// + EventQueue::~EventQueue () { + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct* EventQueue::popEvent () { + EventStruct* oEventStruct_ptr = NULL; + if (!isQueueDone ()) { + ++_currentEvent; + oEventStruct_ptr = &(_currentEvent->second); + } + return oEventStruct_ptr; + } + + // ////////////////////////////////////////////////////////////////////// + void EventQueue::addEvent (const EventStruct& iEventStruct) { + DateTime_T lEventDateTime = iEventStruct.getEventDateTime (); + _eventList.insert( std::pair<DateTime_T, EventStruct> (lEventDateTime, iEventStruct) ); + } + + // ////////////////////////////////////////////////////////////////////// + const bool EventQueue::isQueueDone () const { + bool oFlagDone = false; + if (_currentEvent == _eventList.end ()) { + oFlagDone = true; + } else { + EventList_T::iterator lNextEvent = _currentEvent; + ++lNextEvent; + if (lNextEvent == _eventList.end ()) { + oFlagDone = true; + } + } + return oFlagDone; + } + + // ////////////////////////////////////////////////////////////////////// + const Count_T EventQueue::getQueueSize () const { + if (_eventList.empty ()) { + return 0; + } else { + return _eventList.size (); + } + } + + // ////////////////////////////////////////////////////////////////////// + const bool EventQueue::isQueueEmpty () const { + return _eventList.empty (); + } + + // ////////////////////////////////////////////////////////////////////// + const Count_T EventQueue::getPositionOfCurrent () const { + int i = 0; + bool flag = false; + for (EventList_T::const_iterator it = _eventList.begin (); + it != _eventList.end (); ++it) { + if (it == _currentEvent) { + flag = true; + break; + } + ++i; + } + if (flag) { + return i; + } else { + return -1; + } + } + +} Added: trunk/stdair/stdair/bom/EventQueue.hpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.hpp (rev 0) +++ trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,73 @@ +#ifndef __STDAIR_BAS_EVENTQUEUE_HPP +#define __STDAIR_BAS_EVENTQUEUE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/EventStruct.hpp> + +namespace stdair { + + /** Event queue. */ + class EventQueue { + + public: + typedef std::pair<DateTime_T, EventStruct> EventListElement_T; + typedef std::multimap<DateTime_T, EventStruct> EventList_T; + + public: + // ///////////// Getters /////////// + // /** Get the event type */ + //const EventType_T& getEventType () const { + // return _eventType; + //} + + public: + // ////////// Constructors and destructors ///////// + /** Constructor. */ + EventQueue (const DateTime_T&); + + /** Destructor. */ + virtual ~EventQueue (); + + public: + // ////////// Business methods ///////// + /** Pop event */ + EventStruct* popEvent (); + + /** Add event */ + void addEvent (const EventStruct&); + + /** Is queue done */ + const bool isQueueDone () const; + + + // ////////// Debug methods ///////// + /** Queue size */ + const Count_T getQueueSize () const; + + /** Is queue empty */ + const bool isQueueEmpty () const; + + /** Get position of current */ + const Count_T getPositionOfCurrent () const; + + private: + /** Default constructors. */ + EventQueue (const EventQueue&); + + private: + // ////////// Attributes ////////// + + /** Event list */ + EventList_T _eventList; + + /** Pointer to current event */ + EventList_T::iterator _currentEvent; + + }; + +} +#endif // __STDAIR_BAS_EVENTQUEUE_HPP Added: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp (rev 0) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,43 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/BookingRequestStruct.hpp> +#include <stdair/bom/EventStruct.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + EventStruct:: + EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, + DemandStream& ioDemandStream, BookingRequestStruct* const iRequest) + : _eventType (iEventType), + _eventDateTime (iDateTime), + _demandStream (&ioDemandStream), + _request (NULL) { + if (iEventType == "Request") { + _request = iRequest; + } + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct:: + EventStruct (const EventStruct& iEventStruct) + : _eventType (iEventStruct._eventType), + _eventDateTime (iEventStruct._eventDateTime), + _demandStream (iEventStruct._demandStream), + _request (iEventStruct._request) { + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct::EventStruct (const DateTime_T& iDateTime) + : _eventType (""), + _eventDateTime (iDateTime), + _request (NULL) { + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct::~EventStruct () { + } + +} Added: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp (rev 0) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,78 @@ +#ifndef __STDAIR_BAS_EVENTSTRUCT_HPP +#define __STDAIR_BAS_EVENTSTRUCT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Forward declaration */ + struct BookingRequestStruct; + class DemandStream; + + /** Event struct. */ + struct EventStruct { + + public: + // ///////////// Getters /////////// + /** Get the event type */ + const EventType_T& getEventType () const { + return _eventType; + } + + /** Get the event datetime */ + const DateTime_T& getEventDateTime () const { + return _eventDateTime; + } + + /** Get the pointer Request event. */ + const BookingRequestStruct* getPointerToRequestEvent () const { + return _request; + } + + /** Get the demand stream of the event. */ + DemandStream& getDemandStream () const { + assert (_demandStream != NULL); + return *_demandStream; + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor. */ + EventStruct (const EventType_T&, const DateTime_T&, + DemandStream&, BookingRequestStruct* const); + EventStruct (const DateTime_T&); + + /** Copy constructor. */ + EventStruct (const EventStruct&); + + /** Destructor. */ + virtual ~EventStruct (); + + private: + /** Default constructors. */ + EventStruct (); + + + private: + // ////////// Attributes ////////// + + /** Event type */ + EventType_T _eventType; + + /** Event datetime */ + DateTime_T _eventDateTime; + + /** The demand stream which generated this event. */ + DemandStream* _demandStream; + + /** Pointer to Request event */ + BookingRequestStruct* _request; + + }; + +} +#endif // __STDAIR_BAS_EVENTSTRUCT_HPP Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-08 16:32:09 UTC (rev 124) @@ -86,6 +86,9 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ + $(top_srcdir)/stdair/bom/DemandStream.hpp \ + $(top_srcdir)/stdair/bom/EventStruct.hpp \ + $(top_srcdir)/stdair/bom/EventQueue.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ @@ -135,4 +138,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ + $(top_srcdir)/stdair/bom/DemandStream.cpp \ + $(top_srcdir)/stdair/bom/EventStruct.cpp \ + $(top_srcdir)/stdair/bom/EventQueue.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-08 09:22:28
|
Revision: 123 http://stdair.svn.sourceforge.net/stdair/?rev=123&view=rev Author: quannaus Date: 2010-02-08 09:22:21 +0000 (Mon, 08 Feb 2010) Log Message: ----------- [BOM] Delegated the creation of Inventory to the StdAir library. Modified Paths: -------------- trunk/stdair/stdair/command/sources.mk trunk/stdair/stdair/service/STDAIR_Service.cpp Added Paths: ----------- trunk/stdair/stdair/command/CmdBomManager.cpp trunk/stdair/stdair/command/CmdBomManager.hpp Added: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp (rev 0) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-08 09:22:21 UTC (rev 123) @@ -0,0 +1,106 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// StdAir +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/AirlineFeatureSet.hpp> +#include <stdair/bom/AirlineFeature.hpp> +// Inventory: child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Inventory.hpp> +// Network: child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Network.hpp> +#include <stdair/bom/FlightDate.hpp> +#include <stdair/factory/FacSupervisor.hpp> +#include <stdair/factory/FacBomContent.hpp> +#include <stdair/command/CmdBomManager.hpp> +#include <stdair/service/Logger.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + void CmdBomManager::initAirlineFeatureSet (BomRoot& ioBomRoot) { + // Initialise the set of required airline features + AirlineFeatureSet& lAirlineFeatureSet = + FacBomContent::instance().create<AirlineFeatureSet>(); + + // Set the AirlineFeatureSet for the BomRoot. + ioBomRoot.setAirlineFeatureSet (&lAirlineFeatureSet); + } + + // ////////////////////////////////////////////////////////////////////// + void CmdBomManager:: + addAirlineFeature (BomRoot& ioBomRoot, + const AirlineCode_T& iAirlineCode) { + + // Initialise an AirlineFeature object + AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); + AirlineFeature& lAirlineFeature = FacBomContent:: + instance().create<AirlineFeature> (lAirlineFeatureKey); + + // Retrieve the AirlineFeatureSet object + AirlineFeatureSet& lAirlineFeatureSet = ioBomRoot.getAirlineFeatureSet(); + + // Add the AirlineFeature object to its AirlineFeatureSet parent + FacBomContent::linkWithParent<AirlineFeature> (lAirlineFeature, + lAirlineFeatureSet); + } + + // ////////////////////////////////////////////////////////////////////// + Inventory& CmdBomManager:: + createInventoryInternal (BomRoot& ioBomRoot, + const AirlineCode_T& iAirlineCode) { + InventoryKey_T lInventoryKey (iAirlineCode); + + // Instantiate an Inventory object with the given airline code + Inventory& lInventory = + FacBomContent::instance().create<Inventory> (lInventoryKey); + + // Link the created inventory with the bom root. + FacBomContent::linkWithParent<Inventory> (lInventory, ioBomRoot); + + return lInventory; + } + + // ////////////////////////////////////////////////////////////////////// + Inventory& CmdBomManager:: + getOrCreateInventory (BomRoot& ioBomRoot, + const AirlineCode_T& iAirlineCode) { + Inventory* lInventory_ptr = ioBomRoot.getInventory (iAirlineCode); + + // If there is no Inventory object for that airline already, create one + if (lInventory_ptr == NULL) { + const InventoryKey_T lInventoryKey (iAirlineCode); + + + // Instantiate an Inventory object with the given airline code + lInventory_ptr = &createInventoryInternal (ioBomRoot, iAirlineCode); + assert (lInventory_ptr != NULL); + + // Set the AirlineFeature for the inventory. + addAirlineFeature (ioBomRoot, iAirlineCode); + + // TODO: find a more elegant way to link the AirlineFeature back to the + // Inventory object + + // Link the AirlineFeature with the Inventory object + const AirlineFeatureSet& lAirlineFeatureSet = + ioBomRoot.getAirlineFeatureSet (); + const AirlineFeature* lAirlineFeature_ptr = + lAirlineFeatureSet.getAirlineFeature (iAirlineCode); + + if (lAirlineFeature_ptr == NULL) { + STDAIR_LOG_ERROR (lAirlineFeatureSet.display() + << "Needed airline code: " << iAirlineCode); + assert (false); + } + + lInventory_ptr->setAirlineFeature (lAirlineFeature_ptr); + } + assert (lInventory_ptr != NULL); + + return *lInventory_ptr; + } + +} Added: trunk/stdair/stdair/command/CmdBomManager.hpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.hpp (rev 0) +++ trunk/stdair/stdair/command/CmdBomManager.hpp 2010-02-08 09:22:21 UTC (rev 123) @@ -0,0 +1,56 @@ +#ifndef __STDAIR_CMD_CMDBOMMANAGER_HPP +#define __STDAIR_CMD_CMDBOMMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/command/CmdAbstract.hpp> + +namespace stdair { + + // Forward declarations + class BomRoot; + class Inventory; + + /** Class wrapping utility functions for handling the BOM tree objects. */ + class CmdBomManager : public CmdAbstract { + public: + + /** If needed, create the Inventory corresponding to the given airline code + (Inventory key), link it to the BomRoot object and to the + associated AirlineFeature object, itself retrieved from the + AirlineFeatureSet object. + Otherwise, just retrieve the reference on the existing Inventory object + corresponding to the given airline code. + <br>If not existing, a ObjectNotFoundException exception is thrown. + @param BomRoot& Root of the BOM tree. + @param const AirlineCode_T& Airline code for the inventory to be + created . */ + static Inventory& getOrCreateInventory (BomRoot&, const AirlineCode_T&); + + /** Initialise the AirlineFeatureSet object, and attach it to the + BomRoot. + @param BomRoot& Root of the BOM tree. */ + static void initAirlineFeatureSet (BomRoot&); + + /** Add the airline-specific AirlineFeature object to its AirlineFeatureSet + parent. + @param BomRoot& Root of the BOM tree. + @param const AirlineCode_T& Airline code for the inventory to be + created . */ + static void addAirlineFeature (BomRoot&, const AirlineCode_T& iAirlineCode); + + private: + // ///////////////////// Internal support methods //////////////////////// + /** Create the Inventory corresponding to the given airline code + (Inventory key). + @param BomRoot& Root of the BOM tree. + @param const AirlineCode_T& Airline code for the inventory to be + created . */ + static Inventory& createInventoryInternal (BomRoot&, const AirlineCode_T&); + }; + +} +#endif // ___STDAIR_CMD_CMDBOMMANAGER_HPP Modified: trunk/stdair/stdair/command/sources.mk =================================================================== --- trunk/stdair/stdair/command/sources.mk 2010-02-07 20:06:07 UTC (rev 122) +++ trunk/stdair/stdair/command/sources.mk 2010-02-08 09:22:21 UTC (rev 123) @@ -1,6 +1,8 @@ cmd_h_sources = \ $(top_srcdir)/stdair/command/CmdAbstract.hpp \ + $(top_srcdir)/stdair/command/CmdBomManager.hpp \ $(top_srcdir)/stdair/command/DBManagerForAirlines.hpp cmd_cc_sources = \ $(top_srcdir)/stdair/command/CmdAbstract.cpp \ + $(top_srcdir)/stdair/command/CmdBomManager.cpp \ $(top_srcdir)/stdair/command/DBManagerForAirlines.cpp Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-07 20:06:07 UTC (rev 122) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-08 09:22:21 UTC (rev 123) @@ -7,15 +7,11 @@ #include <stdair/basic/BasChronometer.hpp> #include <stdair/bom/BomManager.hpp> // for display() #include <stdair/bom/BomRoot.hpp> -#include <stdair/bom/AirlineFeatureSet.hpp> -#include <stdair/bom/AirlineFeature.hpp> -// Inventory: child of BomRoot, needed for creation of BomRoot -#include <stdair/bom/Inventory.hpp> -// Network: child of BomRoot, needed for creation of BomRoot #include <stdair/bom/Network.hpp> -#include <stdair/bom/FlightDate.hpp> +#include <stdair/bom/Inventory.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> +#include <stdair/command/CmdBomManager.hpp> #include <stdair/service/Logger.hpp> #include <stdair/service/DBSessionManager.hpp> #include <stdair/STDAIR_Service.hpp> @@ -91,32 +87,16 @@ } // ////////////////////////////////////////////////////////////////////// - void STDAIR_Service::initAirlineFeatureSet () { - // Initialise the set of required airline features - stdair::AirlineFeatureSet& lAirlineFeatureSet = - stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>(); - - // Set the AirlineFeatureSet for the BomRoot. - _bomRoot.setAirlineFeatureSet (&lAirlineFeatureSet); + void STDAIR_Service::initAirlineFeatureSet () { + // Delegate to the dedicated command + CmdBomManager::initAirlineFeatureSet (_bomRoot); } // ////////////////////////////////////////////////////////////////////// void STDAIR_Service:: addAirlineFeature (const AirlineCode_T& iAirlineCode) const { - - // Initialise an AirlineFeature object - stdair::AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); - stdair::AirlineFeature& lAirlineFeature = stdair::FacBomContent:: - instance().create<stdair::AirlineFeature> (lAirlineFeatureKey); - - // Retrieve the AirlineFeatureSet object - stdair::AirlineFeatureSet& lAirlineFeatureSet = - _bomRoot.getAirlineFeatureSet(); - - // Add the AirlineFeature object to its AirlineFeatureSet parent - stdair::FacBomContent:: - linkWithParent<stdair::AirlineFeature> (lAirlineFeature, - lAirlineFeatureSet); + // Delegate to the dedicated command + CmdBomManager::addAirlineFeature (_bomRoot, iAirlineCode); } // ////////////////////////////////////////////////////////////////////// @@ -139,42 +119,19 @@ return *lInventory_ptr; } + /** + Note that the AirlineFeature is linked both to the Inventory + and to the AirlineFeatureSet, which in turn is linked to the BomRoot. + There is therefore a duplication of the structure links. + */ + // ////////////////////////////////////////////////////////////////////// Inventory& STDAIR_Service:: createInventory (const AirlineCode_T& iAirlineCode) const { - Inventory* lInventory_ptr = _bomRoot.getInventory (iAirlineCode); - - // If there is no Inventory object for that airline already, create one - if (lInventory_ptr == NULL) { - const stdair::InventoryKey_T lInventoryKey (iAirlineCode); - - // Instantiate an Inventory object with the given airline code - lInventory_ptr = - &stdair::FacBomContent::instance(). - create<stdair::Inventory> (lInventoryKey); - assert (lInventory_ptr != NULL); - - // Link the created inventory with the bom root. - stdair::FacBomContent::linkWithParent<stdair::Inventory> (*lInventory_ptr, - _bomRoot); - - // Set the AirlineFeature for the inventory. - const stdair::AirlineFeatureSet& lAirlineFeatureSet = - _bomRoot.getAirlineFeatureSet (); - const stdair::AirlineFeature* lAirlineFeature_ptr = - lAirlineFeatureSet.getAirlineFeature (iAirlineCode); - - // TODO: throw an exception? - if (lAirlineFeature_ptr == NULL) { - STDAIR_LOG_ERROR (lAirlineFeatureSet.display() - << "Needed airline code: " << iAirlineCode); - } - - lInventory_ptr->setAirlineFeature (lAirlineFeature_ptr); - } - assert (lInventory_ptr != NULL); - - return *lInventory_ptr; + // Delegate to the dedicated command + Inventory& oInventory = + CmdBomManager::getOrCreateInventory (_bomRoot, iAirlineCode); + return oInventory; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-07 20:06:14
|
Revision: 122 http://stdair.svn.sourceforge.net/stdair/?rev=122&view=rev Author: denis_arnaud Date: 2010-02-07 20:06:07 +0000 (Sun, 07 Feb 2010) Log Message: ----------- [StdAir] Added the command layer for StdAir. Modified Paths: -------------- trunk/stdair/configure.ac Modified: trunk/stdair/configure.ac =================================================================== --- trunk/stdair/configure.ac 2010-02-07 19:51:29 UTC (rev 121) +++ trunk/stdair/configure.ac 2010-02-07 20:06:07 UTC (rev 122) @@ -207,9 +207,9 @@ stdair/dbadaptor/Makefile stdair/factory/Makefile stdair/command/Makefile + stdair/config/Makefile stdair/service/Makefile stdair/core/Makefile - stdair/config/Makefile doc/Makefile doc/images/Makefile doc/tutorial/Makefile This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-07 19:51:36
|
Revision: 121 http://stdair.svn.sourceforge.net/stdair/?rev=121&view=rev Author: denis_arnaud Date: 2010-02-07 19:51:29 +0000 (Sun, 07 Feb 2010) Log Message: ----------- [StdAir] Added the command layer for StdAir. Modified Paths: -------------- trunk/stdair/configure.ac Modified: trunk/stdair/configure.ac =================================================================== --- trunk/stdair/configure.ac 2010-02-07 19:43:30 UTC (rev 120) +++ trunk/stdair/configure.ac 2010-02-07 19:51:29 UTC (rev 121) @@ -206,6 +206,7 @@ stdair/bom/Makefile stdair/dbadaptor/Makefile stdair/factory/Makefile + stdair/command/Makefile stdair/service/Makefile stdair/core/Makefile stdair/config/Makefile This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |