RMOL Logo Get Revenue Management Optimisation Library at SourceForge.net. Fast, secure and Free Open Source software downloads

Bucket.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // C
00005 #include <assert.h>
00006 // STL
00007 #include <iostream>
00008 #include <iomanip>
00009 // RMOL
00010 #include <rmol/bom/Demand.hpp>
00011 #include <rmol/bom/Bucket.hpp>
00012 
00013 namespace RMOL {
00014 
00015   // //////////////////////////////////////////////////////////////////////
00016   Bucket::Bucket ()
00017     : _demand (NULL),
00018       _yieldRange (), _protection (0.0), _cumulatedProtection (0.0),
00019       _bookingLimit (0.0), _cumulatedBookingLimit (0.0),
00020       _generatedDemandVector (NULL) {
00021   }
00022   
00023   // //////////////////////////////////////////////////////////////////////
00024   Bucket::Bucket (const Bucket& iBucket) :
00025     _demand (&iBucket.getDemand()), 
00026     _yieldRange (iBucket.getYieldRange()), 
00027     _protection (iBucket.getProtection()),
00028     _cumulatedProtection (iBucket.getCumulatedProtection()),
00029     _bookingLimit (iBucket.getBookingLimit()),
00030     _cumulatedBookingLimit (iBucket.getCumulatedBookingLimit()),
00031     _generatedDemandVector (NULL) {
00032   }
00033 
00034   // //////////////////////////////////////////////////////////////////////
00035   Bucket::Bucket (const FldYieldRange& iYieldRange) :
00036     _demand (NULL),
00037     _yieldRange (iYieldRange), _protection (0.0), _cumulatedProtection (0.0),
00038     _bookingLimit (0.0), _cumulatedBookingLimit (0.0),
00039     _generatedDemandVector (NULL) {
00040   }
00041   
00042   // //////////////////////////////////////////////////////////////////////
00043   Bucket::~Bucket() {
00044   }
00045 
00046   // //////////////////////////////////////////////////////////////////////
00047   const std::string Bucket::describeShortKey() const {
00048     std::ostringstream oStr;
00049     oStr << _yieldRange;
00050     return oStr.str();
00051   }
00052   
00053   // //////////////////////////////////////////////////////////////////////
00054   const std::string Bucket::describeKey() const {
00055     return describeShortKey();
00056   }
00057 
00058   // //////////////////////////////////////////////////////////////////////
00059   std::string Bucket::toString() const {
00060     std::ostringstream oStr;
00061     oStr << describeShortKey() << ", ";
00062     const double pj = getUpperYield();
00063     const double mj = getMean();
00064     const double sj = getStandardDeviation();
00065     const double proj = getProtection();
00066     const double yj = getCumulatedProtection();
00067     const double bj = getCumulatedBookingLimit();
00068     oStr << std::fixed << std::setprecision (2)
00069          << pj << "; " << mj << "; " << sj << "; " << proj << "; " << yj
00070          << "; " << bj << std::endl;
00071     
00072     return oStr.str();
00073   }   
00074 
00075   // //////////////////////////////////////////////////////////////////////
00076   void Bucket::toStream (std::ostream& ioOut) const {
00077     ioOut << toString();
00078   }
00079   
00080   // //////////////////////////////////////////////////////////////////////
00081   void Bucket::fromStream (std::istream& ioIn) {
00082   }
00083   
00084   // //////////////////////////////////////////////////////////////////////
00085   const std::string Bucket::shortDisplay() const {
00086     std::ostringstream oStr;
00087     oStr << describeKey();
00088     const double pj = getUpperYield();
00089     const double mj = getMean();
00090     const double sj = getStandardDeviation();
00091     const double proj = getProtection();
00092     const double yj = getCumulatedProtection();
00093     const double blj = getBookingLimit();
00094     const double bj = getCumulatedBookingLimit();
00095     oStr << std::fixed << std::setprecision (2)
00096          << ", upper yield = " << pj << "; "
00097          << ", mean = " << mj << "; " << ", std_dev = " << sj << "; "
00098          << ", protection = " << proj << "; "
00099          << ", cumulative protection = " << yj << "; "
00100          << ", booking limit = " << blj
00101          << ", cumulative booking limit = " << bj << std::endl;
00102 
00103     return oStr.str();
00104   }
00105   
00106   // //////////////////////////////////////////////////////////////////////
00107   const std::string Bucket::display() const {
00108     std::ostringstream oStr;
00109     oStr << shortDisplay();
00110     return oStr.str();
00111   }
00112 
00113   // //////////////////////////////////////////////////////////////////////
00114   const FldDistributionParameters& Bucket::getDistributionParameters() const {
00115     assert (_demand != NULL);
00116     return _demand->getDistributionParameters();
00117   }
00118 
00119   // //////////////////////////////////////////////////////////////////////
00120   Demand& Bucket::getDemand() const {
00121     assert (_demand != NULL);
00122     return *_demand;
00123   }
00124 
00125   // //////////////////////////////////////////////////////////////////////
00126   void Bucket::setDemand (Demand& iDemand) {
00127     _demand = &iDemand;
00128   }
00129 
00130   // //////////////////////////////////////////////////////////////////////
00131   void Bucket::setYieldRange (const double iYield) {
00132     _yieldRange.setUpperYield (iYield);
00133     _yieldRange.setAverageYield (iYield);
00134     _yieldRange.setLowerYield (iYield);
00135   }
00136 
00137   // //////////////////////////////////////////////////////////////////////
00138   void Bucket::setDemandParameters (const double iMean, const double iSD) {
00139     _demand->setMean (iMean);
00140     _demand->setSD (iSD);
00141   }
00142 
00143   // //////////////////////////////////////////////////////////////////////
00144   const double Bucket::getMean() const {
00145     assert (_demand != NULL);
00146     return _demand->getMean();
00147   }
00148 
00149   // //////////////////////////////////////////////////////////////////////
00150   const double Bucket::getStandardDeviation() const {
00151     assert (_demand != NULL);
00152     return _demand->getStandardDeviation();
00153   }
00154 
00155   // //////////////////////////////////////////////////////////////////////
00156   const double Bucket::getUpperYield() const {
00157     return _yieldRange.getUpperYield();
00158   }
00159 
00160   // //////////////////////////////////////////////////////////////////////
00161   const double Bucket::getAverageYield() const {
00162     return _yieldRange.getAverageYield();
00163   }
00164 
00165   // //////////////////////////////////////////////////////////////////////
00166   const double Bucket::getLowerYield() const {
00167     return _yieldRange.getLowerYield();
00168   }
00169 
00170   // //////////////////////////////////////////////////////////////////////
00171   void Bucket::
00172   setGeneratedDemandVector (GeneratedDemandVector_T* iVector) {
00173     _generatedDemandVector = iVector;
00174   }
00175 
00176 }
SourceForge Logo

Generated on Sat Jun 6 13:48:51 2009 for RMOL by Doxygen 1.5.7.1