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