From: <qua...@us...> - 2010-06-30 15:59:25
|
Revision: 209 http://stdair.svn.sourceforge.net/stdair/?rev=209&view=rev Author: quannaus Date: 2010-06-30 15:59:19 +0000 (Wed, 30 Jun 2010) Log Message: ----------- [dev] Implemented the new network generator. Modified Paths: -------------- trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp trunk/stdair/stdair/bom/DoWStruct.cpp trunk/stdair/stdair/bom/DoWStruct.hpp trunk/stdair/stdair/bom/FlightPeriodContent.hpp trunk/stdair/stdair/bom/FlightPeriodKey.cpp trunk/stdair/stdair/bom/FlightPeriodKey.hpp trunk/stdair/stdair/bom/SegmentPathPeriod.cpp trunk/stdair/stdair/bom/SegmentPathPeriod.hpp trunk/stdair/stdair/bom/SegmentPathPeriodContent.cpp trunk/stdair/stdair/bom/SegmentPathPeriodContent.hpp trunk/stdair/stdair/bom/SegmentPathPeriodKey.cpp trunk/stdair/stdair/bom/SegmentPathPeriodKey.hpp trunk/stdair/stdair/bom/SegmentPathPeriodTypes.hpp trunk/stdair/stdair/bom/SegmentPeriod.cpp trunk/stdair/stdair/bom/SegmentPeriod.hpp trunk/stdair/stdair/bom/sources.mk Added Paths: ----------- trunk/stdair/stdair/bom/PeriodStruct.cpp trunk/stdair/stdair/bom/PeriodStruct.hpp Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -226,6 +226,9 @@ /** Default Minimum connection time. */ const Duration_T DEFAULT_MINIMUM_CONNECTION_TIME (0, 30, 0); + /** Default maximum connection time. */ + const Duration_T DEFAULT_MAXIMUM_CONNECTION_TIME (24, 0, 0); + /** Default Matching Indicator value. */ const MatchingIndicator_T DEFAULT_MATCHING_INDICATOR (0.0); Modified: trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -18,6 +18,9 @@ /** Default Minimum connection time. */ extern const Duration_T DEFAULT_MINIMUM_CONNECTION_TIME; + + /** Default maximum connection time. */ + extern const Duration_T DEFAULT_MAXIMUM_CONNECTION_TIME; /** Null time duration (in boost::time_duration unit).*/ extern const Duration_T NULL_BOOST_TIME_DURATION; Modified: trunk/stdair/stdair/bom/DoWStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/DoWStruct.cpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/DoWStruct.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -9,6 +9,13 @@ #include <stdair/bom/DoWStruct.hpp> namespace stdair { + + // //////////////////////////////////////////////////////////////////// + DoWStruct_T::DoWStruct_T () { + for (unsigned short i = 0; i < 7; ++i) { + _dowList.push_back (false); + } + } // //////////////////////////////////////////////////////////////////// DoWStruct_T::DoWStruct_T (const std::string& iDowString) { @@ -71,4 +78,49 @@ return _dowList.at (iStd); } + // //////////////////////////////////////////////////////////////////// + void DoWStruct_T::setDayOfWeek (const unsigned short i, const bool iBool) { + assert (i >= 0 && i < 7); + _dowList.at (i) = iBool; + } + + // //////////////////////////////////////////////////////////////////// + DoWStruct_T DoWStruct_T::shift (const long& iNbOfDays) const { + DoWStruct_T oDoW (DEFAULT_DOW_STRING); + + for (short i = 0; i < 7; ++i) { + const bool lDoWBool = _dowList.at (i); + short lIndex = (i + iNbOfDays) % 7; + if (lIndex < 0) { + lIndex += 7; + } + oDoW.setDayOfWeek (lIndex, lDoWBool); + } + + return oDoW; + } + + // //////////////////////////////////////////////////////////////////// + DoWStruct_T DoWStruct_T::intersection (const DoWStruct_T& iDoW) const { + DoWStruct_T oDoW (DEFAULT_DOW_STRING); + for (unsigned short i = 0; i < 7; ++i) { + if (getDayOfWeek(i) && iDoW.getDayOfWeek(i)) { + oDoW.setDayOfWeek (i, true); + } else { + oDoW.setDayOfWeek (i, false); + } + } + return oDoW; + } + + // //////////////////////////////////////////////////////////////////// + const bool DoWStruct_T::isValid () const { + for (unsigned short i = 0; i < 7; ++i) { + if (getDayOfWeek(i)) { + return true; + } + } + return false; + } + } Modified: trunk/stdair/stdair/bom/DoWStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/DoWStruct.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/DoWStruct.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -19,16 +19,22 @@ public: /** Define the bit set representing the DoW. */ typedef std::vector<bool> BooleanList_T; - - /** Attributes. */ - BooleanList_T _dowList; + public: + // //////////////// Getters /////////////// /** Get the i-th day of the week (Monday being the first one). */ bool getDayOfWeek (const unsigned short i) const; /** Get the i-th day of the week (Sunday being the first one). */ bool getStandardDayOfWeek (const unsigned short i) const; - + + public: + // //////////////// Setters /////////////// + /** Set the new value for the i-th day-of-week. */ + void setDayOfWeek (const unsigned short, const bool); + + public: + // //////////////// Display methods /////////////// /** Display explicitly (e.g., "Mon.Tue.Wed.Thu.Fri."). */ const std::string describe() const; @@ -36,15 +42,29 @@ const std::string describeShort() const; public: + // ///////////////// Business Methods //////////////// + /** Build a new DoW struct by shifting the current DoW by a given number. */ + DoWStruct_T shift (const long&) const; + + /** Build a new DoW struct by intersecting two DoW structs. */ + DoWStruct_T intersection (const DoWStruct_T&) const; + + /** Return if the DoW struct is valid (i.e., has at least one "true"). */ + const bool isValid () const; + + public: /** Constructor from a given bit set (e.g., "0000011" for the week-ends). */ DoWStruct_T (const std::string& iDowString); - - /** Default constructor. */ + /** Default constructors. */ DoWStruct_T (); - - /** Default constructor. */ DoWStruct_T (const DoWStruct_T&); + /** Default destructor. */ + ~DoWStruct_T () { } + + private: + /** Attributes. */ + BooleanList_T _dowList; }; } Modified: trunk/stdair/stdair/bom/FlightPeriodContent.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightPeriodContent.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/FlightPeriodContent.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -29,16 +29,11 @@ return _key.getFlightNumber(); } - /** Get the departure date range. */ - const DatePeriod_T& getDeparturePeriod () const { - return _key.getDeparturePeriod(); + /** Get the departure period (part of the key). */ + const PeriodStruct_T& getPeriod () const { + return _key.getPeriod(); } - /** Get the active days-of-week. */ - const DoWStruct_T& getDoW () const { - return _key.getDoW(); - } - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. Modified: trunk/stdair/stdair/bom/FlightPeriodKey.cpp =================================================================== --- trunk/stdair/stdair/bom/FlightPeriodKey.cpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/FlightPeriodKey.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -8,15 +8,13 @@ // //////////////////////////////////////////////////////////////////// FlightPeriodKey_T::FlightPeriodKey_T (const FlightNumber_T& iFlightNumber, - const DatePeriod_T& iDatePeriod, - const DoWStruct_T& iDoW) - : _flightNumber (iFlightNumber), _dateRange (iDatePeriod), _dow (iDoW) { + const PeriodStruct_T& iPeriod) + : _flightNumber (iFlightNumber), _period (iPeriod) { } // //////////////////////////////////////////////////////////////////// FlightPeriodKey_T::FlightPeriodKey_T (const FlightPeriodKey_T& iKey) - : _flightNumber (iKey._flightNumber), _dateRange (iKey._dateRange), - _dow (iKey._dow) { + : _flightNumber (iKey._flightNumber), _period (iKey._period) { } // //////////////////////////////////////////////////////////////////// @@ -35,8 +33,7 @@ // //////////////////////////////////////////////////////////////////// const std::string FlightPeriodKey_T::toString() const { std::ostringstream oStr; - oStr << _flightNumber << ", " << _dateRange << ", " - << _dow.describeShort(); + oStr << _flightNumber << ", " << _period.describeShort(); return oStr.str(); } Modified: trunk/stdair/stdair/bom/FlightPeriodKey.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightPeriodKey.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/FlightPeriodKey.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -6,7 +6,7 @@ // ////////////////////////////////////////////////////////////////////// // STDAIR #include <stdair/bom/BomKey.hpp> -#include <stdair/bom/DoWStruct.hpp> +#include <stdair/bom/PeriodStruct.hpp> namespace stdair { /** Key of flight-period. */ @@ -18,8 +18,7 @@ public: // /////////// Construction /////////// /** Constructors. */ - FlightPeriodKey_T (const FlightNumber_T&, const DatePeriod_T&, - const DoWStruct_T&); + FlightPeriodKey_T (const FlightNumber_T&, const PeriodStruct_T&); FlightPeriodKey_T (const FlightPeriodKey_T&); /** Destructor. */ ~FlightPeriodKey_T (); @@ -30,14 +29,9 @@ return _flightNumber; } - /** Get the departure date range. */ - const DatePeriod_T& getDeparturePeriod () const { - return _dateRange; - } - /** Get the active days-of-week. */ - const DoWStruct_T& getDoW () const { - return _dow; + const PeriodStruct_T& getPeriod () const { + return _period; } // /////////// Display support methods ///////// @@ -61,11 +55,8 @@ /** Flight number. */ FlightNumber_T _flightNumber; - /** Departure period of the (first leg of the) flight. */ - DatePeriod_T _dateRange; - - /** DoW during the departure period. */ - DoWStruct_T _dow; + /** Period during the departure period. */ + PeriodStruct_T _period; }; Added: trunk/stdair/stdair/bom/PeriodStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/PeriodStruct.cpp (rev 0) +++ trunk/stdair/stdair/bom/PeriodStruct.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -0,0 +1,78 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <sstream> +#include <cassert> +// STDAIR +#include <stdair/basic/BasConst_Period_BOM.hpp> +#include <stdair/bom/PeriodStruct.hpp> + +namespace stdair { + // //////////////////////////////////////////////////////////////////// + PeriodStruct_T::PeriodStruct_T () + : _dateRange (BOOST_DEFAULT_DATE_PERIOD), _dow () { + } + + // //////////////////////////////////////////////////////////////////// + PeriodStruct_T::PeriodStruct_T (const DatePeriod_T& iDateRange, + const DoWStruct_T& iDoW) + : _dateRange (iDateRange), _dow (iDoW) { + } + + // //////////////////////////////////////////////////////////////////// + PeriodStruct_T::PeriodStruct_T (const PeriodStruct_T& iPeriodStruct) + : _dateRange (iPeriodStruct._dateRange), _dow (iPeriodStruct._dow) { + + } + + // //////////////////////////////////////////////////////////////////// + const std::string PeriodStruct_T::describeShort() const { + std::ostringstream ostr; + ostr << _dateRange << ", " << _dow.describeShort (); + return ostr.str(); + } + + // //////////////////////////////////////////////////////////////////// + const std::string PeriodStruct_T::describe() const { + std::ostringstream ostr; + ostr << _dateRange << ", " << _dow.describe (); + return ostr.str(); + } + + // //////////////////////////////////////////////////////////////////// + PeriodStruct_T PeriodStruct_T:: + addDateOffset (const DateOffset_T& iDateOffset) const { + // Create a new date range by shifting the date range of this object with + // iDateOffset. + DatePeriod_T lNewDateRange = getDateRange(); + lNewDateRange.shift (iDateOffset); + + // Create a new DoWStruct by shifting the DoWStruct of this object with + // iDateOffset. + const long lNbOfDaysOffset = iDateOffset.days(); + const DoWStruct_T& lDoW = getDoW(); + const DoWStruct_T lNewDoW = lDoW.shift (lNbOfDaysOffset); + + return PeriodStruct_T (lNewDateRange, lNewDoW); + } + + // //////////////////////////////////////////////////////////////////// + PeriodStruct_T PeriodStruct_T:: + intersection (const PeriodStruct_T& iPeriodStruct) const { + const DatePeriod_T lNewDateRange = + _dateRange.intersection (iPeriodStruct._dateRange); + const DoWStruct_T lNewDoW = _dow.intersection (iPeriodStruct._dow); + + return PeriodStruct_T (lNewDateRange, lNewDoW); + } + + // //////////////////////////////////////////////////////////////////// + const bool PeriodStruct_T::isValid () const { + if (_dateRange.is_null() == false && _dow.isValid()) { + return true; + } + return false; + } + +} Added: trunk/stdair/stdair/bom/PeriodStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/PeriodStruct.hpp (rev 0) +++ trunk/stdair/stdair/bom/PeriodStruct.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -0,0 +1,72 @@ +#ifndef __STDAIR_BOM_PERIODSTRUCT_HPP +#define __STDAIR_BOM_PERIODSTRUCT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +#include <vector> +// STDAIR +#include <stdair/basic/StructAbstract.hpp> +#include <stdair/bom/DoWStruct.hpp> + +namespace stdair { + + /** Define a departure period + <br> A period is defined by a date range and a day-of-week struct. */ + struct PeriodStruct_T : public StructAbstract { + public: + // ////////// Getters ///////////// + /** Retrieve the attributes. */ + const DatePeriod_T& getDateRange () const { + return _dateRange; + } + const DoWStruct_T& getDoW () const { + return _dow; + } + + public: + // /////////// Setters //////////// + /** Set the new value for the attributes. */ + void setDateRange (const DatePeriod_T& iDateRange) { + _dateRange = iDateRange; + } + void setDoW (const DoWStruct_T& iDoW) { _dow = iDoW; } + + public: + /** Display explicitly (e.g., "Mon.Tue.Wed.Thu.Fri."). */ + const std::string describe() const; + + /** Display as a bit set (e.g., "1111100"). */ + const std::string describeShort() const; + + public: + // /////////// Business Methods ///////////// + /** Build a period struct from this period struct by adding a date offset. */ + PeriodStruct_T addDateOffset (const DateOffset_T&) const; + + /** Build a new period struct which is the intersection of two + period structs. */ + PeriodStruct_T intersection (const PeriodStruct_T&) const; + + /** Return if the period is valid (i.e., valid date range and valid DoW). */ + const bool isValid () const; + + public: + /** Constructor. */ + PeriodStruct_T (const DatePeriod_T&, const DoWStruct_T&); + /** Default constructors. */ + PeriodStruct_T (); + PeriodStruct_T (const PeriodStruct_T&); + /** Default destructor. */ + ~PeriodStruct_T () { } + + private: + // Attributes + DatePeriod_T _dateRange; + DoWStruct_T _dow; + }; + +} +#endif // __STDAIR_BOM_PERIODSTRUCT_HPP Modified: trunk/stdair/stdair/bom/SegmentPathPeriod.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriod.cpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPathPeriod.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -4,6 +4,7 @@ // STL #include <cassert> // STDAIR +#include <stdair/basic/BasConst_TravelSolution.hpp> #include <stdair/bom/BomSource.hpp> namespace stdair { @@ -112,91 +113,143 @@ assert (lLastSegment_ptr != NULL); return lLastSegment_ptr->getOffPoint(); } - - // //////////////////////////////////////////////////////////////////// - void SegmentPathPeriod::updateAirlineCode() { - // TODO: to be optimised. - // std::ostringstream ostr; - // SegmentPeriodList_T lSegmentPeriodList = getSegmentPeriodList(); - - // for (SegmentPeriodList_T::iterator itSegmentPeriod = - // lSegmentPeriodList.begin(); - // itSegmentPeriod != lSegmentPeriodList.end(); ++itSegmentPeriod) { - // const SegmentPeriod& lSegmentPeriod = *itSegmentPeriod; - // ostr << lSegmentPeriod.getAirlineCode(); - // } - - // const AirlineCode_T lAirlineCode (ostr.str()); - // setAirlineCode(lAirlineCode); - } // //////////////////////////////////////////////////////////////////// bool SegmentPathPeriod:: isAirlineFlown (const AirlineCode_T& iAirlineCode) const { bool oAirlineFlown = false; - // const SegmentPeriodList_T& lSegmentPeriodList = getSegmentPeriodList (); - // for (SegmentPeriodList_T::iterator itSegmentPeriod = - // lSegmentPeriodList.begin(); - // itSegmentPeriod != lSegmentPeriodList.end(); ++itSegmentPeriod) { - // const SegmentPeriod& lSegmentPeriod = *itSegmentPeriod; + const SegmentPeriodList_T& lSegmentPeriodList = getSegmentPeriodList (); + for (SegmentPeriodList_T::iterator itSegmentPeriod = + lSegmentPeriodList.begin(); + itSegmentPeriod != lSegmentPeriodList.end(); ++itSegmentPeriod) { + const SegmentPeriod& lSegmentPeriod = *itSegmentPeriod; - // const AirlineCode_T& lSegmentAirlineCode = - // lSegmentPeriod.getAirlineCode(); - // if (lSegmentAirlineCode == iAirlineCode) { - // oAirlineFlown = true; - // break; - // } - // } + const AirlineCode_T& lSegmentAirlineCode = + lSegmentPeriod.getParent().getParent().getAirlineCode(); + if (lSegmentAirlineCode == iAirlineCode) { + oAirlineFlown = true; + break; + } + } return oAirlineFlown; } // //////////////////////////////////////////////////////////////////// - void SegmentPathPeriod:: - updateAfterAddingSegmentPeriod (const SegmentPeriod& iSegmentPeriod) { - // Increment the flight path code - // std::ostringstream ostr; - // FlightPathCode_T lPreviousFPCode = getCurrentFlightPathCode(); - // ostr << lPreviousFPCode - // << iSegmentPeriod.getFlightNumber(); - // setFlightPathCode(ostr.str()); - } - - // //////////////////////////////////////////////////////////////////// - const SegmentPathPeriodKey_T SegmentPathPeriod:: + SegmentPathPeriodKey_T SegmentPathPeriod:: connectWithAnotherSegment(const SegmentPathPeriod& iSingleSegmentPath) const { SegmentPathPeriodKey_T oSegmentPathPeriodKey; // Retrieve the (only) segment period of the single segment path. - const SegmentPeriod* lSegmentPeriod_ptr = getFirstSegmentPeriod (); - assert (lSegmentPeriod_ptr != NULL); + const SegmentPeriod* lNextSegmentPeriod_ptr = + iSingleSegmentPath.getFirstSegmentPeriod (); + assert (lNextSegmentPeriod_ptr != NULL); + // Retrive the last segment period of the current segment path and check + // if the combination of the last segment and the next segment that we + // want to add to the current segment path will create a new segment + // (i.e., the two segment period belongs to the same flight number). + const SegmentPeriod* lLastSegmentPeriod_ptr = getLastSegmentPeriod (); + assert (lLastSegmentPeriod_ptr != NULL); + const FlightPeriod& lLastFlightPeriod = lLastSegmentPeriod_ptr->getParent(); + const FlightPeriod& lNextFlightPeriod = lNextSegmentPeriod_ptr->getParent(); + if (lLastFlightPeriod.getFlightNumber()==lNextFlightPeriod.getFlightNumber() + && lLastFlightPeriod.getParent().getAirlineCode() == + lNextFlightPeriod.getParent().getAirlineCode()) { + return oSegmentPathPeriodKey; + } + // Check if the new segment period will create a circle. - const AirportCode_T& lDestination = lSegmentPeriod_ptr->getOffPoint(); + const AirportCode_T& lDestination = lNextSegmentPeriod_ptr->getOffPoint(); if (checkCircle (lDestination) == true) { return oSegmentPathPeriodKey; } - - return oSegmentPathPeriodKey; - } + // Check if a passenger can connect from the last segment of the + // current segment path to the first segment of the to-be-added + // segment path. If yes, build a new departure period for the new + // segment path. + DateOffsetList_T lBoardingDateOffsetList = + getBoardingDateOffsetList(); + const PeriodStruct_T& lCurrentDeparturePeriod = getDeparturePeriod(); + const PeriodStruct_T& lNextDeparturePeriod = + iSingleSegmentPath.getDeparturePeriod(); + const Duration_T& lLastOffTime = lLastSegmentPeriod_ptr->getOffTime(); + const Duration_T& lNextBoardingTime = + lNextSegmentPeriod_ptr->getBoardingTime(); + // If the next boarding time is later than the last off time, check if + // the passengers will have enough time for the transfer. If the next + // boarding time is earlier than the last off time, check if the passengers + // can connect to a flight in the next day. + if (lNextBoardingTime >= lLastOffTime) { + const Duration_T lStopTime = lNextBoardingTime - lLastOffTime; + if (lStopTime < DEFAULT_MINIMUM_CONNECTION_TIME) { + return oSegmentPathPeriodKey; + } else { + // Calulcate the date offset of the next segment compare to + // the first one. In this case, this value is equal to the offset + // of the off date of the last segment compare to the boarding date + // of the first segment. + const DateOffset_T& lLastBoardingDateOffset = + lBoardingDateOffsetList.at (getNbOfSegments() - 1); + const DateOffset_T lNextBoardingDateOffset = + lLastBoardingDateOffset + lNextSegmentPeriod_ptr->getOffDateOffset() + - lNextSegmentPeriod_ptr->getBoardingDateOffset(); + const DateOffset_T lNegativeNextBoardingDateOffset = + DateOffset_T (0) - lNextBoardingDateOffset; - // //////////////////////////////////////////////////////////////////// - bool SegmentPathPeriod:: - isConnectable (const SegmentPathPeriod& iSegmentPathPeriod) const { - // Delegate the check on the two (potentially) connecting SegmentPeriod - // objects, i.e., the last SegmentPeriod of the current SegmentPathPeriod, - // and the first SegmentPeriod of the given SegmentPathPeriod. - const SegmentPeriod* lOffSegment_ptr = getLastSegmentPeriod(); - assert (lOffSegment_ptr != NULL); + // Compute the adjusted departure period of the next segment by + // substracting the origin one with the boarding date offset. + const PeriodStruct_T lAdjustedNextDeparturePeriod = + lNextDeparturePeriod.addDateOffset (lNegativeNextBoardingDateOffset); - const SegmentPeriod* lBoardingSegment_ptr = - iSegmentPathPeriod.getFirstSegmentPeriod(); - assert (lBoardingSegment_ptr != NULL); - - return lOffSegment_ptr->isConnectable (*lBoardingSegment_ptr); - // TODO + // Build the intersection of the two periods. + const PeriodStruct_T lNewDeparturePeriod = + lCurrentDeparturePeriod.intersection (lAdjustedNextDeparturePeriod); + Duration_T lNewElapsed = getElapsedTime() + lStopTime + + lNextSegmentPeriod_ptr->getElapsedTime(); + lBoardingDateOffsetList.push_back (lNextBoardingDateOffset); + oSegmentPathPeriodKey.setPeriod (lNewDeparturePeriod); + oSegmentPathPeriodKey.setElapsedTime (lNewElapsed); + } + } else { + const Duration_T lStopTime = + lNextBoardingTime - lLastOffTime + Duration_T (24, 0, 0); + if (lStopTime < DEFAULT_MINIMUM_CONNECTION_TIME) { + return oSegmentPathPeriodKey; + } else { + // Calulcate the date offset of the next segment compare to + // the first one. + const DateOffset_T& lLastBoardingDateOffset = + lBoardingDateOffsetList.at (getNbOfSegments() - 1); + const DateOffset_T lNextBoardingDateOffset = + lLastBoardingDateOffset + lNextSegmentPeriod_ptr->getOffDateOffset() + - lNextSegmentPeriod_ptr->getBoardingDateOffset() + DateOffset_T (1); + const DateOffset_T lNegativeNextBoardingDateOffset = + DateOffset_T (0) - lNextBoardingDateOffset; + + // Compute the adjusted departure period of the next segment by + // substracting the origin one with the boarding date offset. + const PeriodStruct_T lAdjustedNextDeparturePeriod = + lNextDeparturePeriod.addDateOffset (lNegativeNextBoardingDateOffset); + + // Build the intersection of the two periods. + const PeriodStruct_T lNewDeparturePeriod = + lCurrentDeparturePeriod.intersection (lAdjustedNextDeparturePeriod); + Duration_T lNewElapsed = getElapsedTime() + lStopTime + + lNextSegmentPeriod_ptr->getElapsedTime(); + lBoardingDateOffsetList.push_back (lNextBoardingDateOffset); + oSegmentPathPeriodKey.setPeriod (lNewDeparturePeriod); + oSegmentPathPeriodKey.setElapsedTime (lNewElapsed); + } + } + + const Duration_T& lBoardingTime = getBoardingTime(); + oSegmentPathPeriodKey.setBoardingTime (lBoardingTime); + oSegmentPathPeriodKey.setBoardingDateOffsetList (lBoardingDateOffsetList); + + return oSegmentPathPeriodKey; } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/SegmentPathPeriod.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriod.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPathPeriod.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -86,17 +86,7 @@ 2. There is no circle within the new segment path. 3. The intersection of the two periods is non-empty. */ - const SegmentPathPeriodKey_T connectWithAnotherSegment (const SegmentPathPeriod&) const; - - /** States whether or not the given SegmentPathPeriod may connect with the - current one. - <br>Basically, the board time of the given SegmentPathPeriod should be - such as to allow the passenger connecting from the previous flight - (current SegmentPathPeriod object) to the next one - (given SegmentPathPeriod). - <br>Note that this method relies on the eponym method of the - SegmentPeriod class. */ - bool isConnectable (const SegmentPathPeriod&) const; + SegmentPathPeriodKey_T connectWithAnotherSegment (const SegmentPathPeriod&) const; /** Check if the given destination airport the departure point of one of the segment member. If yes, a circle exists. */ @@ -105,14 +95,7 @@ /** State whether or not the given airline is flown by (at least) one of the segments of the internal list. */ bool isAirlineFlown (const AirlineCode_T&) const; - - /** Update Airline Code. */ - void updateAirlineCode (); - /** Update the total flight time and the flight path code after - adding a segment-date. */ - void updateAfterAddingSegmentPeriod (const SegmentPeriod&); - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. Modified: trunk/stdair/stdair/bom/SegmentPathPeriodContent.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriodContent.cpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPathPeriodContent.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -11,8 +11,7 @@ // //////////////////////////////////////////////////////////////////// SegmentPathPeriodContent::SegmentPathPeriodContent (const Key_T& iKey) - : _key (iKey), _airlineCode (DEFAULT_AIRLINE_CODE), - _flightPathCode (DEFAULT_FLIGHTPATH_CODE) { + : _key (iKey) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/SegmentPathPeriodContent.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriodContent.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPathPeriodContent.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -23,26 +23,17 @@ const Key_T& getKey() const { return _key; } - /** Get the airline code (from the whole outbound path). */ - const AirlineCode_T& getAirlineCode() const { - return _airlineCode; - } - /** Get the flightPathCode (from the whole outbound path). */ - const FlightPathCode_T& getFlightPathCode() const { - return _flightPathCode; - } - - /** Get the current flightPathCode (from the whole outbound path). */ - FlightPathCode_T getCurrentFlightPathCode() { - return _flightPathCode; - } - /** Get the number of segments (part of the primary key). */ - const NbOfSegments_T& getNbOfSegments() const { + const NbOfSegments_T getNbOfSegments() const { return _key.getNbOfSegments(); } + /** Get the boarding date offset list. */ + const DateOffsetList_T& getBoardingDateOffsetList () const { + return _key.getBoardingDateOffsetList(); + } + /** Get the elapsed time (part of the primary key). */ const Duration_T& getElapsedTime() const { return _key.getElapsedTime(); @@ -57,19 +48,12 @@ const Duration_T& getBoardingTime() const { return _key.getBoardingTime(); } - - public: - // /////////// Setters //////////// - /** Set Airline Code. */ - void setAirlineCode (const AirlineCode_T& iAirlineCode) { - _airlineCode = iAirlineCode; + + /** Get the departure period. */ + const PeriodStruct_T& getDeparturePeriod () const { + return _key.getPeriod(); } - /** Set the flight path Code. */ - void setFlightPathCode (const FlightPathCode_T& iFPCode) { - _flightPathCode = iFPCode; - } - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -99,12 +83,6 @@ // Attributes /** The key of both structure and content objects. */ Key_T _key; - - /** AirlineCode for the whole outboundPath.*/ - AirlineCode_T _airlineCode; - - /** FlightPathCode (AirlineCode + flight numbers of all segments). */ - FlightPathCode_T _flightPathCode; }; } Modified: trunk/stdair/stdair/bom/SegmentPathPeriodKey.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriodKey.cpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPathPeriodKey.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -10,27 +10,23 @@ // //////////////////////////////////////////////////////////////////// SegmentPathPeriodKey_T::SegmentPathPeriodKey_T () - : _dateRange (BOOST_DEFAULT_DATE_PERIOD), - _dow (DEFAULT_DOW_STRING), + : _period (), _boardingTime (NULL_BOOST_TIME_DURATION), _elapsed (NULL_BOOST_TIME_DURATION), - _nbOfSegments (0), _nbOfAirlines (0){ } // //////////////////////////////////////////////////////////////////// SegmentPathPeriodKey_T:: - SegmentPathPeriodKey_T (const DatePeriod_T& iDeparturePeriod, - const DoWStruct_T& iDoW, + SegmentPathPeriodKey_T (const PeriodStruct_T& iPeriod, const Duration_T& iBoardingTime, const Duration_T& iElapsedTime, - const NbOfSegments_T& iNbOfSegments, + const DateOffsetList_T& iBoardingDateOffsetList, const NbOfAirlines_T& iNbOfAirlines) - : _dateRange (iDeparturePeriod), - _dow (iDoW), + : _period (iPeriod), _boardingTime (iBoardingTime), _elapsed (iElapsedTime), - _nbOfSegments (iNbOfSegments), + _boardingDateOffsetList (iBoardingDateOffsetList), _nbOfAirlines (iNbOfAirlines){ } @@ -50,9 +46,15 @@ // //////////////////////////////////////////////////////////////////// const std::string SegmentPathPeriodKey_T::toString() const { std::ostringstream oStr; - oStr << _dateRange << ", " << _dow.describeShort () << ", " - << _boardingTime << ", " << _elapsed << ", " - << _nbOfSegments << ", " << _nbOfAirlines ; + oStr << _period.describeShort () << ", " + << _boardingTime << ", " << _elapsed << ", "; + for (DateOffsetList_T::const_iterator itOffset = + _boardingDateOffsetList.begin(); + itOffset != _boardingDateOffsetList.end(); ++itOffset) { + oStr << *itOffset << ", "; + } + + oStr << _nbOfAirlines ; return oStr.str(); } Modified: trunk/stdair/stdair/bom/SegmentPathPeriodKey.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriodKey.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPathPeriodKey.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -7,7 +7,8 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> -#include <stdair/bom/DoWStruct.hpp> +#include <stdair/bom/PeriodStruct.hpp> +#include <stdair/bom/SegmentPathPeriodTypes.hpp> namespace stdair { /** Key of SegmentPathPeriod. */ @@ -17,27 +18,26 @@ // /////////// Construction /////////// /** Constructors. */ SegmentPathPeriodKey_T (); - SegmentPathPeriodKey_T (const DatePeriod_T&, const DoWStruct_T&, + SegmentPathPeriodKey_T (const PeriodStruct_T&, const Duration_T&, const Duration_T&, - const NbOfSegments_T&, const NbOfAirlines_T&); + const DateOffsetList_T&, const NbOfAirlines_T&); /** Destructor. */ ~SegmentPathPeriodKey_T (); // /////////// Getters ////////// - /** Get the departure period. */ - const DatePeriod_T& getDeparturePeriod () const { - return _dateRange; + /** Get the active days-of-week. */ + const PeriodStruct_T& getPeriod () const { + return _period; } - /** Get the active days-of-week. */ - const DoWStruct_T& getDoW () const { - return _dow; + const DateOffsetList_T& getBoardingDateOffsetList () const { + return _boardingDateOffsetList; } /** Get the number of segments. */ - const NbOfSegments_T& getNbOfSegments() const { - return _nbOfSegments; + const NbOfSegments_T getNbOfSegments() const { + return _boardingDateOffsetList.size(); } /** Get the number of airlines. */ @@ -54,7 +54,32 @@ const Duration_T& getBoardingTime () const { return _boardingTime; } + + // /////////// Setters ////////// + /** Set the active days-of-week. */ + void setPeriod (const PeriodStruct_T& iPeriod) { + _period = iPeriod; + } + + void setBoardingDateOffsetList (const DateOffsetList_T& iList) { + _boardingDateOffsetList = iList; + } + /** Set the number of airlines. */ + void setNbOfAirlines (const NbOfAirlines_T& iNbOfAirlines) { + _nbOfAirlines = iNbOfAirlines; + } + + /** Set the elapsed time. */ + void setElapsedTime (const Duration_T& iElapsed) { + _elapsed = iElapsed; + } + + /** Set the boarding time. */ + void setBoardingTime (const Duration_T& iBoardingTime) { + _boardingTime = iBoardingTime; + } + // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @param ostream& the output stream. */ @@ -70,14 +95,17 @@ <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-cabin. */ const std::string toString() const; + + // /////////// Business methods //////////// + /** Check if the key is valid (i.e. the departure period is valid). */ + const bool isValid () const { + return _period.isValid (); + } private: // Attributes /** Departure peiod. */ - DatePeriod_T _dateRange; - - /** Active days-of-week. */ - DoWStruct_T _dow; + PeriodStruct_T _period; /** The boarding time. */ Duration_T _boardingTime; @@ -85,8 +113,9 @@ /** The elapsed time of the path. */ Duration_T _elapsed; - /** Number of segments included in the path. */ - NbOfSegments_T _nbOfSegments; + /** The list of boarding date offsets of the segments compare to + the first one. */ + DateOffsetList_T _boardingDateOffsetList; /** Number of airlines included in the path. */ NbOfAirlines_T _nbOfAirlines; Modified: trunk/stdair/stdair/bom/SegmentPathPeriodTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriodTypes.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPathPeriodTypes.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -8,6 +8,8 @@ // STL #include <map> #include <vector> +// STDAIR +#include <stdair/STDAIR_Types.hpp> namespace stdair { @@ -32,6 +34,10 @@ typedef std::vector<const SegmentPathPeriod*> SegmentPathPeriodLightList_T; typedef std::vector<SegmentPathPeriodLightList_T>SegmentPathPeriodListList_T; + + /** Define the vector of boarding date offsets of the member segments of + a segment path compare to the boarding date of the first segment. */ + typedef std::vector <DateOffset_T> DateOffsetList_T; } #endif // __STDAIR_BOM_SEGMENTPATHPERIODTYPES_HPP Modified: trunk/stdair/stdair/bom/SegmentPeriod.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPeriod.cpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPeriod.cpp 2010-06-30 15:59:19 UTC (rev 209) @@ -50,14 +50,6 @@ oStr << _structure.describeParentKey() << ", " << describeShortKey(); return oStr.str(); } - - // //////////////////////////////////////////////////////////////////// - bool SegmentPeriod:: - isConnectable (const SegmentPeriod& iSegmentPeriod) const { - bool oIsConnectable = false; - - return oIsConnectable; - } // //////////////////////////////////////////////////////////////////// const SegmentPeriod::Parent_T& SegmentPeriod::getParent () const { @@ -65,14 +57,9 @@ } // //////////////////////////////////////////////////////////////////// - const DatePeriod_T& SegmentPeriod::getDeparturePeriod () const { - return getParent().getDeparturePeriod(); + const PeriodStruct_T& SegmentPeriod::getPeriod () const { + return getParent().getPeriod(); } - - // //////////////////////////////////////////////////////////////////// - const DoWStruct_T& SegmentPeriod::getDoW () const { - return getParent().getDoW(); - } } Modified: trunk/stdair/stdair/bom/SegmentPeriod.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPeriod.hpp 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/SegmentPeriod.hpp 2010-06-30 15:59:19 UTC (rev 209) @@ -54,23 +54,10 @@ /** Get the parent object. */ const Parent_T& getParent () const; - /** Get the departure date range. */ - const DatePeriod_T& getDeparturePeriod () const; + /** Get the departure period of the flight-date parent. */ + const PeriodStruct_T& getPeriod () const; - /** Get the active days-of-week. */ - const DoWStruct_T& getDoW () const; - public: - // /////////// Business Methods ////////////// - /** States whether or not the given SegmentPeriod may connect with the - current one. - <br>Basically, the board time of the given SegmentPeriod should be - such as to allow the passenger connecting from the previous flight - (current SegmentPeriod object) to the next one (given SegmentPeriod). */ - bool isConnectable (const SegmentPeriod&) const; - - - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @param ostream& the output stream. */ Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-06-28 15:24:10 UTC (rev 208) +++ trunk/stdair/stdair/bom/sources.mk 2010-06-30 15:59:19 UTC (rev 209) @@ -100,6 +100,7 @@ $(top_srcdir)/stdair/bom/YieldStore.hpp \ $(top_srcdir)/stdair/bom/OptimizerStruct.hpp \ $(top_srcdir)/stdair/bom/DoWStruct.hpp \ + $(top_srcdir)/stdair/bom/PeriodStruct.hpp \ $(top_srcdir)/stdair/bom/TravelSolutionStruct.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ @@ -172,6 +173,7 @@ $(top_srcdir)/stdair/bom/YieldStore.cpp \ $(top_srcdir)/stdair/bom/OptimizerStruct.cpp \ $(top_srcdir)/stdair/bom/DoWStruct.cpp \ + $(top_srcdir)/stdair/bom/PeriodStruct.cpp \ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |