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. |