You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(3) |
Feb
(2) |
Mar
(27) |
Apr
(8) |
May
(22) |
Jun
(10) |
Jul
(4) |
Aug
(3) |
Sep
(25) |
Oct
(12) |
Nov
|
Dec
(6) |
2010 |
Jan
(13) |
Feb
(3) |
Mar
(2) |
Apr
(1) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(14) |
Sep
(14) |
Oct
(4) |
Nov
(1) |
Dec
(2) |
From: <den...@us...> - 2009-09-17 16:03:58
|
Revision: 250 http://rmol.svn.sourceforge.net/rmol/?rev=250&view=rev Author: denis_arnaud Date: 2009-09-17 16:03:43 +0000 (Thu, 17 Sep 2009) Log Message: ----------- [Branch 0.23.0] Fixed ticket #1: the RPMs can now be generated. Modified Paths: -------------- branches/rmol/0.23.0/Ticket_1_01/rmol/bom/sources.mk Modified: branches/rmol/0.23.0/Ticket_1_01/rmol/bom/sources.mk =================================================================== --- branches/rmol/0.23.0/Ticket_1_01/rmol/bom/sources.mk 2009-09-17 15:32:40 UTC (rev 249) +++ branches/rmol/0.23.0/Ticket_1_01/rmol/bom/sources.mk 2009-09-17 16:03:43 UTC (rev 250) @@ -22,6 +22,9 @@ $(top_srcdir)/rmol/bom/StatAggregatorStruct.hpp \ $(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \ $(top_srcdir)/rmol/bom/StudyStatManager.hpp \ + $(top_srcdir)/rmol/bom/HistoricalBooking.hpp \ + $(top_srcdir)/rmol/bom/HistoricalBookingHolder.hpp \ + $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.hpp \ $(top_srcdir)/rmol/bom/SellupProbabilityCalculator.hpp \ $(top_srcdir)/rmol/bom/QEquivalentBookingCalculator.hpp bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-09-17 15:32:55
|
Revision: 249 http://rmol.svn.sourceforge.net/rmol/?rev=249&view=rev Author: denis_arnaud Date: 2009-09-17 15:32:40 +0000 (Thu, 17 Sep 2009) Log Message: ----------- [Branch 0.23.0] Created a working branch for the 0.23.0 release (from revision r244), for ticket #1. Added Paths: ----------- branches/rmol/0.23.0/Ticket_1_01/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-09-16 17:26:35
|
Revision: 248 http://rmol.svn.sourceforge.net/rmol/?rev=248&view=rev Author: dkchoe Date: 2009-09-16 17:26:27 +0000 (Wed, 16 Sep 2009) Log Message: ----------- [Q-Forecaster] Merged a few BOMs into QForecaster object; Added Utility struct which should include common operations for C++ standard objects(e.g. vector) Modified Paths: -------------- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp trunk/rmol/rmol/RMOL_Service.hpp trunk/rmol/rmol/bom/sources.mk trunk/rmol/rmol/command/Forecaster.cpp trunk/rmol/rmol/command/Forecaster.hpp trunk/rmol/rmol/command/sources.mk trunk/rmol/rmol/service/RMOL_Service.cpp Added Paths: ----------- trunk/rmol/rmol/bom/QForecaster.cpp trunk/rmol/rmol/bom/QForecaster.hpp trunk/rmol/rmol/command/Utilities.cpp trunk/rmol/rmol/command/Utilities.hpp Removed Paths: ------------- trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp Modified: trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp =================================================================== --- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-16 17:26:27 UTC (rev 248) @@ -18,9 +18,9 @@ SimilarFlightsDemandList_T; /** Define the holder of forecasted demand parameters (mean, std. deviation) - per booking class. Each row contains [class key, [mean, s.d.]] */ - typedef std::map<std::string, std::vector<double> > - ForecastedDemandParameterList_T; + per booking class. The order of the parameters corresponds to the vector + inputs resulted the parameters themselves.*/ + typedef std::vector<double> ForecastedDemandParameterList_T; /** Define a vector of fares. */ typedef std::vector<double> PriceHolder_T; Modified: trunk/rmol/rmol/RMOL_Service.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Service.hpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/RMOL_Service.hpp 2009-09-16 17:26:27 UTC (rev 248) @@ -124,7 +124,8 @@ /** Demand forecast using Q-Forecasting */ void demandForecastByQForecasting (ForecastedDemandParameterList_T, HistoricalDataHolderHolder_T&, - PriceHolder_T&); + PriceHolder_T&, + SellupFactorHolder_T&); private: /** Default Constructors. */ Deleted: trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp =================================================================== --- trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp 2009-09-16 17:26:27 UTC (rev 248) @@ -1,49 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <cmath> -// RMOL Bom -#include <rmol/bom/Bucket.hpp> -#include <rmol/bom/BucketHolder.hpp> -#include <rmol/bom/QEquivalentBookingCalculator.hpp> - -namespace RMOL { - - // ////////////////////////////////////////////////////////////////////// - void QEquivalentBookingCalculator::calculateQEquivalentBooking - (HistoricalBookingHolderHolder& iHistoricalBookingHolderHolder, - SellupProbabilityVector_T& iSellupProbabilityVector, - HolderOfQEquivalentBookingsPerSimilarFlight_T& - oHolderOfQEquivalentBookingsPerSimilarFlight) { - -// // Get the number of Buckets -// const double nbOfBuckets = ioBucketHolder.getSize(); - -// for (int j = 0; -// j < iHistoricalBookingHolderHolder.getNumberOfSimilarFlights(); -// j++) { - -// HistoricalBookingHolder& lHistoricalBookingHolder = -// iHistoricalBookingHolderHolder.at(j); - -// double qEquivalentBooking = 0.0; -// for (short k = 0; k < nbOfBuckets; k++) { -// HistoricalBooking& lHistoricalBooking = -// lCurrentHistoricalBookingVector.getHistoricalBooking(k); -// const double& lHBValue = lHistoricalBooking.getNumberOfBookings(); -// qEquivqlentBooking = qEquivqlentBooking + -// lHBValue * lSellupProbabilityVector[k]; -// } - -// oQEquivalentBookingsPerSimilarFlight.push_back(qEquivqlentBooking); -// } - -// // SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i} -// // where -// // ProbSellup_{bucket i} = -// // EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) - - - } -} Deleted: trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp =================================================================== --- trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp 2009-09-16 17:26:27 UTC (rev 248) @@ -1,33 +0,0 @@ -#ifndef __RMOL_BOM_QEQUIVQLENTBOOKINGCALCULATOR_HPP -#define __RMOL_BOM_QEQUIVQLENTBOOKINGCALCULATOR_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// RMOL Bom -#include <rmol/bom/BomAbstract.hpp> -#include <rmol/RMOL_Types.hpp> - -namespace RMOL { - - // Forward declaration - struct HistoricalBookingHolderHolder; - - /** Accessary Class for Sellup considered forecast methods. */ - class QEquivalentBookingCalculator : public BomAbstract { - - public: - - /** Calculate Q-equivalent bookings probability for given sell-up - probabilities.<br> - The formular was proposed by Belobaba and Hopperstad: - Algorithms for Revenue Management in Unrestricted Fare Markets, - AGIFORS, Auckland, New Zealand, Jan 2004 */ - static void calculateQEquivalentBooking - (HistoricalBookingHolderHolder&, - SellupProbabilityVector_T&, - HolderOfQEquivalentBookingsPerSimilarFlight_T&); - }; - -} -#endif // __RMOL_BOM_QEQUIVQLENTBOOKINGCALCULATOR_HPP Added: trunk/rmol/rmol/bom/QForecaster.cpp =================================================================== --- trunk/rmol/rmol/bom/QForecaster.cpp (rev 0) +++ trunk/rmol/rmol/bom/QForecaster.cpp 2009-09-16 17:26:27 UTC (rev 248) @@ -0,0 +1,32 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cmath> +// RMOL Bom +#include <rmol/bom/Bucket.hpp> +#include <rmol/bom/BucketHolder.hpp> +#include <rmol/bom/QForecaster.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////////// + void QForecaster::calculateSellupProbability + (BucketHolder& iBucketHolder, + const double iQYield, + const SellupFactorHolder_T& iSellupFactorHolder, + SellupProbabilityVector_T& ioSellupProbabilityVector) { + // Compute sell-up probability for each bucket and store it in a vector + short j = 0; + for (iBucketHolder.begin(); + iBucketHolder.hasNotReachedEnd(); + iBucketHolder.iterate()) { + Bucket& lCurrentBucket = iBucketHolder.getCurrentBucket(); + const double lYield = lCurrentBucket.getAverageYield(); + const double probSellup = + exp(-iSellupFactorHolder.at(j) *lYield/iQYield); + ioSellupProbabilityVector.push_back(probSellup); + j++; + } + } +} Added: trunk/rmol/rmol/bom/QForecaster.hpp =================================================================== --- trunk/rmol/rmol/bom/QForecaster.hpp (rev 0) +++ trunk/rmol/rmol/bom/QForecaster.hpp 2009-09-16 17:26:27 UTC (rev 248) @@ -0,0 +1,32 @@ +#ifndef __RMOL_BOM_QFORECASTER_HPP +#define __RMOL_BOM_QFORECASTER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL Bom +#include <rmol/bom/BomAbstract.hpp> + +namespace RMOL { + + // Forward declaration + class BucketHolder; + + /** Accessary Class for Sellup considered forecast methods. */ + class QForecaster : public BomAbstract { + + public: + + /** Calculate sell-up probability for given sell-up factor, + and yield ratio between the sell-up occurs.<br> + The formular was proposed by Belobaba and Hopperstad: + Algorithms for Revenue Management in Unrestricted Fare Markets, + AGIFORS, Auckland, New Zealand, Jan 2004 */ + static void calculateSellupProbability (BucketHolder&, + const double iQYield, + const SellupFactorHolder_T&, + SellupProbabilityVector_T&); + }; + +} +#endif // __RMOL_BOM_QFORECASTER_HPP Deleted: trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp =================================================================== --- trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp 2009-09-16 17:26:27 UTC (rev 248) @@ -1,32 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <cmath> -// RMOL Bom -#include <rmol/bom/Bucket.hpp> -#include <rmol/bom/BucketHolder.hpp> -#include <rmol/bom/SellupProbabilityCalculator.hpp> - -namespace RMOL { - - // ////////////////////////////////////////////////////////////////////// - void SellupProbabilityCalculator::calculateSellupProbability - (BucketHolder& iBucketHolder, - const double iQYield, - const SellupFactorHolder_T& iSellupFactorHolder, - SellupProbabilityVector_T& ioSellupProbabilityVector) { - // Compute sell-up probability for each bucket and store it in a vector - short j = 0; - for (iBucketHolder.begin(); - iBucketHolder.hasNotReachedEnd(); - iBucketHolder.iterate()) { - Bucket& lCurrentBucket = iBucketHolder.getCurrentBucket(); - const double lYield = lCurrentBucket.getAverageYield(); - const double probSellup = - exp(-iSellupFactorHolder.at(j) *lYield/iQYield); - ioSellupProbabilityVector.push_back(probSellup); - j++; - } - } -} Deleted: trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp =================================================================== --- trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp 2009-09-16 17:26:27 UTC (rev 248) @@ -1,32 +0,0 @@ -#ifndef __RMOL_BOM_SELLUPPROBABILITYCALCULATOR_HPP -#define __RMOL_BOM_SELLUPPROBABILITYCALCULATOR_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// RMOL Bom -#include <rmol/bom/BomAbstract.hpp> - -namespace RMOL { - - // Forward declaration - class BucketHolder; - - /** Accessary Class for Sellup considered forecast methods. */ - class SellupProbabilityCalculator : public BomAbstract { - - public: - - /** Calculate sell-up probability for given sell-up factor, - and yield ratio between the sell-up occurs.<br> - The formular was proposed by Belobaba and Hopperstad: - Algorithms for Revenue Management in Unrestricted Fare Markets, - AGIFORS, Auckland, New Zealand, Jan 2004 */ - static void calculateSellupProbability (BucketHolder&, - const double iQYield, - const SellupFactorHolder_T&, - SellupProbabilityVector_T&); - }; - -} -#endif // __RMOL_BOM_SELLUPPROBABILITYCALCULATOR_HPP Modified: trunk/rmol/rmol/bom/sources.mk =================================================================== --- trunk/rmol/rmol/bom/sources.mk 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/bom/sources.mk 2009-09-16 17:26:27 UTC (rev 248) @@ -22,8 +22,7 @@ $(top_srcdir)/rmol/bom/StatAggregatorStruct.hpp \ $(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \ $(top_srcdir)/rmol/bom/StudyStatManager.hpp \ - $(top_srcdir)/rmol/bom/SellupProbabilityCalculator.hpp \ - $(top_srcdir)/rmol/bom/QEquivalentBookingCalculator.hpp + $(top_srcdir)/rmol/bom/QForecaster.hpp bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \ $(top_srcdir)/rmol/bom/Bucket.cpp \ $(top_srcdir)/rmol/bom/BucketHolder.cpp \ @@ -41,5 +40,4 @@ $(top_srcdir)/rmol/bom/MAForecast.cpp \ $(top_srcdir)/rmol/bom/StatAggregatorStruct.cpp \ $(top_srcdir)/rmol/bom/StudyStatManager.cpp \ - $(top_srcdir)/rmol/bom/SellupProbabilityCalculator.cpp \ - $(top_srcdir)/rmol/bom/QEquivalentBookingCalculator.cpp \ No newline at end of file + $(top_srcdir)/rmol/bom/QForecaster.cpp \ No newline at end of file Modified: trunk/rmol/rmol/command/Forecaster.cpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.cpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/command/Forecaster.cpp 2009-09-16 17:26:27 UTC (rev 248) @@ -8,9 +8,9 @@ #include <rmol/bom/HistoricalBooking.hpp> #include <rmol/bom/HistoricalBookingHolder.hpp> #include <rmol/bom/HistoricalBookingHolderHolder.hpp> -#include <rmol/bom/SellupProbabilityCalculator.hpp> -#include <rmol/bom/QEquivalentBookingCalculator.hpp> +#include <rmol/bom/QForecaster.hpp> #include <rmol/command/Forecaster.hpp> +#include <rmol/command/Utilities.hpp> namespace RMOL { @@ -29,27 +29,41 @@ std::vector<double> lSellupProbabilityVector; // Compute sell-up probability for each bucket and store it in a vector - SellupProbabilityCalculator::calculateSellupProbability + QForecaster::calculateSellupProbability (ioBucketHolder, qYield, iSellupFactorHolder, lSellupProbabilityVector); // Compute total Q-equivalent bookings - QEquivalentBookingCalculator::calculateQEquivalentBooking - (iHistoricalBookingHolderHolder, - lSellupProbabilityVector, - oQEquivalentBookingsPerSimilarFlight); + // QEquivalentBookingCalculator::calculateQEquivalentBooking + // (iHistoricalBookingHolderHolder, + // lSellupProbabilityVector, + // oQEquivalentBookingsPerSimilarFlight); } // ////////////////////////////////////////////////////////////////////// void Forecaster::demandForecastByQForecasting (ForecastedDemandParameterList_T oForecastedDemandParameterList, HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder, - PriceHolder_T& iPriceHolder) { + PriceHolder_T& iPriceHolder, + SellupFactorHolder_T& iSellupFactorHolder) { // Run Q-Forecasting algorithm // 1. Obtain forecasted Q-eqivalent demand mean and s.d.(mu_Q, sigma_Q) // 2. Partition to each class // E(alpha x Q)=alpha x mu_Q, S.D.(alpha x Q) = |alpha| X sigma_Q - //qEquivalentDemandCalculation(); + // TODO: Find the class with the lowest yield + const double iQYield = Utilities::minimumElementOfAVector(iPriceHolder); + // // TODO: Initialize a vector for sell-up probabilities + // std::vector<double> lSellupProbabilityVector; + + // // TODO: Compute sell-up probability for each class/bucket & store it in a vector + // QForecaster::calculateSellupProbability + // (lSellupProbabilityVector, iQYield, iPriceHolder, iSellupFactorHolder); + + // // TODO: Q-equivalent demand calculation + // QForecaster::calculateQEquivalentDemandParametersAndPartition + // (oForecastedDemandParameterList, + // iHistoricalDataHolderHolder, lSellupProbabilityVector); + } } Modified: trunk/rmol/rmol/command/Forecaster.hpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.hpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/command/Forecaster.hpp 2009-09-16 17:26:27 UTC (rev 248) @@ -53,20 +53,23 @@ where ProbSellup_{bucket i} = EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) - static void qEquivalentBookingCalculation - (BucketHolder&, - SellupFactorHolder_T&, - HistoricalBookingHolderHolder&, + + static void qEquivalentDemandCalculation + (SellupFactorHolder_T&, + HistoricalDataHolderHolder&, HolderOfQEquivalentDemandsPerSimilarFlight_T&); - */ + */ /** A forecasting method developed by Belobaba and Hopperstad: Algorithms for Revenue Management in Unrestricted Fare Markets, AGIFORS, Auckland, New Zealand, Jan 2004 - */ + NOTES: Inputs are supposed to be appropriately ordered so that + i-th element of the PriceHolder is the price associated to the + i-th element of the HistoricalDataHolderHolder. */ static void demandForecastByQForecasting (ForecastedDemandParameterList_T, HistoricalDataHolderHolder_T&, - PriceHolder_T&); + PriceHolder_T&, + SellupFactorHolder_T&); }; } #endif // __RMOL_COMMAND_FORECASTER_HPP Added: trunk/rmol/rmol/command/Utilities.cpp =================================================================== --- trunk/rmol/rmol/command/Utilities.cpp (rev 0) +++ trunk/rmol/rmol/command/Utilities.cpp 2009-09-16 17:26:27 UTC (rev 248) @@ -0,0 +1,23 @@ + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +//STL +#include <algorithm> +#include <assert.h> +// RMOL +#include <rmol/command/Utilities.hpp> + +namespace RMOL { + + // ///////////////////////////////////////////////////////////////////// + const double Utilities::minimumElementOfAVector (std::vector<double> iVector) { + + assert(!iVector.empty()); + std::vector<double>::iterator pos = min_element (iVector.begin(), + iVector.end()); + return *pos; + + } + +} Added: trunk/rmol/rmol/command/Utilities.hpp =================================================================== --- trunk/rmol/rmol/command/Utilities.hpp (rev 0) +++ trunk/rmol/rmol/command/Utilities.hpp 2009-09-16 17:26:27 UTC (rev 248) @@ -0,0 +1,17 @@ +#ifndef __RMOL_COMMAND_UTILITIES_HPP +#define __RMOL_COMMAND_UTILITIES_HPP +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <vector> + +namespace RMOL { + + struct Utilities { + static const double minimumElementOfAVector(std::vector<double>); + }; + +} + +#endif // __RMOL_COMMAND_UTILITIES_HPP Modified: trunk/rmol/rmol/command/sources.mk =================================================================== --- trunk/rmol/rmol/command/sources.mk 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/command/sources.mk 2009-09-16 17:26:27 UTC (rev 248) @@ -1,8 +1,10 @@ cmd_h_sources = $(top_srcdir)/rmol/command/FileMgr.hpp \ $(top_srcdir)/rmol/command/Optimiser.hpp \ $(top_srcdir)/rmol/command/Unconstrainer.hpp \ - $(top_srcdir)/rmol/command/Forecaster.hpp + $(top_srcdir)/rmol/command/Forecaster.hpp \ + $(top_srcdir)/rmol/command/Utilities.hpp cmd_cc_sources = $(top_srcdir)/rmol/command/FileMgr.cpp \ $(top_srcdir)/rmol/command/Optimiser.cpp \ $(top_srcdir)/rmol/command/Unconstrainer.cpp \ - $(top_srcdir)/rmol/command/Forecaster.cpp \ No newline at end of file + $(top_srcdir)/rmol/command/Forecaster.cpp \ + $(top_srcdir)/rmol/command/Utilities.cpp \ No newline at end of file Modified: trunk/rmol/rmol/service/RMOL_Service.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-15 17:49:05 UTC (rev 247) +++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-16 17:26:27 UTC (rev 248) @@ -480,7 +480,8 @@ void RMOL_Service::demandForecastByQForecasting (ForecastedDemandParameterList_T oForecastedDemandParameterList, HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder, - PriceHolder_T& iPriceHolder) { + PriceHolder_T& iPriceHolder, + SellupFactorHolder_T& iSellupFactorHolder) { // assert (_rmolServiceContext != NULL); // const BucketHolder* oBucketHolder_ptr = // _rmolServiceContext->getBucketHolder(); @@ -489,7 +490,8 @@ // TO-DO Forecaster::demandForecastByQForecasting (oForecastedDemandParameterList, iHistoricalDataHolderHolder, - iPriceHolder); + iPriceHolder, + iSellupFactorHolder); // Fill in the forecasted demand parameters This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-09-15 17:49:12
|
Revision: 247 http://rmol.svn.sourceforge.net/rmol/?rev=247&view=rev Author: denis_arnaud Date: 2009-09-15 17:49:05 +0000 (Tue, 15 Sep 2009) Log Message: ----------- [Branch 0.23.0] Created the 0.23.0 release branch (from revision r244). Added Paths: ----------- branches/rmol/0.23.0/main/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-09-15 17:44:51
|
Revision: 246 http://rmol.svn.sourceforge.net/rmol/?rev=246&view=rev Author: denis_arnaud Date: 2009-09-15 17:44:44 +0000 (Tue, 15 Sep 2009) Log Message: ----------- Created the 0.23.0 release branch structure. Added Paths: ----------- branches/rmol/ branches/rmol/0.23.0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-09-15 17:23:32
|
Revision: 245 http://rmol.svn.sourceforge.net/rmol/?rev=245&view=rev Author: dkchoe Date: 2009-09-15 17:23:24 +0000 (Tue, 15 Sep 2009) Log Message: ----------- [Release] New working version (99.99.99). Modified Paths: -------------- trunk/rmol/configure.ac Modified: trunk/rmol/configure.ac =================================================================== --- trunk/rmol/configure.ac 2009-09-15 17:20:14 UTC (rev 244) +++ trunk/rmol/configure.ac 2009-09-15 17:23:24 UTC (rev 245) @@ -2,7 +2,7 @@ #------------------------------------------------------------------- AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (C) 2007-2009 Denis Arnaud <den...@us...>]) -AC_INIT([RMOL],[0.23.0],[den...@us...],[rmol]) +AC_INIT([RMOL],[99.99.99],[den...@us...],[rmol]) AC_CONFIG_HEADER([rmol/config.h]) AC_CONFIG_SRCDIR([rmol/basic/BasConst.cpp]) AC_CONFIG_AUX_DIR([config]) @@ -15,7 +15,7 @@ AC_SUBST(RPM_RELEASE) # Shared library versioning -GENERIC_LIBRARY_VERSION="0:23:0" +GENERIC_LIBRARY_VERSION="99:99:99" # | | | # +------+ | +---+ # | | | This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-09-15 17:20:24
|
Revision: 244 http://rmol.svn.sourceforge.net/rmol/?rev=244&view=rev Author: dkchoe Date: 2009-09-15 17:20:14 +0000 (Tue, 15 Sep 2009) Log Message: ----------- [Release 0.23.0] Modified Paths: -------------- trunk/rmol/AUTHORS trunk/rmol/ChangeLog trunk/rmol/NEWS trunk/rmol/README trunk/rmol/TODO trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp trunk/rmol/rmol/RMOL_Service.hpp trunk/rmol/rmol/command/Forecaster.cpp trunk/rmol/rmol/command/Forecaster.hpp trunk/rmol/rmol/service/RMOL_Service.cpp trunk/rmol/rmol.spec.in Modified: trunk/rmol/AUTHORS =================================================================== --- trunk/rmol/AUTHORS 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/AUTHORS 2009-09-15 17:20:14 UTC (rev 244) @@ -1,4 +1,5 @@ Denis Arnaud <denis dot arnaud_rmol at m4x dot org> +Dongkyoung Choe <dkchoe at users dot sourceforge dot net> Olivier d'Huart <olivier dot dhuart at mit dot edu> Anh Quan Nguyen <aquannguyen at gmail dot com> Patrick Grandjean <ptgrd at yahoo dot com> Modified: trunk/rmol/ChangeLog =================================================================== --- trunk/rmol/ChangeLog 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/ChangeLog 2009-09-15 17:20:14 UTC (rev 244) @@ -1,3 +1,5 @@ -* Fri Jun 5 2009 Anh Quan Nguyen <qua...@us...> 0.22.0 +* Tue Sep 15 2009 Dongkyoung Choe <dkchoe at users dot sourceforge dot net> 0.23.0 +- First implementation of the Q-Forecasting. + +* Fri Jun 5 2009 Anh Quan Nguyen <quannaus at users dot sourceforge dot net> 0.22.0 - Iterative DAVN implementation. - Modified: trunk/rmol/NEWS =================================================================== --- trunk/rmol/NEWS 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/NEWS 2009-09-15 17:20:14 UTC (rev 244) @@ -1,3 +1,4 @@ +2009-09-09: First version of the Q-Forecasting algorithm. 2009-03-07: Release of RPMs for Fedora 10. Modified: trunk/rmol/README =================================================================== --- trunk/rmol/README 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/README 2009-09-15 17:20:14 UTC (rev 244) @@ -1,4 +1,14 @@ +Getting and installing from the Fedora/CentOS/RedHat distribution: +------------------------------------------------------------------ +Just use Yum: +yum -y install rmol-devel rmol-doc + +You can also get the RPM packages (which may work on Linux +distributions like Novel Suse and Mandriva) from the Fedora repository +(e.g., for Fedora 11, +http://fr2.rpmfind.net/linux/fedora/releases/11/Everything/) + Building the library and test binary from Subversion repository: ---------------------------------------------------------------- The Sourceforge Subversion repository is to be found here: @@ -21,11 +31,10 @@ http://sourceforge.net/project/showfiles.php?group_id=177703 Then, as usual, you can just type the following sequence: -"./configure --prefix=/home/latus/dev/deliveries/rmol-0.19.0 && make && make check && cd test && ./testLibsh" +"./configure --prefix=/home/latus/dev/deliveries/rmol-0.23.0 && make && make check && cd test && ../rmol/batches/rmol -i ../samples/sample3.csv" Of course, if you want to install the library (librmol*.so*), just type: "make install". See the INSTALL file for more details. -Denis Arnaud (February 2007, revised July 2008) - +Denis Arnaud (February 2007, revised September 2009) Modified: trunk/rmol/TODO =================================================================== --- trunk/rmol/TODO 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/TODO 2009-09-15 17:20:14 UTC (rev 244) @@ -1,5 +1,5 @@ 1. Alter the documentation (doc/ directory). 2. Alter the man (man/ directory) and info (info/ directory) pages. 3. Alter the i18n (.po) files (po/ directory). -4. Automate the delivery of Distribution packages: .rpm, .deb. +4. Automate the delivery of Distribution packages: .deb. Modified: trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp =================================================================== --- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-15 17:20:14 UTC (rev 244) @@ -22,5 +22,14 @@ typedef std::map<std::string, std::vector<double> > ForecastedDemandParameterList_T; + /** Define a vector of fares. */ + typedef std::vector<double> PriceHolder_T; + +// /** Define historical data vector*/ +// typedef std::vector<double> HistoricalDataHolder_T; + + /** Define vector of historical data vector*/ + typedef std::vector< std::vector<double> > HistoricalDataHolderHolder_T; + } #endif // __RMOL_RMOL_FORECASTER_TYPES_HPP Modified: trunk/rmol/rmol/RMOL_Service.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Service.hpp 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/rmol/RMOL_Service.hpp 2009-09-15 17:20:14 UTC (rev 244) @@ -118,11 +118,13 @@ void demandUnconstrainingByExpectationMaximization (); /** Demand forecast using Q-Forecasting [used in unit tests] */ - void demandForecastByQForecasting (SimilarFlightsDemandList_T&); + void demandForecastByQForecasting (HistoricalDataHolderHolder_T&, + PriceHolder_T&); /** Demand forecast using Q-Forecasting */ - void demandForecastByQForecasting (SimilarFlightsDemandList_T&, - ForecastedDemandParameterList_T&); + void demandForecastByQForecasting (ForecastedDemandParameterList_T, + HistoricalDataHolderHolder_T&, + PriceHolder_T&); private: /** Default Constructors. */ Modified: trunk/rmol/rmol/command/Forecaster.cpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.cpp 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/rmol/command/Forecaster.cpp 2009-09-15 17:20:14 UTC (rev 244) @@ -41,13 +41,15 @@ // ////////////////////////////////////////////////////////////////////// void Forecaster::demandForecastByQForecasting - (SimilarFlightsDemandList_T& iSimilarFlightsDemandList, - ForecastedDemandParameterList_T& oForecastedDemandParameterList) { + (ForecastedDemandParameterList_T oForecastedDemandParameterList, + HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder, + PriceHolder_T& iPriceHolder) { // Run Q-Forecasting algorithm // 1. Obtain forecasted Q-eqivalent demand mean and s.d.(mu_Q, sigma_Q) // 2. Partition to each class // E(alpha x Q)=alpha x mu_Q, S.D.(alpha x Q) = |alpha| X sigma_Q + //qEquivalentDemandCalculation(); } } Modified: trunk/rmol/rmol/command/Forecaster.hpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.hpp 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/rmol/command/Forecaster.hpp 2009-09-15 17:20:14 UTC (rev 244) @@ -33,19 +33,40 @@ where ProbSellup_{bucket i} = EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) - */ + */ static void qEquivalentBookingCalculation (BucketHolder&, SellupFactorHolder_T&, HistoricalBookingHolderHolder&, HolderOfQEquivalentBookingsPerSimilarFlight_T&); + /** + An accessory algorithm for demand forecasting. + + Calculate Q-equivalent demands for the given group of + classes/buckets/fare points using the given + sell-up factors. + + Q-equivalent demands are, by definition, + + SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i} + where + ProbSellup_{bucket i} = + EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) + static void qEquivalentBookingCalculation + (BucketHolder&, + SellupFactorHolder_T&, + HistoricalBookingHolderHolder&, + HolderOfQEquivalentDemandsPerSimilarFlight_T&); + */ + /** A forecasting method developed by Belobaba and Hopperstad: Algorithms for Revenue Management in Unrestricted Fare Markets, AGIFORS, Auckland, New Zealand, Jan 2004 */ - static void demandForecastByQForecasting (SimilarFlightsDemandList_T&, - ForecastedDemandParameterList_T&); + static void demandForecastByQForecasting (ForecastedDemandParameterList_T, + HistoricalDataHolderHolder_T&, + PriceHolder_T&); }; } #endif // __RMOL_COMMAND_FORECASTER_HPP Modified: trunk/rmol/rmol/service/RMOL_Service.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-15 17:20:14 UTC (rev 244) @@ -440,34 +440,33 @@ // /////////////////////////////////////////////////////////////////////// void RMOL_Service::demandForecastByQForecasting - (SimilarFlightsDemandList_T& iSimilarFlightsDemandList) { -// assert (_rmolServiceContext != NULL); -// const BucketHolder* oBucketHolder_ptr = _rmolServiceContext->getBucketHolder(); -// assert (oBucketHolder_ptr != NULL); + (HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder, + PriceHolder_T& iPriceHolder) { // Declare forecaster output holder ForecastedDemandParameterList_T lForecastedDemandParameterList; - // Make an element of a ForecastedDemandParameterList_T. It is needed - // to use the reference of lForecastedDemandParameterList as an - // input argument. - double lMean = 0.0; - double lSD = 0.0; - std::vector<double> lForecastedDemandParameters; - lForecastedDemandParameters.push_back(lMean); - lForecastedDemandParameters.push_back(lSD); +// // Make an element of a ForecastedDemandParameterList_T. It is needed +// // to use the reference of lForecastedDemandParameterList as an +// // input argument. +// double lMean = 0.0; +// double lSD = 0.0; +// std::vector<double> lForecastedDemandParameters; +// lForecastedDemandParameters.push_back(lMean); +// lForecastedDemandParameters.push_back(lSD); - // Instantiate the forecaster output holder with the element created above - lForecastedDemandParameterList.insert - (std::map<std::string, std::vector<double> >:: - value_type("YNCELHR", lForecastedDemandParameters)); +// // Instantiate the forecaster output holder with the element created above +// lForecastedDemandParameterList.insert +// (std::map<std::string, std::vector<double> >:: +// value_type("YNCELHR", lForecastedDemandParameters)); - ForecastedDemandParameterList_T& lForecastedDemandParameterList_ref = - lForecastedDemandParameterList; +// ForecastedDemandParameterList_T& lForecastedDemandParameterList_ref = +// lForecastedDemandParameterList; - // Run Q-Forecasting algorithm - Forecaster::demandForecastByQForecasting (iSimilarFlightsDemandList, - lForecastedDemandParameterList_ref); +// // Run Q-Forecasting algorithm +// Forecaster::demandForecastByQForecasting (oForecastedDemandParameterList, +// iHistoricalDataHolderHolder, +// iPriceHolder); // DEBUG // RMOL_LOG_DEBUG (oBucketHolder_ptr->display()); @@ -479,16 +478,18 @@ // /////////////////////////////////////////////////////////////////////// void RMOL_Service::demandForecastByQForecasting - (SimilarFlightsDemandList_T& iSimilarFlightsDemandList, - ForecastedDemandParameterList_T& oForecastedDemandParameterList) { - assert (_rmolServiceContext != NULL); - const BucketHolder* oBucketHolder_ptr = - _rmolServiceContext->getBucketHolder(); - assert (oBucketHolder_ptr != NULL); + (ForecastedDemandParameterList_T oForecastedDemandParameterList, + HistoricalDataHolderHolder_T& iHistoricalDataHolderHolder, + PriceHolder_T& iPriceHolder) { +// assert (_rmolServiceContext != NULL); +// const BucketHolder* oBucketHolder_ptr = +// _rmolServiceContext->getBucketHolder(); +// assert (oBucketHolder_ptr != NULL); // TO-DO - Forecaster::demandForecastByQForecasting (iSimilarFlightsDemandList, - oForecastedDemandParameterList); + Forecaster::demandForecastByQForecasting (oForecastedDemandParameterList, + iHistoricalDataHolderHolder, + iPriceHolder); // Fill in the forecasted demand parameters Modified: trunk/rmol/rmol.spec.in =================================================================== --- trunk/rmol/rmol.spec.in 2009-09-14 16:57:24 UTC (rev 243) +++ trunk/rmol/rmol.spec.in 2009-09-15 17:20:14 UTC (rev 244) @@ -130,6 +130,9 @@ %changelog +* Tue Sep 15 2009 Denis Arnaud <den...@m4...> 0.23.0-1 +- Upstream integration + * Mon May 11 2009 Denis Arnaud <den...@m4...> 0.22.0-1 - Upstream integration This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ben...@us...> - 2009-09-14 16:57:37
|
Revision: 243 http://rmol.svn.sourceforge.net/rmol/?rev=243&view=rev Author: benoitrostykus Date: 2009-09-14 16:57:24 +0000 (Mon, 14 Sep 2009) Log Message: ----------- [Analysis] Added the analysis sub-project. Added Paths: ----------- trunk/rmol/analysis/ trunk/rmol/analysis/tools/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-09-04 14:31:23
|
Revision: 242 http://rmol.svn.sourceforge.net/rmol/?rev=242&view=rev Author: dkchoe Date: 2009-09-04 14:31:09 +0000 (Fri, 04 Sep 2009) Log Message: ----------- Added historical data BOM objects (struct) Modified Paths: -------------- trunk/rmol/rmol/bom/sources.mk Added Paths: ----------- trunk/rmol/rmol/bom/HistoricalDataHolder.cpp trunk/rmol/rmol/bom/HistoricalDataHolder.hpp trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp trunk/rmol/rmol/bom/HistoricalDataHolderHolder.hpp Added: trunk/rmol/rmol/bom/HistoricalDataHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalDataHolder.cpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalDataHolder.cpp 2009-09-04 14:31:09 UTC (rev 242) @@ -0,0 +1,89 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// GSL Random Number Generation +// (GSL Reference Manual, version 1.7, Chapter 19) +#include <gsl/gsl_cdf.h> +#include <gsl/gsl_randist.h> +// C +#include <assert.h> +#include <math.h> +// STL +#include <iostream> +//#include <iomanip> +//#include <cmath> +// RMU +#include <rmol/bom/HistoricalDataHolder.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////// + HistoricalDataHolder::HistoricalDataHolder () { + } + + // ////////////////////////////////////////////////////////////////// + HistoricalDataHolder::~HistoricalDataHolder () { + _historicalDataVector.clear(); + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalDataHolder::getMean () const { + double lResult = 0.0; + const double& lSize = getNumberOfHistoricalData(); + + for (short ite = 0; ite < lSize; ++ite) { + const double& lHistoricalData = getHistoricalData(ite); + lResult += (lHistoricalData); + } + + lResult /= lSize; + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalDataHolder::getStandardDeviation + (const double& iMean) const { + double lResult = 0.0; + const double& lSize = getNumberOfHistoricalData(); + + for (short ite = 0; ite < lSize; ++ite) { + const double& lHistorialData = getNumberOfHistoricalData(); + lResult += + (lHistorialData - iMean) * (lHistorialData - iMean); + } + + lResult /= (lSize - 1); + + lResult = sqrt (lResult); + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalDataHolder::toStream (std::ostream& ioOut) const { + const double& lSize = getNumberOfHistoricalData(); + + ioOut << "Historical Data Vector: " << std::endl; + + for (short ite = 0; ite < lSize; ++ite) { + const double& lHistoricalData = getHistoricalData(ite); + ioOut << lHistoricalData << " " + << std::endl; + } + } + + // ////////////////////////////////////////////////////////////////////// + const std::string HistoricalDataHolder::describe() const { + std::ostringstream ostr; + ostr << "Holder of historical data."; + + return ostr.str(); + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalDataHolder::display() const { + toStream (std::cout); + } + +} Added: trunk/rmol/rmol/bom/HistoricalDataHolder.hpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalDataHolder.hpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalDataHolder.hpp 2009-09-04 14:31:09 UTC (rev 242) @@ -0,0 +1,74 @@ +#ifndef __RMOL_BOM_HISTORICALDATAHOLDER_HPP +#define __RMOL_BOM_HISTORICALDATAHOLDER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <vector> +// RMOL +#include <rmol/bom/StructAbstract.hpp> + +namespace RMOL { + + /** HistoricalDataHolder + [Usage example] + Forecast remaining demand 10 days before departure for flight + 2009/09/02 AD101 NCE->CDG Y. + HistoricalDataHolder will be the Vector of [45;60;58] if the remaining + demand 10days before departure of the following similar flights: + 2009/08/05 AD101 NCE->CDG Y: 45 + 2009/08/12 AD101 NCE->CDG Y: 60 + 2009/08/19 AD101 NCE->CDG Y: 58 */ + struct HistoricalDataHolder : public StructAbstract { + + public: + // Getters + /** Get the number of historical data. */ + const double getNumberOfHistoricalData() const { + return _historicalDataVector.size(); + } + + /** Get the historical data. */ + const double& getHistoricalData(const short i) const { + return _historicalDataVector.at(i); + } + + /** Get the mean of the data*/ + const double getMean () const; + + /** Get the standard deviation of the data*/ + const double getStandardDeviation (const double& iMean) const; + + /** Add historical data to the holder. */ + void addHistoricalData (const double iHistoricalData) { + _historicalDataVector.push_back(iHistoricalData); + } + + /** Dump a Business Object into an output stream. + @param ostream& the output stream + @return ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + // ///////// Display Methods ////////// + /** Give a description of the structure (for display purposes). */ + const std::string describe() const; + + /** Display on standard output. */ + void display () const; + + /** Destructors. */ + virtual ~HistoricalDataHolder(); + + public: + /** Constructors. */ + HistoricalDataHolder (); + + HistoricalDataHolder (const HistoricalDataHolder&); + + private: + /** Vector of historical data. */ + std::vector<double> _historicalDataVector; + }; +} +#endif // __RMOL_BOM_HISTORICALDATAHOLDER_HPP Added: trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalDataHolderHolder.cpp 2009-09-04 14:31:09 UTC (rev 242) @@ -0,0 +1,56 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// GSL Random Number Generation +// (GSL Reference Manual, version 1.7, Chapter 19) +// #include <gsl/gsl_cdf.h> +// #include <gsl/gsl_randist.h> +// C +// #include <assert.h> +// #include <math.h> +// STL +#include <iostream> +#include <iomanip> +// #include <cmath> +// RMU +#include <rmol/bom/HistoricalDataHolder.hpp> +#include <rmol/bom/HistoricalDataHolderHolder.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////// + HistoricalDataHolderHolder::HistoricalDataHolderHolder () { + } + + // ////////////////////////////////////////////////////////////////// + HistoricalDataHolderHolder::~HistoricalDataHolderHolder () { + _historicalDataVectorVector.clear(); + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalDataHolderHolder::toStream (std::ostream& ioOut) const { + const short lSize = getNumberOfHistoricalDataHolder(); + + ioOut << "Holder of HistoricalDataHolder: " << std::endl; + + for (short ite = 0; ite < lSize; ++ite) { + const HistoricalDataHolder& lHistorialDataHolder = + _historicalDataVectorVector.at(ite); + lHistorialDataHolder.display(); + } + } + + // ////////////////////////////////////////////////////////////////// + const std::string HistoricalDataHolderHolder::describe() const { + std::ostringstream ostr; + ostr << "Holder of HistoricalData structs."; + + return ostr.str(); + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalDataHolderHolder::display() const { + toStream (std::cout); + } + +} Added: trunk/rmol/rmol/bom/HistoricalDataHolderHolder.hpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalDataHolderHolder.hpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalDataHolderHolder.hpp 2009-09-04 14:31:09 UTC (rev 242) @@ -0,0 +1,74 @@ +#ifndef __RMOL_BOM_HISTORICALDATAHOLDERHOLDER_HPP +#define __RMOL_BOM_HISTORICALDATAHOLDERHOLDER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iostream> +// RMOL +#include <rmol/bom/StructAbstract.hpp> + +namespace RMOL { + + /** Forward declaration. */ + struct HistoricalDataHolder; + + /** Define a vector (ordered list) of N HistoricalDatas. */ + typedef std::vector<HistoricalDataHolder> HistoricalDataVectorVector_T; + + /** Holder of a HistoricalDataHolder object. + [Usage example] + When computing Q-equivalent bookings, multiple HistoricalDataHolders + are needed. For example, + a HistoricalDataHolder of 2009/09/02 AD101 NCE->CDG Y & + a HistoricalDataHolder of 2009/09/02 AD101 NCE->CDG K. */ + struct HistoricalDataHolderHolder : public StructAbstract { + + public: + // ////// Getters ////// + /** Get the number of HistoricalDataHolder*/ + const short getNumberOfHistoricalDataHolder () const { + return _historicalDataVectorVector.size(); + } + + /** Get the (i+1)th HistoricalDataHolder. */ + const HistoricalDataHolder& getHistoricalDataHolder (const short i) const{ + return _historicalDataVectorVector.at(i); + } + + // ////// Setters ////// + /** Add a HistoricalData object to the holder. */ + void addHistoricalDataHolder (const HistoricalDataHolder iHDHolder) { + _historicalDataVectorVector.push_back(iHDHolder); + } + + /** Dump a Business Object into an output stream. + @param ostream& the output stream + @return ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + // ///////// Display Methods ////////// + /** Give a description of the structure (for display purposes). */ + const std::string describe() const; + + /** Display on standard output. */ + void display () const; + + /** Destructor. */ + virtual ~HistoricalDataHolderHolder(); + + public: + /** Constructor. + <br>Protected to force the use of the Factory. */ + HistoricalDataHolderHolder (); + + private: + + /** The list of (N) buckets/classes. */ + HistoricalDataVectorVector_T _historicalDataVectorVector; + + }; +} +#endif // __RMOL_BOM_HISTORICALDATAHOLDERHOLDER_HPP + Modified: trunk/rmol/rmol/bom/sources.mk =================================================================== --- trunk/rmol/rmol/bom/sources.mk 2009-09-03 13:40:00 UTC (rev 241) +++ trunk/rmol/rmol/bom/sources.mk 2009-09-04 14:31:09 UTC (rev 242) @@ -6,9 +6,8 @@ $(top_srcdir)/rmol/bom/Demand.hpp \ $(top_srcdir)/rmol/bom/DistributionParameterList.hpp \ $(top_srcdir)/rmol/bom/Gaussian.hpp \ - $(top_srcdir)/rmol/bom/HistoricalBooking.hpp \ - $(top_srcdir)/rmol/bom/HistoricalBookingHolder.hpp \ - $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.hpp \ + $(top_srcdir)/rmol/bom/HistoricalDataHolder.hpp \ + $(top_srcdir)/rmol/bom/HistoricalDataHolderHolder.hpp \ $(top_srcdir)/rmol/bom/PartialSumList.hpp \ $(top_srcdir)/rmol/bom/VariateList.hpp \ $(top_srcdir)/rmol/bom/PartialSumHolder.hpp \ @@ -30,9 +29,8 @@ $(top_srcdir)/rmol/bom/BucketHolder.cpp \ $(top_srcdir)/rmol/bom/Demand.cpp \ $(top_srcdir)/rmol/bom/Gaussian.cpp \ - $(top_srcdir)/rmol/bom/HistoricalBooking.cpp \ - $(top_srcdir)/rmol/bom/HistoricalBookingHolder.cpp \ - $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.cpp \ + $(top_srcdir)/rmol/bom/HistoricalDataHolder.cpp \ + $(top_srcdir)/rmol/bom/HistoricalDataHolderHolder.cpp \ $(top_srcdir)/rmol/bom/PartialSumHolder.cpp \ $(top_srcdir)/rmol/bom/PartialSumHolderHolder.cpp \ $(top_srcdir)/rmol/bom/Emsr.cpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-09-03 13:40:09
|
Revision: 241 http://rmol.svn.sourceforge.net/rmol/?rev=241&view=rev Author: dkchoe Date: 2009-09-03 13:40:00 +0000 (Thu, 03 Sep 2009) Log Message: ----------- Added source file Modified Paths: -------------- trunk/rmol/rmol/core/sources.mk Modified: trunk/rmol/rmol/core/sources.mk =================================================================== --- trunk/rmol/rmol/core/sources.mk 2009-09-02 17:14:10 UTC (rev 240) +++ trunk/rmol/rmol/core/sources.mk 2009-09-03 13:40:00 UTC (rev 241) @@ -1,3 +1,4 @@ service_h_sources = $(top_srcdir)/rmol/RMOL_Types.hpp \ - $(top_srcdir)/rmol/RMOL_Service.hpp + $(top_srcdir)/rmol/RMOL_Service.hpp \ + $(top_srcdir)/rmol/RMOL_FORECASTER_Types.hpp service_cc_sources = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-09-02 17:14:24
|
Revision: 240 http://rmol.svn.sourceforge.net/rmol/?rev=240&view=rev Author: dkchoe Date: 2009-09-02 17:14:10 +0000 (Wed, 02 Sep 2009) Log Message: ----------- Defined types related to forecaster: SimilarFlightsDemandList_T and ForecastedDemandParameterList_T which are respectively the input and output of a forecasting algorithm Modified Paths: -------------- trunk/rmol/rmol/RMOL_Service.hpp trunk/rmol/rmol/command/Forecaster.cpp trunk/rmol/rmol/command/Forecaster.hpp trunk/rmol/rmol/command/sources.mk trunk/rmol/rmol/service/RMOL_Service.cpp Added Paths: ----------- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp Added: trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp =================================================================== --- trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp (rev 0) +++ trunk/rmol/rmol/RMOL_FORECASTER_Types.hpp 2009-09-02 17:14:10 UTC (rev 240) @@ -0,0 +1,26 @@ +#ifndef __RMOL_RMOL_FORECASTER_TYPES_HPP +#define __RMOL_RMOL_FORECASTER_TYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <vector> +#include <map> + +namespace RMOL { + + // //////// Type definitions ///////// + + /** Define the map of a class code - segment (origine/destination) + and a vector of (unconstrained) demand of the similar flight-dates. */ + typedef std::map<std::string, std::vector<double> > + SimilarFlightsDemandList_T; + + /** Define the holder of forecasted demand parameters (mean, std. deviation) + per booking class. Each row contains [class key, [mean, s.d.]] */ + typedef std::map<std::string, std::vector<double> > + ForecastedDemandParameterList_T; + +} +#endif // __RMOL_RMOL_FORECASTER_TYPES_HPP Modified: trunk/rmol/rmol/RMOL_Service.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Service.hpp 2009-08-27 17:57:15 UTC (rev 239) +++ trunk/rmol/rmol/RMOL_Service.hpp 2009-09-02 17:14:10 UTC (rev 240) @@ -8,6 +8,7 @@ #include <string> // RMOL #include <rmol/RMOL_Types.hpp> +#include <rmol/RMOL_FORECASTER_Types.hpp> namespace RMOL { @@ -116,8 +117,12 @@ /** Demand unconstraining by Expectation Maximization */ void demandUnconstrainingByExpectationMaximization (); + /** Demand forecast using Q-Forecasting [used in unit tests] */ + void demandForecastByQForecasting (SimilarFlightsDemandList_T&); + /** Demand forecast using Q-Forecasting */ - void demandForecastByQForecasting (); + void demandForecastByQForecasting (SimilarFlightsDemandList_T&, + ForecastedDemandParameterList_T&); private: /** Default Constructors. */ Modified: trunk/rmol/rmol/command/Forecaster.cpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.cpp 2009-08-27 17:57:15 UTC (rev 239) +++ trunk/rmol/rmol/command/Forecaster.cpp 2009-09-02 17:14:10 UTC (rev 240) @@ -40,13 +40,14 @@ } // ////////////////////////////////////////////////////////////////////// - void Forecaster::demandForecastByQForecasting () { - // qEquivalentBookingCalculation - // (BucketHolder& ioBucketHolder, - // SellupFactorHolder_T& iSellupFactorHolder, - // HistoricalBookingHolderHolder& iHistoricalBookingHolderHolder, - // HolderOfQEquivalentBookingsPerSimilarFlight_T& - // oQEquivalentBookingsPerSimilarFlight); + void Forecaster::demandForecastByQForecasting + (SimilarFlightsDemandList_T& iSimilarFlightsDemandList, + ForecastedDemandParameterList_T& oForecastedDemandParameterList) { + // Run Q-Forecasting algorithm + // 1. Obtain forecasted Q-eqivalent demand mean and s.d.(mu_Q, sigma_Q) + // 2. Partition to each class + // E(alpha x Q)=alpha x mu_Q, S.D.(alpha x Q) = |alpha| X sigma_Q + } } Modified: trunk/rmol/rmol/command/Forecaster.hpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.hpp 2009-08-27 17:57:15 UTC (rev 239) +++ trunk/rmol/rmol/command/Forecaster.hpp 2009-09-02 17:14:10 UTC (rev 240) @@ -6,6 +6,7 @@ // ////////////////////////////////////////////////////////////////////// // RMOL #include <rmol/RMOL_Types.hpp> +#include <rmol/RMOL_FORECASTER_Types.hpp> namespace RMOL { @@ -43,7 +44,8 @@ Algorithms for Revenue Management in Unrestricted Fare Markets, AGIFORS, Auckland, New Zealand, Jan 2004 */ - static void demandForecastByQForecasting (); + static void demandForecastByQForecasting (SimilarFlightsDemandList_T&, + ForecastedDemandParameterList_T&); }; } #endif // __RMOL_COMMAND_FORECASTER_HPP Modified: trunk/rmol/rmol/command/sources.mk =================================================================== --- trunk/rmol/rmol/command/sources.mk 2009-08-27 17:57:15 UTC (rev 239) +++ trunk/rmol/rmol/command/sources.mk 2009-09-02 17:14:10 UTC (rev 240) @@ -4,5 +4,5 @@ $(top_srcdir)/rmol/command/Forecaster.hpp cmd_cc_sources = $(top_srcdir)/rmol/command/FileMgr.cpp \ $(top_srcdir)/rmol/command/Optimiser.cpp \ - $(top_srcdir)/rmol/command/Unconstrainer.cpp \ - $(top_srcdir)/rmol/command/Forecaster.cpp \ No newline at end of file + $(top_srcdir)/rmol/command/Unconstrainer.cpp \ + $(top_srcdir)/rmol/command/Forecaster.cpp \ No newline at end of file Modified: trunk/rmol/rmol/service/RMOL_Service.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-08-27 17:57:15 UTC (rev 239) +++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-09-02 17:14:10 UTC (rev 240) @@ -439,21 +439,61 @@ } // /////////////////////////////////////////////////////////////////////// - void RMOL_Service::demandForecastByQForecasting () { - assert (_rmolServiceContext != NULL); - const BucketHolder* oBucketHolder_ptr = _rmolServiceContext->getBucketHolder(); - assert (oBucketHolder_ptr != NULL); + void RMOL_Service::demandForecastByQForecasting + (SimilarFlightsDemandList_T& iSimilarFlightsDemandList) { +// assert (_rmolServiceContext != NULL); +// const BucketHolder* oBucketHolder_ptr = _rmolServiceContext->getBucketHolder(); +// assert (oBucketHolder_ptr != NULL); - // TO-DO - Forecaster::demandForecastByQForecasting (); + // Declare forecaster output holder + ForecastedDemandParameterList_T lForecastedDemandParameterList; + + // Make an element of a ForecastedDemandParameterList_T. It is needed + // to use the reference of lForecastedDemandParameterList as an + // input argument. + double lMean = 0.0; + double lSD = 0.0; + std::vector<double> lForecastedDemandParameters; + lForecastedDemandParameters.push_back(lMean); + lForecastedDemandParameters.push_back(lSD); + + // Instantiate the forecaster output holder with the element created above + lForecastedDemandParameterList.insert + (std::map<std::string, std::vector<double> >:: + value_type("YNCELHR", lForecastedDemandParameters)); + + ForecastedDemandParameterList_T& lForecastedDemandParameterList_ref = + lForecastedDemandParameterList; + + // Run Q-Forecasting algorithm + Forecaster::demandForecastByQForecasting (iSimilarFlightsDemandList, + lForecastedDemandParameterList_ref); // DEBUG - RMOL_LOG_DEBUG (oBucketHolder_ptr->display()); - +// RMOL_LOG_DEBUG (oBucketHolder_ptr->display()); std::ostringstream logStream; logStream << "Testing Demand Forecasting by Q-Forecasting"; RMOL_LOG_DEBUG (logStream.str()); } + + // /////////////////////////////////////////////////////////////////////// + void RMOL_Service::demandForecastByQForecasting + (SimilarFlightsDemandList_T& iSimilarFlightsDemandList, + ForecastedDemandParameterList_T& oForecastedDemandParameterList) { + assert (_rmolServiceContext != NULL); + const BucketHolder* oBucketHolder_ptr = + _rmolServiceContext->getBucketHolder(); + assert (oBucketHolder_ptr != NULL); + + // TO-DO + Forecaster::demandForecastByQForecasting (iSimilarFlightsDemandList, + oForecastedDemandParameterList); + + // Fill in the forecasted demand parameters + + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-08-27 17:57:26
|
Revision: 239 http://rmol.svn.sourceforge.net/rmol/?rev=239&view=rev Author: dkchoe Date: 2009-08-27 17:57:15 +0000 (Thu, 27 Aug 2009) Log Message: ----------- Added (empty) interfaces for unconstraining & forecasting algorithms; Added objects used for calculating Sellup probability and Q-eq bookings Modified Paths: -------------- trunk/rmol/rmol/RMOL_Service.hpp trunk/rmol/rmol/bom/sources.mk trunk/rmol/rmol/command/Forecaster.cpp trunk/rmol/rmol/command/Forecaster.hpp trunk/rmol/rmol/command/sources.mk trunk/rmol/rmol/service/RMOL_Service.cpp Added Paths: ----------- trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp trunk/rmol/rmol/command/Unconstrainer.cpp trunk/rmol/rmol/command/Unconstrainer.hpp Modified: trunk/rmol/rmol/RMOL_Service.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Service.hpp 2009-08-27 08:14:53 UTC (rev 238) +++ trunk/rmol/rmol/RMOL_Service.hpp 2009-08-27 17:57:15 UTC (rev 239) @@ -113,6 +113,12 @@ network optimisation. */ void legOptimisationByMC (BidPriceVector_T&, BookingLimitVector_T&); + /** Demand unconstraining by Expectation Maximization */ + void demandUnconstrainingByExpectationMaximization (); + + /** Demand forecast using Q-Forecasting */ + void demandForecastByQForecasting (); + private: /** Default Constructors. */ RMOL_Service (); Added: trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp =================================================================== --- trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp (rev 0) +++ trunk/rmol/rmol/bom/QEquivalentBookingCalculator.cpp 2009-08-27 17:57:15 UTC (rev 239) @@ -0,0 +1,49 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cmath> +// RMOL Bom +#include <rmol/bom/Bucket.hpp> +#include <rmol/bom/BucketHolder.hpp> +#include <rmol/bom/QEquivalentBookingCalculator.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////////// + void QEquivalentBookingCalculator::calculateQEquivalentBooking + (HistoricalBookingHolderHolder& iHistoricalBookingHolderHolder, + SellupProbabilityVector_T& iSellupProbabilityVector, + HolderOfQEquivalentBookingsPerSimilarFlight_T& + oHolderOfQEquivalentBookingsPerSimilarFlight) { + +// // Get the number of Buckets +// const double nbOfBuckets = ioBucketHolder.getSize(); + +// for (int j = 0; +// j < iHistoricalBookingHolderHolder.getNumberOfSimilarFlights(); +// j++) { + +// HistoricalBookingHolder& lHistoricalBookingHolder = +// iHistoricalBookingHolderHolder.at(j); + +// double qEquivalentBooking = 0.0; +// for (short k = 0; k < nbOfBuckets; k++) { +// HistoricalBooking& lHistoricalBooking = +// lCurrentHistoricalBookingVector.getHistoricalBooking(k); +// const double& lHBValue = lHistoricalBooking.getNumberOfBookings(); +// qEquivqlentBooking = qEquivqlentBooking + +// lHBValue * lSellupProbabilityVector[k]; +// } + +// oQEquivalentBookingsPerSimilarFlight.push_back(qEquivqlentBooking); +// } + +// // SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i} +// // where +// // ProbSellup_{bucket i} = +// // EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) + + + } +} Added: trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp =================================================================== --- trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp (rev 0) +++ trunk/rmol/rmol/bom/QEquivalentBookingCalculator.hpp 2009-08-27 17:57:15 UTC (rev 239) @@ -0,0 +1,33 @@ +#ifndef __RMOL_BOM_QEQUIVQLENTBOOKINGCALCULATOR_HPP +#define __RMOL_BOM_QEQUIVQLENTBOOKINGCALCULATOR_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL Bom +#include <rmol/bom/BomAbstract.hpp> +#include <rmol/RMOL_Types.hpp> + +namespace RMOL { + + // Forward declaration + struct HistoricalBookingHolderHolder; + + /** Accessary Class for Sellup considered forecast methods. */ + class QEquivalentBookingCalculator : public BomAbstract { + + public: + + /** Calculate Q-equivalent bookings probability for given sell-up + probabilities.<br> + The formular was proposed by Belobaba and Hopperstad: + Algorithms for Revenue Management in Unrestricted Fare Markets, + AGIFORS, Auckland, New Zealand, Jan 2004 */ + static void calculateQEquivalentBooking + (HistoricalBookingHolderHolder&, + SellupProbabilityVector_T&, + HolderOfQEquivalentBookingsPerSimilarFlight_T&); + }; + +} +#endif // __RMOL_BOM_QEQUIVQLENTBOOKINGCALCULATOR_HPP Added: trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp =================================================================== --- trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp (rev 0) +++ trunk/rmol/rmol/bom/SellupProbabilityCalculator.cpp 2009-08-27 17:57:15 UTC (rev 239) @@ -0,0 +1,32 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cmath> +// RMOL Bom +#include <rmol/bom/Bucket.hpp> +#include <rmol/bom/BucketHolder.hpp> +#include <rmol/bom/SellupProbabilityCalculator.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////////// + void SellupProbabilityCalculator::calculateSellupProbability + (BucketHolder& iBucketHolder, + const double iQYield, + const SellupFactorHolder_T& iSellupFactorHolder, + SellupProbabilityVector_T& ioSellupProbabilityVector) { + // Compute sell-up probability for each bucket and store it in a vector + short j = 0; + for (iBucketHolder.begin(); + iBucketHolder.hasNotReachedEnd(); + iBucketHolder.iterate()) { + Bucket& lCurrentBucket = iBucketHolder.getCurrentBucket(); + const double lYield = lCurrentBucket.getAverageYield(); + const double probSellup = + exp(-iSellupFactorHolder.at(j) *lYield/iQYield); + ioSellupProbabilityVector.push_back(probSellup); + j++; + } + } +} Added: trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp =================================================================== --- trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp (rev 0) +++ trunk/rmol/rmol/bom/SellupProbabilityCalculator.hpp 2009-08-27 17:57:15 UTC (rev 239) @@ -0,0 +1,32 @@ +#ifndef __RMOL_BOM_SELLUPPROBABILITYCALCULATOR_HPP +#define __RMOL_BOM_SELLUPPROBABILITYCALCULATOR_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL Bom +#include <rmol/bom/BomAbstract.hpp> + +namespace RMOL { + + // Forward declaration + class BucketHolder; + + /** Accessary Class for Sellup considered forecast methods. */ + class SellupProbabilityCalculator : public BomAbstract { + + public: + + /** Calculate sell-up probability for given sell-up factor, + and yield ratio between the sell-up occurs.<br> + The formular was proposed by Belobaba and Hopperstad: + Algorithms for Revenue Management in Unrestricted Fare Markets, + AGIFORS, Auckland, New Zealand, Jan 2004 */ + static void calculateSellupProbability (BucketHolder&, + const double iQYield, + const SellupFactorHolder_T&, + SellupProbabilityVector_T&); + }; + +} +#endif // __RMOL_BOM_SELLUPPROBABILITYCALCULATOR_HPP Modified: trunk/rmol/rmol/bom/sources.mk =================================================================== --- trunk/rmol/rmol/bom/sources.mk 2009-08-27 08:14:53 UTC (rev 238) +++ trunk/rmol/rmol/bom/sources.mk 2009-08-27 17:57:15 UTC (rev 239) @@ -22,7 +22,9 @@ $(top_srcdir)/rmol/bom/MAForecast.hpp \ $(top_srcdir)/rmol/bom/StatAggregatorStruct.hpp \ $(top_srcdir)/rmol/bom/StatAggregatorStructList.hpp \ - $(top_srcdir)/rmol/bom/StudyStatManager.hpp + $(top_srcdir)/rmol/bom/StudyStatManager.hpp \ + $(top_srcdir)/rmol/bom/SellupProbabilityCalculator.hpp \ + $(top_srcdir)/rmol/bom/QEquivalentBookingCalculator.hpp bom_cc_sources = $(top_srcdir)/rmol/bom/BomAbstract.cpp \ $(top_srcdir)/rmol/bom/Bucket.cpp \ $(top_srcdir)/rmol/bom/BucketHolder.cpp \ @@ -40,5 +42,6 @@ $(top_srcdir)/rmol/bom/DPOptimiser.cpp \ $(top_srcdir)/rmol/bom/MAForecast.cpp \ $(top_srcdir)/rmol/bom/StatAggregatorStruct.cpp \ - $(top_srcdir)/rmol/bom/StudyStatManager.cpp - + $(top_srcdir)/rmol/bom/StudyStatManager.cpp \ + $(top_srcdir)/rmol/bom/SellupProbabilityCalculator.cpp \ + $(top_srcdir)/rmol/bom/QEquivalentBookingCalculator.cpp \ No newline at end of file Modified: trunk/rmol/rmol/command/Forecaster.cpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.cpp 2009-08-27 08:14:53 UTC (rev 238) +++ trunk/rmol/rmol/command/Forecaster.cpp 2009-08-27 17:57:15 UTC (rev 239) @@ -8,6 +8,8 @@ #include <rmol/bom/HistoricalBooking.hpp> #include <rmol/bom/HistoricalBookingHolder.hpp> #include <rmol/bom/HistoricalBookingHolderHolder.hpp> +#include <rmol/bom/SellupProbabilityCalculator.hpp> +#include <rmol/bom/QEquivalentBookingCalculator.hpp> #include <rmol/command/Forecaster.hpp> namespace RMOL { @@ -23,52 +25,28 @@ // Get the lowest yield of the given buckets const double qYield = ioBucketHolder.getLowestAverageYield (); - // Get the number of Buckets - const double nbOfBuckets = ioBucketHolder.getSize(); - // Initialize a vector for sell-up probabilities std::vector<double> lSellupProbabilityVector; - /** Sell-up probability calculator */ // Compute sell-up probability for each bucket and store it in a vector - short j = 0; - for (ioBucketHolder.begin(); - ioBucketHolder.hasNotReachedEnd(); - ioBucketHolder.iterate()) { - Bucket& lCurrentBucket = ioBucketHolder.getCurrentBucket(); - const double lYield = lCurrentBucket.getAverageYield(); - const double probSellup = - exp(-iSellupFactorHolder.at(j) *lYield/qYield); - lSellupProbabilityVector.push_back(probSellup); - j++; - } + SellupProbabilityCalculator::calculateSellupProbability + (ioBucketHolder, qYield, iSellupFactorHolder, lSellupProbabilityVector); -// /** Q-equivqlent booking calculator */ -// // Compute total Q-equivalent bookings -// for (int j = 0; -// j < iHistoricalBookingHolderHolder.getNumberOfSimilarFlights(); -// j++) { + // Compute total Q-equivalent bookings + QEquivalentBookingCalculator::calculateQEquivalentBooking + (iHistoricalBookingHolderHolder, + lSellupProbabilityVector, + oQEquivalentBookingsPerSimilarFlight); + } -// HistoricalBookingHolder& lHistoricalBookingHolder = -// iHistoricalBookingHolderHolder.at(j); + // ////////////////////////////////////////////////////////////////////// + void Forecaster::demandForecastByQForecasting () { + // qEquivalentBookingCalculation + // (BucketHolder& ioBucketHolder, + // SellupFactorHolder_T& iSellupFactorHolder, + // HistoricalBookingHolderHolder& iHistoricalBookingHolderHolder, + // HolderOfQEquivalentBookingsPerSimilarFlight_T& + // oQEquivalentBookingsPerSimilarFlight); -// double qEquivqlentBooking = 0.0; -// for (short k = 0; k < nbOfBuckets; k++) { -// HistoricalBooking& lHistoricalBooking = -// lCurrentHistoricalBookingVector.getHistoricalBooking(k); -// const double& lHBValue = lHistoricalBooking.getNumberOfBookings(); -// qEquivqlentBooking = qEquivqlentBooking + -// lHBValue * lSellupProbabilityVector[k]; -// } - -// oQEquivalentBookingsPerSimilarFlight.push_back(qEquivqlentBooking); -// } - -// // SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i} -// // where -// // ProbSellup_{bucket i} = -// // EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) - } - } Modified: trunk/rmol/rmol/command/Forecaster.hpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.hpp 2009-08-27 08:14:53 UTC (rev 238) +++ trunk/rmol/rmol/command/Forecaster.hpp 2009-08-27 17:57:15 UTC (rev 239) @@ -6,7 +6,7 @@ // ////////////////////////////////////////////////////////////////////// // RMOL #include <rmol/RMOL_Types.hpp> -#include <rmol/bom/HistoricalBookingHolderHolder.hpp> + namespace RMOL { /** Forward declarations. */ @@ -38,6 +38,12 @@ SellupFactorHolder_T&, HistoricalBookingHolderHolder&, HolderOfQEquivalentBookingsPerSimilarFlight_T&); + + /** A forecasting method developed by Belobaba and Hopperstad: + Algorithms for Revenue Management in Unrestricted Fare Markets, + AGIFORS, Auckland, New Zealand, Jan 2004 + */ + static void demandForecastByQForecasting (); }; } #endif // __RMOL_COMMAND_FORECASTER_HPP Added: trunk/rmol/rmol/command/Unconstrainer.cpp =================================================================== --- trunk/rmol/rmol/command/Unconstrainer.cpp (rev 0) +++ trunk/rmol/rmol/command/Unconstrainer.cpp 2009-08-27 17:57:15 UTC (rev 239) @@ -0,0 +1,20 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL +#include <rmol/command/Unconstrainer.hpp> +// #include <rmol/bom/Bucket.hpp> +// #include <rmol/bom/BucketHolder.hpp> +// #include <rmol/bom/HistoricalBooking.hpp> +// #include <rmol/bom/HistoricalBookingHolder.hpp> +// #include <rmol/bom/HistoricalBookingHolderHolder.hpp> + + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////////// + void Unconstrainer::demandUnconstrainByExpectationMaximization () { } + + // ////////////////////////////////////////////////////////////////////// + +} Added: trunk/rmol/rmol/command/Unconstrainer.hpp =================================================================== --- trunk/rmol/rmol/command/Unconstrainer.hpp (rev 0) +++ trunk/rmol/rmol/command/Unconstrainer.hpp 2009-08-27 17:57:15 UTC (rev 239) @@ -0,0 +1,28 @@ +#ifndef __RMOL_COMMAND_UNCONSTRAINER_HPP +#define __RMOL_COMMAND_UNCONSTRAINER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL +#include <rmol/RMOL_Types.hpp> + +namespace RMOL { + + /** Forward declarations. */ + class BucketHolder; + struct HistoricalBookingHolderHolder; + + /** Class wrapping the principal unconstraining algorithms and + some accessory algorithms. */ + class Unconstrainer { + public: + + /** A sensored-demand unconstraining method based on + Expectation Maximization algorithm.<br> + Reference: K.T. Talluri and G.Van Ryzin, + The Theory and Practice of Revenue Management. */ + static void demandUnconstrainByExpectationMaximization (); + }; +} +#endif // __RMOL_COMMAND_UNCONSTRAINER_HPP Modified: trunk/rmol/rmol/command/sources.mk =================================================================== --- trunk/rmol/rmol/command/sources.mk 2009-08-27 08:14:53 UTC (rev 238) +++ trunk/rmol/rmol/command/sources.mk 2009-08-27 17:57:15 UTC (rev 239) @@ -1,6 +1,8 @@ cmd_h_sources = $(top_srcdir)/rmol/command/FileMgr.hpp \ $(top_srcdir)/rmol/command/Optimiser.hpp \ + $(top_srcdir)/rmol/command/Unconstrainer.hpp \ $(top_srcdir)/rmol/command/Forecaster.hpp cmd_cc_sources = $(top_srcdir)/rmol/command/FileMgr.cpp \ $(top_srcdir)/rmol/command/Optimiser.cpp \ + $(top_srcdir)/rmol/command/Unconstrainer.cpp \ $(top_srcdir)/rmol/command/Forecaster.cpp \ No newline at end of file Modified: trunk/rmol/rmol/service/RMOL_Service.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-08-27 08:14:53 UTC (rev 238) +++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-08-27 17:57:15 UTC (rev 239) @@ -17,6 +17,7 @@ #include <rmol/bom/StudyStatManager.hpp> #include <rmol/factory/FacRmolServiceContext.hpp> #include <rmol/command/Optimiser.hpp> +#include <rmol/command/Forecaster.hpp> #include <rmol/service/RMOL_ServiceContext.hpp> #include <rmol/service/Logger.hpp> #include <rmol/RMOL_Service.hpp> @@ -426,5 +427,33 @@ // Fill up booking vector oBucketHolder_ptr->fillup (ioBookingLimitVector); } + + // /////////////////////////////////////////////////////////////////////// + void demandUnconstrainingByExpectationMaximization () { + + // DEBUG + std::ostringstream logStream; + logStream << "Testing demand unconstraining by Expectation Maximization"; + RMOL_LOG_DEBUG (logStream.str()); + + } + + // /////////////////////////////////////////////////////////////////////// + void RMOL_Service::demandForecastByQForecasting () { + assert (_rmolServiceContext != NULL); + const BucketHolder* oBucketHolder_ptr = _rmolServiceContext->getBucketHolder(); + assert (oBucketHolder_ptr != NULL); + + // TO-DO + Forecaster::demandForecastByQForecasting (); + + // DEBUG + RMOL_LOG_DEBUG (oBucketHolder_ptr->display()); + + std::ostringstream logStream; + logStream << "Testing Demand Forecasting by Q-Forecasting"; + RMOL_LOG_DEBUG (logStream.str()); + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-08-27 08:15:00
|
Revision: 238 http://rmol.svn.sourceforge.net/rmol/?rev=238&view=rev Author: dkchoe Date: 2009-08-27 08:14:53 +0000 (Thu, 27 Aug 2009) Log Message: ----------- Added rmol service that doesn't require cabin capacity as input argument; Added Historical booking related structs(to be used for unconstraining); Modified Paths: -------------- trunk/rmol/rmol/RMOL_Service.hpp trunk/rmol/rmol/RMOL_Types.hpp trunk/rmol/rmol/bom/sources.mk trunk/rmol/rmol/command/Forecaster.cpp trunk/rmol/rmol/command/Forecaster.hpp trunk/rmol/rmol/service/RMOL_Service.cpp Added Paths: ----------- trunk/rmol/rmol/bom/HistoricalBooking.cpp trunk/rmol/rmol/bom/HistoricalBooking.hpp trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp trunk/rmol/rmol/bom/HistoricalBookingHolder.hpp trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.hpp trunk/rmol/rmol/bom/StructAbstract.hpp Modified: trunk/rmol/rmol/RMOL_Service.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Service.hpp 2009-08-18 17:42:18 UTC (rev 237) +++ trunk/rmol/rmol/RMOL_Service.hpp 2009-08-27 08:14:53 UTC (rev 238) @@ -18,6 +18,8 @@ class RMOL_Service { public: /** Constructor. */ + RMOL_Service (std::ostream& ioLogStream); + RMOL_Service (std::ostream& ioLogStream, const ResourceCapacity_T iResourceCapacity); /** Destructor. */ @@ -117,6 +119,8 @@ RMOL_Service (const RMOL_Service&); /** Initialise. */ + void init (std::ostream& ioLogStream); + void init (std::ostream& ioLogStream, const ResourceCapacity_T iResourceCapacity); Modified: trunk/rmol/rmol/RMOL_Types.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Types.hpp 2009-08-18 17:42:18 UTC (rev 237) +++ trunk/rmol/rmol/RMOL_Types.hpp 2009-08-27 08:14:53 UTC (rev 238) @@ -77,16 +77,19 @@ /** Define the holder of sellup factors (used for computing Q-eq bookings)*/ typedef std::vector<double> SellupFactorHolder_T; - /** Define the historical booking data of a flight date in the order of - the classes in the BucketHolder - eg. - BucketHolder=[Q;M;B;Y], OrderedHistoricalBookingVector_T=[10;5;0;0] - 5 corresponds to bookings of class M of a similar flight */ - typedef std::vector<double> OrderedHistoricalBookingVector_T; +// /** Define the historical booking data of a flight date in the order of +// the classes in the BucketHolder +// eg. +// BucketHolder=[Q;M;B;Y], OrderedHistoricalBookingVector_T=[10;5;0;0] +// 5 corresponds to bookings of class M of a similar flight */ +// typedef std::vector<double> OrderedHistoricalBookingVector_T; - /** Define the holder of historical booking vectors */ - typedef std::vector<OrderedHistoricalBookingVector_T> - HistoricalBookingVectorHolder_T; +// /** Define the holder of historical booking vectors */ +// typedef std::vector<HistoricalBookingHolder> +// HistoricalBookingHolderHolder_T; + /** Define the holder of Q-equivalent booking values*/ + typedef std::vector<double> HolderOfQEquivalentBookingsPerSimilarFlight_T; + } #endif // __RMOL_RMOL_TYPES_HPP Added: trunk/rmol/rmol/bom/HistoricalBooking.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBooking.cpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalBooking.cpp 2009-08-27 08:14:53 UTC (rev 238) @@ -0,0 +1,61 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// C +#include <assert.h> +// STL +#include <iostream> +#include <iomanip> +// RMU +#include <rmol/bom/HistoricalBooking.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////////// + HistoricalBooking::HistoricalBooking () : + _numberOfBookings (0.0),_unconstrainedDemand (0.0), _flag (false) { + } + + // ////////////////////////////////////////////////////////////////////// + void HistoricalBooking::setParameters + (const double iNumberOfBookings, const bool iFlag) { + _numberOfBookings = iNumberOfBookings; + _unconstrainedDemand = iNumberOfBookings; + _flag = iFlag; + } + + // ////////////////////////////////////////////////////////////////////// + HistoricalBooking::HistoricalBooking + (const HistoricalBooking& iHistoricalBooking) : + _numberOfBookings (iHistoricalBooking.getNumberOfBookings()), + _unconstrainedDemand (iHistoricalBooking.getUnconstrainedDemand()), + _flag (iHistoricalBooking.getFlag()) { + } + + // ////////////////////////////////////////////////////////////////////// + HistoricalBooking::~HistoricalBooking() { + } + + // ////////////////////////////////////////////////////////////////////// + const std::string HistoricalBooking::describe() const { + std::ostringstream ostr; + ostr << "Struct of hitorical booking, unconstrained demand and flag of " + << "censorship for a FlightDate/Class."; + + return ostr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + void HistoricalBooking::toStream (std::ostream& ioOut) const { + const double bj = getNumberOfBookings(); + const double uj = getUnconstrainedDemand(); + const bool fj = getFlag(); + ioOut << std::fixed << std::setprecision (2) + << bj << "; " << uj << "; " << fj << std::endl; + } + + // ////////////////////////////////////////////////////////////////////// + void HistoricalBooking::display () const { + toStream (std::cout); + } +} Added: trunk/rmol/rmol/bom/HistoricalBooking.hpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBooking.hpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalBooking.hpp 2009-08-27 08:14:53 UTC (rev 238) @@ -0,0 +1,73 @@ +#ifndef __RMOL_BOM_HISTORICALBOOKING_HPP +#define __RMOL_BOM_HISTORICALBOOKING_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL +#include <rmol/bom/StructAbstract.hpp> + +namespace RMOL { + + /** HistoricalBooking for a given class and the flag of censorship. + */ + struct HistoricalBooking : public StructAbstract { + + public: + // Getters + /** Getter for the booking. */ + const double& getNumberOfBookings() const { + return _numberOfBookings; + } + /** Getter for the unconstrained bookings. */ + const double& getUnconstrainedDemand() const { + return _unconstrainedDemand; + } + /** Getter for the flag of censorship: "false" means that the bookings + are not censored. */ + const bool& getFlag() const { + return _flag; + } + + /** Setter for the unconstraining demand. */ + void setUnconstrainedDemand (const double iDemand) { + _unconstrainedDemand = iDemand; + } + + /** Setter for all parameters (no of bkgs, flag). */ + void setParameters (const double, const bool); + + /** Dump a Business Object into an output stream. + @param ostream& the output stream + @return ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + // ///////// Display Methods ////////// + /** Give a description of the structure (for display purposes). */ + const std::string describe() const; + + /** Display on standard output. */ + void display () const; + + /** Destructors. */ + virtual ~HistoricalBooking(); + + public: + /** Constructors. + <br>Protected to force the use of the Factory. */ + HistoricalBooking (); + + HistoricalBooking (const HistoricalBooking&); + + private: + /** Number of historical bookings. */ + double _numberOfBookings; + + /** Unconstrained historical bookings. */ + double _unconstrainedDemand; + + /** Flag of censorship. */ + bool _flag; + }; +} +#endif // __RMOL_BOM_HISTORICALBOOKING_HPP Added: trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalBookingHolder.cpp 2009-08-27 08:14:53 UTC (rev 238) @@ -0,0 +1,277 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// GSL Random Number Generation +// (GSL Reference Manual, version 1.7, Chapter 19) +#include <gsl/gsl_cdf.h> +#include <gsl/gsl_randist.h> +// C +#include <assert.h> +#include <math.h> +// STL +#include <iostream> +#include <iomanip> +#include <cmath> +// RMU +#include <rmol/bom/HistoricalBooking.hpp> +#include <rmol/bom/HistoricalBookingHolder.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////// + HistoricalBookingHolder::HistoricalBookingHolder () { + } + + // ////////////////////////////////////////////////////////////////// + HistoricalBookingHolder::~HistoricalBookingHolder () { + _historicalBookingVector.clear(); + } + + // ////////////////////////////////////////////////////////////////// + const short HistoricalBookingHolder::getNumberOfFlights () const { + return _historicalBookingVector.size(); + } + + // ////////////////////////////////////////////////////////////////// + const short HistoricalBookingHolder::getNumberOfUncensoredData () const { + short lResult = 0; + const short lSize = _historicalBookingVector.size(); + + for (short ite = 0; ite < lSize; ++ite) { + const bool lFlag = _historicalBookingVector.at(ite).getFlag (); + if (lFlag == false) { + ++ lResult; + } + } + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalBookingHolder:: + getNumberOfUncensoredBookings () const { + double lResult = 0; + const short lSize = _historicalBookingVector.size(); + + for (short ite = 0; ite < lSize; ++ite) { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(ite); + const bool lFlag = lHistorialBooking.getFlag (); + if (lFlag == false) { + const double lBooking = + lHistorialBooking.getNumberOfBookings (); + lResult += lBooking; + } + } + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalBookingHolder::getUncensoredStandardDeviation + (const double iMeanOfUncensoredBookings, const short iNumberOfUncensoredData) + const { + + double lResult = 0; + const short lSize = _historicalBookingVector.size(); + + for (short ite = 0; ite < lSize; ++ite) { + const bool lFlag = _historicalBookingVector.at(ite).getFlag (); + if (lFlag == false) { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(ite); + + const double lBooking = + lHistorialBooking.getNumberOfBookings (); + + lResult += (lBooking - iMeanOfUncensoredBookings) + * (lBooking - iMeanOfUncensoredBookings); + } + } + lResult /= (iNumberOfUncensoredData - 1); + lResult = sqrt (lResult); + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalBookingHolder::getMeanDemand () const { + double lResult = 0; + const short lSize = _historicalBookingVector.size(); + + for (short ite = 0; ite < lSize; ++ite) { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(ite); + + const double lDemand = + lHistorialBooking.getUnconstrainedDemand (); + + lResult += static_cast<double>(lDemand); + } + + lResult /= lSize; + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalBookingHolder::getStandardDeviation + (const double iMeanDemand) const { + double lResult = 0; + const short lSize = _historicalBookingVector.size(); + + for (short ite = 0; ite < lSize; ++ite) { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(ite); + + const double lDemand = + lHistorialBooking.getUnconstrainedDemand (); + + const double lDoubleDemand = static_cast<double> (lDemand); + lResult += (lDoubleDemand - iMeanDemand) * (lDoubleDemand - iMeanDemand); + } + + lResult /= (lSize - 1); + + lResult = sqrt (lResult); + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const std::vector<bool> HistoricalBookingHolder:: + getListOfToBeUnconstrainedFlags () const { + std::vector<bool> lResult; + const short lSize = _historicalBookingVector.size(); + + for (short ite = 0; ite < lSize; ++ite) { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(ite); + const bool lFlag = lHistorialBooking.getFlag (); + if (lFlag == true) { + lResult.push_back(true); + } + else { + lResult.push_back(false); + } + } + + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalBookingHolder:: + getHistoricalBooking (const short i) const { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(i); + double lResult = lHistorialBooking.getNumberOfBookings(); + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + const double HistoricalBookingHolder:: + getUnconstrainedDemand (const short i) const { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(i); + double lResult = lHistorialBooking.getUnconstrainedDemand(); + return lResult; + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalBookingHolder::setUnconstrainedDemand + (const double iExpectedDemand, const short i) { + _historicalBookingVector.at(i).setUnconstrainedDemand(iExpectedDemand); + } + + // ////////////////////////////////////////////////////////////////////// + const double HistoricalBookingHolder::calculateExpectedDemand + (const double iMean, const double iSD, + const short i, const double iDemand) const { + + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(i); + const double lBooking = static_cast <double> + (lHistorialBooking.getNumberOfBookings()); + double e, d1, d2; + /* + e = - (lBooking - iMean) * (lBooking - iMean) * 0.625 / (iSD * iSD); + e = exp (e); + + // Prevent e to be too close to 0: that can cause d1 = 0. + //if (e < 0.01) { + // return iDemand; + //} + + double s = sqrt (1 - e); + + if (lBooking >= iMean) { + d1 = 0.5 * (1 - s); + } + else { + d1 = 0.5 * (1 + s); + } + */ + + d1 = gsl_cdf_gaussian_Q (lBooking - iMean, iSD); + + e = - (lBooking - iMean) * (lBooking - iMean) * 0.5 / (iSD * iSD); + e = exp (e); + + d2 = e * iSD / sqrt(2 * 3.14159265); + + // std::cout << "d1, d2 = " << d1 << " " << d2 << std::endl; + + if (d1 == 0) { + return iDemand; + } + + const double lDemand = + static_cast<double> (iMean + d2/d1); + + return lDemand; + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalBookingHolder::addHistoricalBooking + (const HistoricalBooking iHistoricalBooking) { + _historicalBookingVector.push_back(iHistoricalBooking); + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalBookingHolder::toStream (std::ostream& ioOut) const { + const short lSize = _historicalBookingVector.size(); + + ioOut << "Historical Booking; Unconstrained Demand; Flag" << std::endl; + + for (short ite = 0; ite < lSize; ++ite) { + const HistoricalBooking lHistorialBooking = + _historicalBookingVector.at(ite); + + const double lBooking = + lHistorialBooking.getNumberOfBookings(); + + const double lDemand = + lHistorialBooking.getUnconstrainedDemand(); + + const bool lFlag = lHistorialBooking.getFlag(); + + ioOut << lBooking << " " + << lDemand << " " + << lFlag << std::endl; + } + } + + // ////////////////////////////////////////////////////////////////////// + const std::string HistoricalBookingHolder::describe() const { + std::ostringstream ostr; + ostr << "Holder of HistoricalBooking structs."; + + return ostr.str(); + } + + // ////////////////////////////////////////////////////////////////// + void HistoricalBookingHolder::display() const { + toStream (std::cout); + } + +} Added: trunk/rmol/rmol/bom/HistoricalBookingHolder.hpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBookingHolder.hpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalBookingHolder.hpp 2009-08-27 08:14:53 UTC (rev 238) @@ -0,0 +1,103 @@ +#ifndef __RMOL_BOM_HISTORICALBOOKINGHOLDER_HPP +#define __RMOL_BOM_HISTORICALBOOKINGHOLDER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iostream> +#include <vector> +// RMOL +#include <rmol/RMOL_Types.hpp> +#include <rmol/bom/StructAbstract.hpp> + +namespace RMOL { + + /** Forward declaration. */ + struct HistoricalBooking; + + /** Define a vector (ordered list) of N HistoricalBookings. */ + typedef std::vector<HistoricalBooking> HistoricalBookingVector_T; + + /** Holder of a HistoricalBookingList object (for memory allocation and + recollection purposes). */ + struct HistoricalBookingHolder : public StructAbstract { + + public: + // ////// Getters ////// + /** Get number of flights. */ + const short getNumberOfFlights () const; + + /** Get number of uncensored booking data. */ + const short getNumberOfUncensoredData () const; + + /** Get number of uncensored bookings. */ + const double getNumberOfUncensoredBookings () const; + + /** Get standard deviation of uncensored bookings. */ + const double getUncensoredStandardDeviation + (const double iMeanOfUncensoredBookings, + const short iNumberOfUncensoredData) const; + + /** Get mean of historical demand. */ + const double getMeanDemand () const; + + /** Get standard deviation of demand. */ + const double getStandardDeviation (const double) const; + + /** Get the list of flags of need to be unconstrained. */ + const std::vector<bool> getListOfToBeUnconstrainedFlags() const; + + /** Get the historical booking of the (i+1)-th flight. */ + const double getHistoricalBooking (const short i) const; + + /** Get the unconstraining demand of the (i+1)-th flight. */ + const double getUnconstrainedDemand (const short i) const; + + /** Get the unconstraining demand of the first flight. */ + const double getUnconstrainedDemandOnFirstElement () const { + return getUnconstrainedDemand (0); + } + + /** Calculate the expected demand. */ + const double calculateExpectedDemand (const double, + const double, + const short, + const double) const; + + /** Set the expected historical demand of the (i+1)-th flight. */ + void setUnconstrainedDemand (const double iExpectedDemand, + const short i); + + /** Add a HistoricalBooking object to the holder. */ + void addHistoricalBooking (const HistoricalBooking iHistoricalBooking); + + /** Dump a Business Object into an output stream. + @param ostream& the output stream + @return ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + // ///////// Display Methods ////////// + /** Give a description of the structure (for display purposes). */ + const std::string describe() const; + + /** Display on standard output. */ + void display () const; + + /** Destructor. */ + virtual ~HistoricalBookingHolder(); + + public: + /** Constructor. + <br>Protected to force the use of the Factory. */ + HistoricalBookingHolder (); + + private: + + /** The list of (N) buckets/classes. */ + HistoricalBookingVector_T _historicalBookingVector; + + }; +} +#endif // __RMOL_BOM_HISTORICALBOOKINGHOLDER_HPP + Added: trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.cpp 2009-08-27 08:14:53 UTC (rev 238) @@ -0,0 +1,276 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// GSL Random Number Generation (GSL Reference Manual, version 1.7, Chapter 19) +#include <gsl/gsl_cdf.h> +#include <gsl/gsl_randist.h> +// C +#include <assert.h> +#include <math.h> +// STL +#include <iostream> +#include <iomanip> +#include <cmath> +// RMU +#include <rmol/bom/HistoricalBookingHolder.hpp> +#include <rmol/bom/HistoricalBookingHolderHolder.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////// + HistoricalBookingHolderHolder::HistoricalBookingHolderHolder () { + } + + // ////////////////////////////////////////////////////////////////// + HistoricalBookingHolderHolder::~HistoricalBookingHolderHolder () { + _historicalBookingHolderHolder.clear(); + } + + // ////////////////////////////////////////////////////////////////// + const int HistoricalBookingHolderHolder::getNumberOfSimilarFlights () + const { + return _historicalBookingHolderHolder.size(); + } + +// // ////////////////////////////////////////////////////////////////// +// const short HistoricalBookingHolderHolder::getNumberOfUncensoredData () const { +// short lResult = 0; +// const short lSize = _historicalBookingHolderHolder.size(); + +// for (short ite = 0; ite < lSize; ++ite) { +// const bool lFlag = _historicalBookingHolderHolder.at(ite).getFlag (); +// if (lFlag == false) { +// ++ lResult; +// } +// } + +// return lResult; +// } + +// // ////////////////////////////////////////////////////////////////// +// const double HistoricalBookingHolderHolder:: +// getNumberOfUncensoredBookings () const { +// double lResult = 0; +// const short lSize = _historicalBookingHolderHolder.size(); + +// for (short ite = 0; ite < lSize; ++ite) { +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(ite); +// const bool lFlag = lHistorialBooking.getFlag (); +// if (lFlag == false) { +// const double lBooking = +// lHistorialBooking.getNumberOfBookings (); +// lResult += lBooking; +// } +// } + +// return lResult; +// } + +// // ////////////////////////////////////////////////////////////////// +// const double HistoricalBookingHolderHolder::getUncensoredStandardDeviation +// (const double iMeanOfUncensoredBookings, const short iNumberOfUncensoredData) +// const { + +// double lResult = 0; +// const short lSize = _historicalBookingHolderHolder.size(); + +// for (short ite = 0; ite < lSize; ++ite) { +// const bool lFlag = _historicalBookingHolderHolder.at(ite).getFlag (); +// if (lFlag == false) { +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(ite); + +// const double lBooking = +// lHistorialBooking.getNumberOfBookings (); + +// lResult += (lBooking - iMeanOfUncensoredBookings) +// * (lBooking - iMeanOfUncensoredBookings); +// } +// } +// lResult /= (iNumberOfUncensoredData - 1); +// lResult = sqrt (lResult); + +// return lResult; +// } + +// // ////////////////////////////////////////////////////////////////// +// const double HistoricalBookingHolderHolder::getMeanDemand () const { +// double lResult = 0; +// const short lSize = _historicalBookingHolderHolder.size(); + +// for (short ite = 0; ite < lSize; ++ite) { +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(ite); + +// const double lDemand = +// lHistorialBooking.getUnconstrainedDemand (); + +// lResult += static_cast<double>(lDemand); +// } + +// lResult /= lSize; + +// return lResult; +// } + +// // ////////////////////////////////////////////////////////////////// +// const double HistoricalBookingHolderHolder::getStandardDeviation +// (const double iMeanDemand) const { +// double lResult = 0; +// const short lSize = _historicalBookingHolderHolder.size(); + +// for (short ite = 0; ite < lSize; ++ite) { +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(ite); + +// const double lDemand = +// lHistorialBooking.getUnconstrainedDemand (); + +// const double lDoubleDemand = static_cast<double> (lDemand); +// lResult += (lDoubleDemand - iMeanDemand) * (lDoubleDemand - iMeanDemand); +// } + +// lResult /= (lSize - 1); + +// lResult = sqrt (lResult); + +// return lResult; +// } + +// // ////////////////////////////////////////////////////////////////// +// const std::vector<bool> HistoricalBookingHolderHolder:: +// getListOfToBeUnconstrainedFlags () const { +// std::vector<bool> lResult; +// const short lSize = _historicalBookingHolderHolder.size(); + +// for (short ite = 0; ite < lSize; ++ite) { +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(ite); +// const bool lFlag = lHistorialBooking.getFlag (); +// if (lFlag == true) { +// lResult.push_back(true); +// } +// else { +// lResult.push_back(false); +// } +// } + +// return lResult; +// } + + // ////////////////////////////////////////////////////////////////// +// HistoricalBookingHolder& HistoricalBookingHolderHolder:: +// getHistoricalBookingVector (const int i) const { +// const HistoricalBookingHolder lHistoricalBookingVector = +// _historicalBookingHolderHolder.at(i); +// return lHistoricalBookingVector; +// } + +// // ////////////////////////////////////////////////////////////////// +// const double HistoricalBookingHolderHolder:: +// getUnconstrainedDemand (const short i) const { +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(i); +// double lResult = lHistorialBooking.getUnconstrainedDemand(); +// return lResult; +// } + +// // ////////////////////////////////////////////////////////////////// +// void HistoricalBookingHolderHolder::setUnconstrainedDemand +// (const double iExpectedDemand, const short i) { +// _historicalBookingHolderHolder.at(i).setUnconstrainedDemand(iExpectedDemand); +// } + +// // ////////////////////////////////////////////////////////////////////// +// const double HistoricalBookingHolderHolder::calculateExpectedDemand +// (const double iMean, const double iSD, +// const short i, const double iDemand) const { + +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(i); +// const double lBooking = static_cast <double> +// (lHistorialBooking.getNumberOfBookings()); +// double e, d1, d2; +// /* +// e = - (lBooking - iMean) * (lBooking - iMean) * 0.625 / (iSD * iSD); +// e = exp (e); + +// // Prevent e to be too close to 0: that can cause d1 = 0. +// //if (e < 0.01) { +// // return iDemand; +// //} + +// double s = sqrt (1 - e); + +// if (lBooking >= iMean) { +// d1 = 0.5 * (1 - s); +// } +// else { +// d1 = 0.5 * (1 + s); +// } +// */ + +// d1 = gsl_cdf_gaussian_Q (lBooking - iMean, iSD); + +// e = - (lBooking - iMean) * (lBooking - iMean) * 0.5 / (iSD * iSD); +// e = exp (e); + +// d2 = e * iSD / sqrt(2 * 3.14159265); + +// // std::cout << "d1, d2 = " << d1 << " " << d2 << std::endl; + +// if (d1 == 0) { +// return iDemand; +// } + +// const double lDemand = +// static_cast<double> (iMean + d2/d1); + +// return lDemand; +// } + +// // ////////////////////////////////////////////////////////////////// +// void HistoricalBookingHolderHolder::addHistoricalBooking +// (const HistoricalBooking iHistoricalBooking) { +// _historicalBookingHolderHolder.push_back(iHistoricalBooking); +// } + +// // ////////////////////////////////////////////////////////////////// +// void HistoricalBookingHolderHolder::toStream (std::ostream& ioOut) const { +// const short lSize = _historicalBookingHolderHolder.size(); + +// ioOut << "Historical Booking; Unconstrained Demand; Flag" << std::endl; + +// for (short ite = 0; ite < lSize; ++ite) { +// const HistoricalBooking lHistorialBooking = +// _historicalBookingHolderHolder.at(ite); + +// const double lBooking = +// lHistorialBooking.getNumberOfBookings(); + +// const double lDemand = +// lHistorialBooking.getUnconstrainedDemand(); + +// const bool lFlag = lHistorialBooking.getFlag(); + +// ioOut << lBooking << " " +// << lDemand << " " +// << lFlag << std::endl; +// } +// } + +// // ////////////////////////////////////////////////////////////////////// +// const std::string HistoricalBookingHolderHolder::describe() const { +// std::ostringstream ostr; +// ostr << "Holder of HistoricalBooking structs."; + +// return ostr.str(); +// } + +// // ////////////////////////////////////////////////////////////////// +// void HistoricalBookingHolderHolder::display() const { +// toStream (std::cout); +// } + +} Added: trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.hpp =================================================================== --- trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.hpp (rev 0) +++ trunk/rmol/rmol/bom/HistoricalBookingHolderHolder.hpp 2009-08-27 08:14:53 UTC (rev 238) @@ -0,0 +1,104 @@ +#ifndef __RMOL_BOM_HISTORICALBOOKINGVECTORHOLDER_HPP +#define __RMOL_BOM_HISTORICALBOOKINGVECTORHOLDER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iostream> +#include <vector> +// RMOL +// #include <rmol/RMOL_Types.hpp> +#include <rmol/bom/StructAbstract.hpp> + +namespace RMOL { + + /** Forward declaration. */ + struct HistoricalBookingHolder; + + /** Define a vector (ordered list) of N HistoricalBookings. */ + typedef std::vector<HistoricalBookingHolder> + HistoricalBookingHolderHolder_T; + + /** Holder of a HistoricalBookingList object (for memory allocation and + recollection purposes). */ + struct HistoricalBookingHolderHolder : public StructAbstract { + + public: + // ////// Getters ////// + /** Get number of similar flights. */ + const int getNumberOfSimilarFlights () const; + +// /** Get number of uncensored booking data. */ +// const short getNumberOfUncensoredData () const; + +// /** Get number of uncensored bookings. */ +// const double getNumberOfUncensoredBookings () const; + +// /** Get standard deviation of uncensored bookings. */ +// const double getUncensoredStandardDeviation +// (const double iMeanOfUncensoredBookings, +// const short iNumberOfUncensoredData) const; + +// /** Get mean of historical demand. */ +// const double getMeanDemand () const; + +// /** Get standard deviation of demand. */ +// const double getStandardDeviation (const double) const; + +// /** Get the list of flags of need to be unconstrained. */ +// const std::vector<bool> getListOfToBeUnconstrainedFlags() const; + + /** Get the historical booking Vector of the i-th similar flight. */ +// HistoricalBookingHolder& getHistoricalBookingVector (const int i) const; + +// /** Get the unconstraining demand of the (i+1)-th flight. */ +// const double getUnconstrainedDemand (const short i) const; + +// /** Get the unconstraining demand of the first flight. */ +// const double getUnconstrainedDemandOnFirstElement () const { +// return getUnconstrainedDemand (0); +// } + +// /** Calculate the expected demand. */ +// const double calculateExpectedDemand (const double, +// const double, +// const short, +// const double) const; + +// /** Set the expected historical demand of the (i+1)-th flight. */ +// void setUnconstrainedDemand (const double iExpectedDemand, +// const short i); + +// /** Add a HistoricalBooking object to the holder. */ +// void addHistoricalBooking (const HistoricalBooking iHistoricalBooking); + +// /** Dump a Business Object into an output stream. +// @param ostream& the output stream +// @return ostream& the output stream. */ +// void toStream (std::ostream& ioOut) const; + +// // ///////// Display Methods ////////// +// /** Give a description of the structure (for display purposes). */ +// const std::string describe() const; + +// /** Display on standard output. */ +// void display () const; + + /** Destructor. */ + virtual ~HistoricalBookingHolderHolder(); + + public: + /** Constructor. + <br>Protected to force the use of the Factory. */ + HistoricalBookingHolderHolder (); + + private: + + /** The list of (N) similar flights. */ + HistoricalBookingHolderHolder_T _historicalBookingHolderHolder; + + }; +} +#endif // __RMOL_BOM_HISTORICALBOOKINGVECTORHOLDER_HPP + Added: trunk/rmol/rmol/bom/StructAbstract.hpp =================================================================== --- trunk/rmol/rmol/bom/StructAbstract.hpp (rev 0) +++ trunk/rmol/rmol/bom/StructAbstract.hpp 2009-08-27 08:14:53 UTC (rev 238) @@ -0,0 +1,84 @@ +#ifndef __RMOL_BOM_STRUCTABSTRACT_HPP +#define __RMOL_BOM_STRUCTABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iostream> +#include <sstream> + +namespace RMOL { + + /** Base class for the Structures of the Business Object Model (BOM) + layer. */ + struct StructAbstract { + public: + + /** Destructor. */ + virtual ~StructAbstract() {} + + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { + ioOut << describe(); + } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + virtual void fromStream (std::istream& ioIn) {} + + /** Display of the structure. */ + virtual const std::string describe() const = 0; + + protected: + /** Protected Default Constructor to ensure this class is abtract. */ + StructAbstract() {} + }; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (p653) of his book "The C++ Standard Library: A Tutorial + and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_ostream<charT, traits>& +operator<< (std::basic_ostream<charT, traits>& ioOut, + const RMOL::StructAbstract& iStruct) { + /** + string stream: + - with same format + - without special field width + */ + std::basic_ostringstream<charT,traits> ostr; + ostr.copyfmt (ioOut); + ostr.width (0); + + // Fill string stream + iStruct.toStream (ostr); + + // Print string stream + ioOut << ostr.str(); + + return ioOut; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (pp655-657) of his book "The C++ Standard Library: + A Tutorial and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_istream<charT, traits>& +operator>> (std::basic_istream<charT, traits>& ioIn, + RMOL::StructAbstract& ioStruct) { + // Fill the Structure object with the input stream. + ioStruct.fromStream (ioIn); + return ioIn; + +} + +#endif // __RMOL_BOM_STRUCTABSTRACT_HPP Modified: trunk/rmol/rmol/bom/sources.mk =================================================================== --- trunk/rmol/rmol/bom/sources.mk 2009-08-18 17:42:18 UTC (rev 237) +++ trunk/rmol/rmol/bom/sources.mk 2009-08-27 08:14:53 UTC (rev 238) @@ -1,10 +1,14 @@ bom_h_sources = $(top_srcdir)/rmol/bom/BomAbstract.hpp \ + $(top_srcdir)/rmol/bom/StructAbstract.hpp \ $(top_srcdir)/rmol/bom/Bucket.hpp \ $(top_srcdir)/rmol/bom/BucketList.hpp \ $(top_srcdir)/rmol/bom/BucketHolder.hpp \ $(top_srcdir)/rmol/bom/Demand.hpp \ $(top_srcdir)/rmol/bom/DistributionParameterList.hpp \ $(top_srcdir)/rmol/bom/Gaussian.hpp \ + $(top_srcdir)/rmol/bom/HistoricalBooking.hpp \ + $(top_srcdir)/rmol/bom/HistoricalBookingHolder.hpp \ + $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.hpp \ $(top_srcdir)/rmol/bom/PartialSumList.hpp \ $(top_srcdir)/rmol/bom/VariateList.hpp \ $(top_srcdir)/rmol/bom/PartialSumHolder.hpp \ @@ -24,6 +28,9 @@ $(top_srcdir)/rmol/bom/BucketHolder.cpp \ $(top_srcdir)/rmol/bom/Demand.cpp \ $(top_srcdir)/rmol/bom/Gaussian.cpp \ + $(top_srcdir)/rmol/bom/HistoricalBooking.cpp \ + $(top_srcdir)/rmol/bom/HistoricalBookingHolder.cpp \ + $(top_srcdir)/rmol/bom/HistoricalBookingHolderHolder.cpp \ $(top_srcdir)/rmol/bom/PartialSumHolder.cpp \ $(top_srcdir)/rmol/bom/PartialSumHolderHolder.cpp \ $(top_srcdir)/rmol/bom/Emsr.cpp \ Modified: trunk/rmol/rmol/command/Forecaster.cpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.cpp 2009-08-18 17:42:18 UTC (rev 237) +++ trunk/rmol/rmol/command/Forecaster.cpp 2009-08-27 08:14:53 UTC (rev 238) @@ -1,23 +1,74 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// +#include <math.h> // RMOL +#include <rmol/bom/Bucket.hpp> #include <rmol/bom/BucketHolder.hpp> -#include <rmol/bom/Bucket.hpp> +#include <rmol/bom/HistoricalBooking.hpp> +#include <rmol/bom/HistoricalBookingHolder.hpp> +#include <rmol/bom/HistoricalBookingHolderHolder.hpp> #include <rmol/command/Forecaster.hpp> namespace RMOL { // ////////////////////////////////////////////////////////////////////// void Forecaster::qEquivalentBookingCalculation - (BucketHolder& ioBucketHolder, - SellupFactorHolder_T& iSellupFactorHolder, - HistoricalBookingVectorHolder_T& iHistoricalBookingVectorHolder){ + (BucketHolder& ioBucketHolder, + SellupFactorHolder_T& iSellupFactorHolder, + HistoricalBookingHolderHolder& iHistoricalBookingHolderHolder, + HolderOfQEquivalentBookingsPerSimilarFlight_T& + oQEquivalentBookingsPerSimilarFlight){ + // Get the lowest yield of the given buckets const double qYield = ioBucketHolder.getLowestAverageYield (); + // Get the number of Buckets + const double nbOfBuckets = ioBucketHolder.getSize(); + // Initialize a vector for sell-up probabilities + std::vector<double> lSellupProbabilityVector; + /** Sell-up probability calculator */ + // Compute sell-up probability for each bucket and store it in a vector + short j = 0; + for (ioBucketHolder.begin(); + ioBucketHolder.hasNotReachedEnd(); + ioBucketHolder.iterate()) { + Bucket& lCurrentBucket = ioBucketHolder.getCurrentBucket(); + const double lYield = lCurrentBucket.getAverageYield(); + const double probSellup = + exp(-iSellupFactorHolder.at(j) *lYield/qYield); + lSellupProbabilityVector.push_back(probSellup); + j++; + } + +// /** Q-equivqlent booking calculator */ +// // Compute total Q-equivalent bookings +// for (int j = 0; +// j < iHistoricalBookingHolderHolder.getNumberOfSimilarFlights(); +// j++) { + +// HistoricalBookingHolder& lHistoricalBookingHolder = +// iHistoricalBookingHolderHolder.at(j); + +// double qEquivqlentBooking = 0.0; +// for (short k = 0; k < nbOfBuckets; k++) { +// HistoricalBooking& lHistoricalBooking = +// lCurrentHistoricalBookingVector.getHistoricalBooking(k); +// const double& lHBValue = lHistoricalBooking.getNumberOfBookings(); +// qEquivqlentBooking = qEquivqlentBooking + +// lHBValue * lSellupProbabilityVector[k]; +// } + +// oQEquivalentBookingsPerSimilarFlight.push_back(qEquivqlentBooking); +// } + +// // SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i} +// // where +// // ProbSellup_{bucket i} = +// // EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) + } - + } Modified: trunk/rmol/rmol/command/Forecaster.hpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.hpp 2009-08-18 17:42:18 UTC (rev 237) +++ trunk/rmol/rmol/command/Forecaster.hpp 2009-08-27 08:14:53 UTC (rev 238) @@ -6,11 +6,12 @@ // ////////////////////////////////////////////////////////////////////// // RMOL #include <rmol/RMOL_Types.hpp> - +#include <rmol/bom/HistoricalBookingHolderHolder.hpp> namespace RMOL { /** Forward declarations. */ class BucketHolder; + struct HistoricalBookingHolderHolder; // class StudyStatManager; /** Class wrapping the principal forecasting algorithms and @@ -35,7 +36,8 @@ static void qEquivalentBookingCalculation (BucketHolder&, SellupFactorHolder_T&, - HistoricalBookingVectorHolder_T&); + HistoricalBookingHolderHolder&, + HolderOfQEquivalentBookingsPerSimilarFlight_T&); }; } #endif // __RMOL_COMMAND_FORECASTER_HPP Modified: trunk/rmol/rmol/service/RMOL_Service.cpp =================================================================== --- trunk/rmol/rmol/service/RMOL_Service.cpp 2009-08-18 17:42:18 UTC (rev 237) +++ trunk/rmol/rmol/service/RMOL_Service.cpp 2009-08-27 08:14:53 UTC (rev 238) @@ -34,6 +34,12 @@ } // ////////////////////////////////////////////////////////////////////// + RMOL_Service::RMOL_Service (std::ostream& ioLogStream) { + // Initialise the context + init (ioLogStream); + } + + // ////////////////////////////////////////////////////////////////////// RMOL_Service::RMOL_Service (std::ostream& ioLogStream, const ResourceCapacity_T iResourceCapacity) { // Initialise the context @@ -45,6 +51,17 @@ } // ////////////////////////////////////////////////////////////////////// + void RMOL_Service::init (std::ostream& ioLogStream) { + // Set the log file + logInit (LOG::DEBUG, ioLogStream); + + // Initialise the context + RMOL_ServiceContext& lRMOL_ServiceContext = + FacRmolServiceContext::instance().create (); + _rmolServiceContext = &lRMOL_ServiceContext; + } + + // ////////////////////////////////////////////////////////////////////// void RMOL_Service::init (std::ostream& ioLogStream, const ResourceCapacity_T iResourceCapacity) { // Set the log file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dk...@us...> - 2009-08-18 17:42:35
|
Revision: 237 http://rmol.svn.sourceforge.net/rmol/?rev=237&view=rev Author: dkchoe Date: 2009-08-18 17:42:18 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Added a function to get Q-yield (the lowest avg yield in the given BucketHolder Modified Paths: -------------- trunk/rmol/rmol/RMOL_Types.hpp trunk/rmol/rmol/bom/BucketHolder.cpp trunk/rmol/rmol/bom/BucketHolder.hpp trunk/rmol/rmol/command/sources.mk Added Paths: ----------- trunk/rmol/rmol/command/Forecaster.cpp trunk/rmol/rmol/command/Forecaster.hpp Modified: trunk/rmol/rmol/RMOL_Types.hpp =================================================================== --- trunk/rmol/rmol/RMOL_Types.hpp 2009-07-14 13:24:26 UTC (rev 236) +++ trunk/rmol/rmol/RMOL_Types.hpp 2009-08-18 17:42:18 UTC (rev 237) @@ -73,5 +73,20 @@ /** Define the sellup probability vector applicable to EMSR*/ typedef std::vector<double> SellupProbabilityVector_T; + + /** Define the holder of sellup factors (used for computing Q-eq bookings)*/ + typedef std::vector<double> SellupFactorHolder_T; + + /** Define the historical booking data of a flight date in the order of + the classes in the BucketHolder + eg. + BucketHolder=[Q;M;B;Y], OrderedHistoricalBookingVector_T=[10;5;0;0] + 5 corresponds to bookings of class M of a similar flight */ + typedef std::vector<double> OrderedHistoricalBookingVector_T; + + /** Define the holder of historical booking vectors */ + typedef std::vector<OrderedHistoricalBookingVector_T> + HistoricalBookingVectorHolder_T; + } #endif // __RMOL_RMOL_TYPES_HPP Modified: trunk/rmol/rmol/bom/BucketHolder.cpp =================================================================== --- trunk/rmol/rmol/bom/BucketHolder.cpp 2009-07-14 13:24:26 UTC (rev 236) +++ trunk/rmol/rmol/bom/BucketHolder.cpp 2009-08-18 17:42:18 UTC (rev 237) @@ -14,14 +14,14 @@ // ////////////////////////////////////////////////////////////////////// BucketHolder::BucketHolder () : - _cabinCapacity (100.0), - _totalMeanDemand (0.0), _demandFactor (0.0), _optimalRevenue (0.0) { + _cabinCapacity (100.0), _totalMeanDemand (0.0), _demandFactor (0.0), + _optimalRevenue (0.0) { } // ////////////////////////////////////////////////////////////////////// BucketHolder::BucketHolder (const double iCabinCapacity) : - _cabinCapacity (iCabinCapacity), - _totalMeanDemand (0.0), _demandFactor (0.0), _optimalRevenue (0.0) { + _cabinCapacity (iCabinCapacity), _totalMeanDemand (0.0), + _demandFactor (0.0), _optimalRevenue (0.0) { } // ////////////////////////////////////////////////////////////////////// @@ -51,7 +51,8 @@ std::ostringstream oStr; oStr << describeShortKey() << ", " << _totalMeanDemand - << ", " << _demandFactor << ", " << _optimalRevenue + << ", " << _demandFactor + << ", " << _optimalRevenue << std::endl; return oStr.str(); @@ -92,7 +93,8 @@ oStr << "Cabin Capacity = " << _cabinCapacity << "; Total Mean Demand = " << _totalMeanDemand << "; Demand Factor = " << _demandFactor - << "; Optimal Revenue = " << _optimalRevenue << std::endl; + << "; Optimal Revenue = " << _optimalRevenue + << std::endl; return oStr.str(); } @@ -232,6 +234,27 @@ } // ////////////////////////////////////////////////////////////////////// + const double BucketHolder::getLowestAverageYield () { + double oLowestAvgYield = 0.0; + + const short nbOfBuckets = getSize(); + assert (nbOfBuckets != 0); + + begin(); + Bucket& lFirstBucket = getCurrentBucket(); + oLowestAvgYield = lFirstBucket.getAverageYield(); + + for (short j = 1; j < nbOfBuckets; ++j, iterate()) { + Bucket& lNextBucket = getNextBucket(); + double lNextBucketAvgYield = lNextBucket.getAverageYield(); + if (lNextBucketAvgYield < oLowestAvgYield){ + oLowestAvgYield = lNextBucketAvgYield; + } + } + return oLowestAvgYield; + } + + // ////////////////////////////////////////////////////////////////////// void BucketHolder::recalculate () { // Re-calculate the booking limits calculateProtectionAndBookingLimits(); Modified: trunk/rmol/rmol/bom/BucketHolder.hpp =================================================================== --- trunk/rmol/rmol/bom/BucketHolder.hpp 2009-07-14 13:24:26 UTC (rev 236) +++ trunk/rmol/rmol/bom/BucketHolder.hpp 2009-08-18 17:42:18 UTC (rev 237) @@ -81,6 +81,8 @@ - the booking limits and cumulated booking limits. */ void recalculate (); + const double getLowestAverageYield (); + public: // ///////// Display methods //////// /** Dump a Business Object into an output stream. Added: trunk/rmol/rmol/command/Forecaster.cpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.cpp (rev 0) +++ trunk/rmol/rmol/command/Forecaster.cpp 2009-08-18 17:42:18 UTC (rev 237) @@ -0,0 +1,23 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL +#include <rmol/bom/BucketHolder.hpp> +#include <rmol/bom/Bucket.hpp> +#include <rmol/command/Forecaster.hpp> + +namespace RMOL { + + // ////////////////////////////////////////////////////////////////////// + void Forecaster::qEquivalentBookingCalculation + (BucketHolder& ioBucketHolder, + SellupFactorHolder_T& iSellupFactorHolder, + HistoricalBookingVectorHolder_T& iHistoricalBookingVectorHolder){ + + const double qYield = ioBucketHolder.getLowestAverageYield (); + + + + } + +} Added: trunk/rmol/rmol/command/Forecaster.hpp =================================================================== --- trunk/rmol/rmol/command/Forecaster.hpp (rev 0) +++ trunk/rmol/rmol/command/Forecaster.hpp 2009-08-18 17:42:18 UTC (rev 237) @@ -0,0 +1,41 @@ +#ifndef __RMOL_COMMAND_FORECASTER_HPP +#define __RMOL_COMMAND_FORECASTER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// RMOL +#include <rmol/RMOL_Types.hpp> + +namespace RMOL { + + /** Forward declarations. */ + class BucketHolder; + // class StudyStatManager; + + /** Class wrapping the principal forecasting algorithms and + some accessory algorithms for demand forecasting. */ + class Forecaster { + public: + + /** + An accessory algorithm for demand forecasting. + + Calculate Q-equivalent bookings for the given group of + classes/buckets/fare points using the given + sell-up factors. + + Q-equivalent bookings are, by definition, + + SUM_{buckets} histBooking_{bucket i} / ProbSellup_{bucket i} + where + ProbSellup_{bucket i} = + EXP(-sellupfactor*(yield_{bucket i}/lowest yield_{buckets})) + */ + static void qEquivalentBookingCalculation + (BucketHolder&, + SellupFactorHolder_T&, + HistoricalBookingVectorHolder_T&); + }; +} +#endif // __RMOL_COMMAND_FORECASTER_HPP Modified: trunk/rmol/rmol/command/sources.mk =================================================================== --- trunk/rmol/rmol/command/sources.mk 2009-07-14 13:24:26 UTC (rev 236) +++ trunk/rmol/rmol/command/sources.mk 2009-08-18 17:42:18 UTC (rev 237) @@ -1,4 +1,6 @@ cmd_h_sources = $(top_srcdir)/rmol/command/FileMgr.hpp \ - $(top_srcdir)/rmol/command/Optimiser.hpp + $(top_srcdir)/rmol/command/Optimiser.hpp \ + $(top_srcdir)/rmol/command/Forecaster.hpp cmd_cc_sources = $(top_srcdir)/rmol/command/FileMgr.cpp \ - $(top_srcdir)/rmol/command/Optimiser.cpp + $(top_srcdir)/rmol/command/Optimiser.cpp \ + $(top_srcdir)/rmol/command/Forecaster.cpp \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-07-14 13:24:29
|
Revision: 236 http://rmol.svn.sourceforge.net/rmol/?rev=236&view=rev Author: denis_arnaud Date: 2009-07-14 13:24:26 +0000 (Tue, 14 Jul 2009) Log Message: ----------- [R] Updated the RPM specification file for R-mvtnorm, so as to reflect newest upstream release. Modified Paths: -------------- trunk/R/R-mvtnorm.spec Modified: trunk/R/R-mvtnorm.spec =================================================================== --- trunk/R/R-mvtnorm.spec 2009-07-14 11:28:31 UTC (rev 235) +++ trunk/R/R-mvtnorm.spec 2009-07-14 13:24:26 UTC (rev 236) @@ -1,19 +1,19 @@ -%define packname mvtnorm -%define packrel 2 +%define packname mvtnorm +%define packrel 7 Summary: Multivariate normal and T distribution R Package Name: R-%{packname} Version: 0.9 -Release: 2%{?dist} +Release: 7%{?dist} License: GPLv2 Group: Applications/Engineering Source0: http://cran.r-project.org/src/contrib/%{packname}_%{version}-%{packrel}.tar.gz URL: http://cran.r-project.org/contrib/main/Descriptions/mvtnorm.html BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: R-devel, tetex-latex, gcc-gfortran -Requires(post): R -Requires(postun): R -Requires: R +Requires(post): R +Requires(postun): R +Requires: R %description @@ -62,6 +62,7 @@ %doc %{_libdir}/R/library/%{packname}/man %doc %{_libdir}/R/library/%{packname}/CHANGES %doc %{_libdir}/R/library/%{packname}/DESCRIPTION +%doc %{_libdir}/R/library/%{packname}/CITATION %{_libdir}/R/library/%{packname}/CONTENTS %{_libdir}/R/library/%{packname}/INDEX %{_libdir}/R/library/%{packname}/NAMESPACE @@ -73,6 +74,9 @@ %changelog +* Tue Jul 14 2009 Denis Arnaud <den...@m4...> - 0.9-7 +- Update to 0.9-7 + * Mon Feb 23 2009 Fedora Release Engineering <re...@li...> - 0.9-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild @@ -97,3 +101,4 @@ * Mon Mar 19 2007 Orion Poplawski <or...@co...> - 0.7-1 - Initial package + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-07-14 11:28:34
|
Revision: 235 http://rmol.svn.sourceforge.net/rmol/?rev=235&view=rev Author: denis_arnaud Date: 2009-07-14 11:28:31 +0000 (Tue, 14 Jul 2009) Log Message: ----------- [R] Added the RPM specification file for the R-mvtnorm package. Modified Paths: -------------- trunk/R/R-msm.spec Added Paths: ----------- trunk/R/R-mvtnorm.spec Modified: trunk/R/R-msm.spec =================================================================== --- trunk/R/R-msm.spec 2009-07-07 05:40:36 UTC (rev 234) +++ trunk/R/R-msm.spec 2009-07-14 11:28:31 UTC (rev 235) @@ -1,9 +1,8 @@ %global packname msm -%global packrel 1 Name: R-%{packname} Version: 0.9.1 -Release: 1%{?dist} +Release: 2%{?dist} Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}.tar.gz License: GPLv2+ URL: http://cran.r-project.org/web/packages/msm/ @@ -82,6 +81,9 @@ %{_libdir}/R/library/%{packname}/libs/%{packname}.so %changelog +* Tue Jul 14 2009 Denis Arnaud <den...@m4...> 0.9.1-2 +- Suppressed the unused definition of the packrel variable + * Fri Jun 12 2009 Denis Arnaud <den...@m4...> 0.9.1-1 - Integrated the new upstream (0.9.1) version Added: trunk/R/R-mvtnorm.spec =================================================================== --- trunk/R/R-mvtnorm.spec (rev 0) +++ trunk/R/R-mvtnorm.spec 2009-07-14 11:28:31 UTC (rev 235) @@ -0,0 +1,99 @@ +%define packname mvtnorm +%define packrel 2 + +Summary: Multivariate normal and T distribution R Package +Name: R-%{packname} +Version: 0.9 +Release: 2%{?dist} +License: GPLv2 +Group: Applications/Engineering +Source0: http://cran.r-project.org/src/contrib/%{packname}_%{version}-%{packrel}.tar.gz +URL: http://cran.r-project.org/contrib/main/Descriptions/mvtnorm.html +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: R-devel, tetex-latex, gcc-gfortran +Requires(post): R +Requires(postun): R +Requires: R + + +%description +This R package computes multivariate normal and t probabilities, quantiles +and densities. + + +%prep +%setup -q -c -n %{packname} + + +%build + + +%install +rm -rf %{buildroot} +mkdir -p $RPM_BUILD_ROOT%{_libdir}/R/library +%{_bindir}/R CMD INSTALL %{packname} -l %{buildroot}%{_libdir}/R/library +# Clean up in advance of check +test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) +rm -rf %{buildroot}%{_libdir}/R/library/R.css + + +%check +%{_bindir}/R CMD check %{packname} + + +%clean +rm -rf %{buildroot} + + +%post +%{_R_make_search_index} + + +%postun +%{_R_make_search_index} + + +%files +%defattr(-, root, root, -) +%dir %{_libdir}/R/library/%{packname} +%doc %{_libdir}/R/library/%{packname}/latex +%doc %{_libdir}/R/library/%{packname}/doc +%doc %{_libdir}/R/library/%{packname}/html +%doc %{_libdir}/R/library/%{packname}/man +%doc %{_libdir}/R/library/%{packname}/CHANGES +%doc %{_libdir}/R/library/%{packname}/DESCRIPTION +%{_libdir}/R/library/%{packname}/CONTENTS +%{_libdir}/R/library/%{packname}/INDEX +%{_libdir}/R/library/%{packname}/NAMESPACE +%{_libdir}/R/library/%{packname}/Meta +%{_libdir}/R/library/%{packname}/R +%{_libdir}/R/library/%{packname}/R-ex +%{_libdir}/R/library/%{packname}/help +%{_libdir}/R/library/%{packname}/libs + + +%changelog +* Mon Feb 23 2009 Fedora Release Engineering <re...@li...> - 0.9-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Sep 4 2008 Orion Poplawski <or...@co...> - 0.9-1 +- Update to 0.9-2 + +* Sat Feb 9 2008 Orion Poplawski <or...@co...> - 0.8-4 +- Rebuild for gcc 3.4 + +* Thu Aug 23 2007 Orion Poplawski <or...@co...> - 0.8-3 +- Update license tag to GPLv2 +- Rebuild for ppc32 + +* Tue Jul 24 2007 Orion Poplawski <or...@co...> - 0.8-2 +- Update to 0.8-1, fixes test + +* Mon Jul 23 2007 Orion Poplawski <or...@co...> - 0.8-1 +- Update to 0.8-0 + +* Wed Jul 11 2007 Orion Poplawski <or...@co...> - 0.7-2 +- Comply with R packaging guidelines + +* Mon Mar 19 2007 Orion Poplawski <or...@co...> - 0.7-1 +- Initial package This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-07-07 05:40:39
|
Revision: 234 http://rmol.svn.sourceforge.net/rmol/?rev=234&view=rev Author: denis_arnaud Date: 2009-07-07 05:40:36 +0000 (Tue, 07 Jul 2009) Log Message: ----------- [R-RM2 - v0.0-4] New release of the R-RM2 package. Modified Paths: -------------- trunk/R/R-RM2.spec Modified: trunk/R/R-RM2.spec =================================================================== --- trunk/R/R-RM2.spec 2009-07-06 19:52:33 UTC (rev 233) +++ trunk/R/R-RM2.spec 2009-07-07 05:40:36 UTC (rev 234) @@ -1,9 +1,8 @@ %global packname RM2 -%global packrel 1 Name: R-%{packname} Version: 0.0 -Release: 3%{?dist} +Release: 4%{?dist} Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}.tar.gz License: GPLv3+ URL: http://cran.r-project.org/web/packages/RM2/ @@ -48,11 +47,9 @@ %defattr(-, root, root, -) %dir %{_datadir}/R/library/%{packname} %doc %{_datadir}/R/library/%{packname}/latex -#%%doc %{_datadir}/R/library/%{packname}/doc %doc %{_datadir}/R/library/%{packname}/html %doc %{_datadir}/R/library/%{packname}/man %doc %{_datadir}/R/library/%{packname}/DESCRIPTION -#%%doc %{_datadir}/R/library/%{packname}/NEWS %{_datadir}/R/library/%{packname}/CONTENTS %{_datadir}/R/library/%{packname}/INDEX %{_datadir}/R/library/%{packname}/NAMESPACE @@ -62,6 +59,9 @@ %{_datadir}/R/library/%{packname}/help %changelog +* Tue Jul 07 2009 Denis Arnaud <den...@m4...> 0.0-4 +- Removed commented lines and unused variables/macros + * Mon Jul 06 2009 Denis Arnaud <den...@m4...> 0.0-3 - No longer use packrel for RPM release version, and updated the license from GPLv3 to GPLv3+ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-07-06 19:52:37
|
Revision: 233 http://rmol.svn.sourceforge.net/rmol/?rev=233&view=rev Author: denis_arnaud Date: 2009-07-06 19:52:33 +0000 (Mon, 06 Jul 2009) Log Message: ----------- [R-RM2] New release of the R-RM2 package. Modified Paths: -------------- trunk/R/R-RM2.spec Modified: trunk/R/R-RM2.spec =================================================================== --- trunk/R/R-RM2.spec 2009-06-27 20:11:57 UTC (rev 232) +++ trunk/R/R-RM2.spec 2009-07-06 19:52:33 UTC (rev 233) @@ -1,11 +1,11 @@ %global packname RM2 -%global packrel 2 +%global packrel 1 Name: R-%{packname} Version: 0.0 -Release: %{packrel}%{?dist} +Release: 3%{?dist} Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}.tar.gz -License: GPLv3 +License: GPLv3+ URL: http://cran.r-project.org/web/packages/RM2/ Group: Applications/Engineering Summary: Revenue Management and Pricing for R @@ -62,6 +62,10 @@ %{_datadir}/R/library/%{packname}/help %changelog +* Mon Jul 06 2009 Denis Arnaud <den...@m4...> 0.0-3 +- No longer use packrel for RPM release version, and updated + the license from GPLv3 to GPLv3+ + * Sat Jun 27 2009 Denis Arnaud <den...@m4...> 0.0-2 - Integrated the dependency on R-msm and R-mvtnorm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-06-27 20:12:39
|
Revision: 232 http://rmol.svn.sourceforge.net/rmol/?rev=232&view=rev Author: denis_arnaud Date: 2009-06-27 20:11:57 +0000 (Sat, 27 Jun 2009) Log Message: ----------- [RPM] New R-RM2 specification file. Modified Paths: -------------- trunk/R/R-RM2.spec Modified: trunk/R/R-RM2.spec =================================================================== --- trunk/R/R-RM2.spec 2009-06-15 16:04:29 UTC (rev 231) +++ trunk/R/R-RM2.spec 2009-06-27 20:11:57 UTC (rev 232) @@ -1,20 +1,20 @@ %global packname RM2 -%global packrel 1 +%global packrel 2 Name: R-%{packname} Version: 0.0 -Release: 1%{?dist} +Release: %{packrel}%{?dist} Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}.tar.gz License: GPLv3 -URL: http://cran.r-project.org/src/contrib +URL: http://cran.r-project.org/web/packages/RM2/ Group: Applications/Engineering Summary: Revenue Management and Pricing for R -BuildRequires: R-devel, tetex-latex, R-msm +BuildRequires: R-devel, tetex-latex, R-msm, R-mvtnorm BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires(post): R Requires(postun): R -Requires: R +Requires: R, R-msm, R-mvtnorm %description RM2 is a simple package that implements functions @@ -62,5 +62,9 @@ %{_datadir}/R/library/%{packname}/help %changelog +* Sat Jun 27 2009 Denis Arnaud <den...@m4...> 0.0-2 +- Integrated the dependency on R-msm and R-mvtnorm + * Sun May 03 2009 Denis Arnaud <den...@m4...> 0.0-1 - Initial package creation + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-06-15 16:04:33
|
Revision: 231 http://rmol.svn.sourceforge.net/rmol/?rev=231&view=rev Author: denis_arnaud Date: 2009-06-15 16:04:29 +0000 (Mon, 15 Jun 2009) Log Message: ----------- [Authors] Added Olivier d'Huart as co-author. Modified Paths: -------------- trunk/rmol/AUTHORS Modified: trunk/rmol/AUTHORS =================================================================== --- trunk/rmol/AUTHORS 2009-06-12 22:39:33 UTC (rev 230) +++ trunk/rmol/AUTHORS 2009-06-15 16:04:29 UTC (rev 231) @@ -1,3 +1,4 @@ Denis Arnaud <denis dot arnaud_rmol at m4x dot org> +Olivier d'Huart <olivier dot dhuart at mit dot edu> Anh Quan Nguyen <aquannguyen at gmail dot com> Patrick Grandjean <ptgrd at yahoo dot com> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-06-12 22:40:06
|
Revision: 230 http://rmol.svn.sourceforge.net/rmol/?rev=230&view=rev Author: denis_arnaud Date: 2009-06-12 22:39:33 +0000 (Fri, 12 Jun 2009) Log Message: ----------- [R-msm] Integrated the latest upstream version (0.9.1) of R-msm. Added Paths: ----------- trunk/R/msm/tests/Rplots.pdf Added: trunk/R/msm/tests/Rplots.pdf =================================================================== --- trunk/R/msm/tests/Rplots.pdf (rev 0) +++ trunk/R/msm/tests/Rplots.pdf 2009-06-12 22:39:33 UTC (rev 230) @@ -0,0 +1,1280 @@ +%PDF-1.4 +%\x81\xE2\x81\xE3\x81ρ\xD3\r +1 0 obj +<< +/CreationDate (D:20090528183927) +/ModDate (D:20090528183927) +/Title (R Graphics Output) +/Producer (R 2.9.0) +/Creator (R) +>> +endobj +2 0 obj +<< +/Type /Catalog +/Pages 3 0 R +>> +endobj +5 0 obj +<< +/Type /Page +/Parent 3 0 R +/Contents 6 0 R +/Resources 4 0 R +>> +endobj +6 0 obj +<< +/Length 7 0 R +>> +stream +q +Q q 49.00 312.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +55.59 449.74 m +57.26 438.78 l +58.92 430.15 l +60.58 428.12 l +62.25 425.97 l +63.91 419.91 l +65.58 409.55 l +67.24 409.27 l +68.90 405.51 l +70.57 400.56 l +72.23 395.31 l +73.89 393.21 l +75.56 386.79 l +77.22 387.50 l +78.89 383.98 l +80.55 378.10 l +82.21 375.29 l +83.88 373.02 l +85.54 369.57 l +87.20 362.93 l +88.87 360.69 l +90.53 360.69 l +92.20 357.67 l +93.86 354.09 l +95.52 352.59 l +97.19 349.07 l +98.85 342.77 l +100.52 343.84 l +102.18 342.44 l +103.84 337.51 l +105.51 335.99 l +107.17 336.23 l +108.83 336.48 l +110.50 335.13 l +112.16 333.92 l +113.83 333.69 l +115.49 331.96 l +117.15 324.48 l +118.82 324.48 l +120.48 324.38 l +122.15 324.19 l +123.81 324.19 l +125.47 324.19 l +127.14 322.26 l +128.80 322.39 l +130.46 322.46 l +132.13 324.58 l +133.79 322.53 l +135.46 322.60 l +137.12 322.53 l +138.78 320.41 l +140.45 322.53 l +142.11 320.37 l +143.78 324.48 l +145.44 326.44 l +147.10 328.33 l +148.77 330.17 l +150.43 326.31 l +152.09 326.19 l +153.76 326.19 l +155.42 326.19 l +157.09 326.19 l +158.75 326.44 l +160.41 326.31 l +162.08 324.38 l +163.74 324.38 l +165.41 326.31 l +167.07 324.29 l +168.73 322.33 l +170.40 322.39 l +172.06 322.39 l +173.72 322.39 l +175.39 320.34 l +177.05 320.30 l +178.72 320.30 l +180.38 320.34 l +182.04 320.34 l +183.71 320.34 l +185.37 320.34 l +187.04 320.34 l +188.70 320.34 l +190.36 318.22 l +192.03 318.22 l +193.69 320.30 l +195.35 320.30 l +197.02 320.30 l +198.68 320.30 l +200.35 320.30 l +202.01 320.30 l +203.67 320.30 l +205.34 320.30 l +207.00 320.30 l +208.67 320.30 l +210.33 320.30 l +211.99 320.30 l +213.66 320.30 l +215.32 320.30 l +216.98 320.30 l +218.65 320.30 l +220.31 318.22 l +S +Q q +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +55.39 312.96 m 199.91 312.96 l S +55.39 312.96 m 55.39 306.98 l S +84.29 312.96 m 84.29 306.98 l S +113.19 312.96 m 113.19 306.98 l S +142.10 312.96 m 142.10 306.98 l S +171.00 312.96 m 171.00 306.98 l S +199.91 312.96 m 199.91 306.98 l S +BT +0.000 0.000 0.000 rg +/F2 1 Tf 10.00 0.00 -0.00 10.00 52.61 291.44 Tm (0) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 78.73 291.44 Tm (10) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 107.63 291.44 Tm (20) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 136.54 291.44 Tm (30) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 165.44 291.44 Tm (40) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 194.35 291.44 Tm (50) Tj +ET +49.00 318.22 m 49.00 449.74 l S +49.00 318.22 m 43.03 318.22 l S +49.00 344.52 m 43.03 344.52 l S +49.00 370.82 m 43.03 370.82 l S +49.00 397.13 m 43.03 397.13 l S +49.00 423.43 m 43.03 423.43 l S +49.00 449.74 m 43.03 449.74 l S +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 315.44 Tm (0) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 338.96 Tm (20) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 365.26 Tm (40) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 391.57 Tm (60) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 417.87 Tm (80) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 441.40 Tm (100) Tj +ET +49.00 312.96 m +226.90 312.96 l +226.90 455.00 l +49.00 455.00 l +49.00 312.96 l +S +Q q 0.00 252.00 252.00 252.00 re W n +BT +0.000 0.000 0.000 rg +/F3 1 Tf 12.00 0.00 -0.00 12.00 118.28 475.19 Tm (State 1) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 124.34 267.54 Tm (Times) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 10.76 350.08 Tm [(Pre) 30 (v) 25 (alence \(%\))] TJ +ET +Q q 49.00 312.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[ 3.00 5.00] 0 d +1 J +1 j +10.00 M +55.59 449.74 m +57.26 442.00 l +58.92 434.72 l +60.58 427.86 l +62.25 421.41 l +63.91 415.34 l +65.58 409.63 l +67.24 404.25 l +68.90 399.19 l +70.57 393.13 l +72.23 386.01 l +73.89 379.57 l +75.56 373.75 l +77.22 368.47 l +78.89 363.70 l +80.55 359.38 l +82.21 355.47 l +83.88 351.93 l +85.54 350.27 l +87.20 349.19 l +88.87 348.15 l +90.53 347.14 l +92.20 346.16 l +93.86 345.22 l +95.52 344.31 l +97.19 343.43 l +98.85 342.55 l +100.52 341.21 l +102.18 339.95 l +103.84 338.76 l +105.51 337.63 l +107.17 336.57 l +108.83 335.56 l +110.50 334.61 l +112.16 333.71 l +113.83 332.86 l +115.49 332.06 l +117.15 331.30 l +118.82 330.58 l +120.48 329.90 l +122.15 329.26 l +123.81 328.66 l +125.47 328.08 l +127.14 327.54 l +128.80 327.03 l +130.46 326.55 l +132.13 326.09 l +133.79 325.66 l +135.46 325.25 l +137.12 324.86 l +138.78 324.50 l +140.45 324.16 l +142.11 323.83 l +143.78 323.52 l +145.44 323.23 l +147.10 322.96 l +148.77 322.70 l +150.43 322.45 l +152.09 322.22 l +153.76 322.00 l +155.42 321.79 l +157.09 321.60 l +158.75 321.41 l +160.41 321.23 l +162.08 321.07 l +163.74 320.91 l +165.41 320.76 l +167.07 320.62 l +168.73 320.49 l +170.40 320.37 l +172.06 320.25 l +173.72 320.14 l +175.39 320.03 l +177.05 319.93 l +178.72 319.84 l +180.38 319.75 l +182.04 319.67 l +183.71 319.59 l +185.37 319.51 l +187.04 319.44 l +188.70 319.37 l +190.36 319.31 l +192.03 319.25 l +193.69 319.19 l +195.35 319.14 l +197.02 319.09 l +198.68 319.04 l +200.35 319.00 l +202.01 318.95 l +203.67 318.91 l +205.34 318.87 l +207.00 318.84 l +208.67 318.80 l +210.33 318.77 l +211.99 318.74 l +213.66 318.71 l +215.32 318.69 l +216.98 318.66 l +218.65 318.64 l +220.31 318.61 l +S +Q q 301.00 312.96 177.90 142.04 re W n +Q q 301.00 312.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +307.59 318.22 m +309.26 329.18 l +310.92 337.80 l +312.58 339.84 l +314.25 338.82 l +315.91 343.98 l +317.58 348.66 l +319.24 348.57 l +320.90 350.81 l +322.57 352.53 l +324.23 355.63 l +325.89 352.83 l +327.56 354.19 l +329.22 348.75 l +330.89 343.79 l +332.55 351.10 l +334.21 349.23 l +335.88 349.88 l +337.54 353.29 l +339.20 355.04 l +340.87 355.21 l +342.53 355.21 l +344.20 347.44 l +345.86 345.12 l +347.52 346.61 l +349.19 342.57 l +350.85 341.01 l +352.52 340.42 l +354.18 340.71 l +355.84 344.52 l +357.51 343.10 l +359.17 338.03 l +360.83 338.31 l +362.50 335.13 l +364.16 329.99 l +365.83 331.75 l +367.49 331.96 l +369.15 326.57 l +370.82 326.57 l +372.48 328.49 l +374.15 328.18 l +375.81 328.18 l +377.47 326.19 l +379.14 328.33 l +380.80 326.57 l +382.46 322.46 l +384.13 322.46 l +385.79 322.53 l +387.46 322.60 l +389.12 324.68 l +390.78 324.79 l +392.45 324.68 l +394.11 322.53 l +395.78 322.39 l +397.44 322.33 l +399.10 322.26 l +400.77 322.20 l +402.43 324.29 l +404.09 324.19 l +405.76 324.19 l +407.42 324.19 l +409.09 322.20 l +410.75 320.27 l +412.41 320.24 l +414.08 320.27 l +415.74 320.27 l +417.41 320.24 l +419.07 320.24 l +420.73 320.27 l +422.40 318.22 l +424.06 318.22 l +425.72 318.22 l +427.39 318.22 l +429.05 320.30 l +430.72 320.30 l +432.38 318.22 l +434.04 318.22 l +435.71 318.22 l +437.37 318.22 l +439.04 318.22 l +440.70 318.22 l +442.36 318.22 l +444.03 318.22 l +445.69 318.22 l +447.35 318.22 l +449.02 318.22 l +450.68 318.22 l +452.35 318.22 l +454.01 318.22 l +455.67 318.22 l +457.34 318.22 l +459.00 318.22 l +460.67 318.22 l +462.33 318.22 l +463.99 318.22 l +465.66 318.22 l +467.32 318.22 l +468.98 318.22 l +470.65 318.22 l +472.31 318.22 l +S +Q q +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +307.39 312.96 m 451.91 312.96 l S +307.39 312.96 m 307.39 306.98 l S +336.29 312.96 m 336.29 306.98 l S +365.19 312.96 m 365.19 306.98 l S +394.10 312.96 m 394.10 306.98 l S +423.00 312.96 m 423.00 306.98 l S +451.91 312.96 m 451.91 306.98 l S +BT +0.000 0.000 0.000 rg +/F2 1 Tf 10.00 0.00 -0.00 10.00 304.61 291.44 Tm (0) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 330.73 291.44 Tm (10) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 359.63 291.44 Tm (20) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 388.54 291.44 Tm (30) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 417.44 291.44 Tm (40) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 446.35 291.44 Tm (50) Tj +ET +301.00 318.22 m 301.00 449.74 l S +301.00 318.22 m 295.03 318.22 l S +301.00 344.52 m 295.03 344.52 l S +301.00 370.82 m 295.03 370.82 l S +301.00 397.13 m 295.03 397.13 l S +301.00 423.43 m 295.03 423.43 l S +301.00 449.74 m 295.03 449.74 l S +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 315.44 Tm (0) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 338.96 Tm (20) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 365.26 Tm (40) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 391.57 Tm (60) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 417.87 Tm (80) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 441.40 Tm (100) Tj +ET +301.00 312.96 m +478.90 312.96 l +478.90 455.00 l +301.00 455.00 l +301.00 312.96 l +S +Q q 252.00 252.00 252.00 252.00 re W n +BT +0.000 0.000 0.000 rg +/F3 1 Tf 12.00 0.00 -0.00 12.00 370.28 475.19 Tm (State 2) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 376.34 267.54 Tm (Times) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 262.76 350.08 Tm [(Pre) 30 (v) 25 (alence \(%\))] TJ +ET +Q q 301.00 312.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[ 3.00 5.00] 0 d +1 J +1 j +10.00 M +307.59 318.22 m +309.26 325.56 l +310.92 331.75 l +312.58 336.92 l +314.25 341.20 l +315.91 344.70 l +317.58 347.51 l +319.24 349.73 l +320.90 351.42 l +322.57 352.95 l +324.23 354.02 l +325.89 354.31 l +327.56 353.99 l +329.22 353.21 l +330.89 352.09 l +332.55 350.73 l +334.21 349.21 l +335.88 347.59 l +337.54 346.75 l +339.20 346.17 l +340.87 345.59 l +342.53 345.01 l +344.20 344.43 l +345.86 343.85 l +347.52 343.27 l +349.19 342.70 l +350.85 342.10 l +352.52 341.17 l +354.18 340.26 l +355.84 339.37 l +357.51 338.49 l +359.17 337.64 l +360.83 336.81 l +362.50 336.00 l +364.16 335.22 l +365.83 334.47 l +367.49 333.74 l +369.15 333.03 l +370.82 332.35 l +372.48 331.69 l +374.15 331.06 l +375.81 330.46 l +377.47 329.88 l +379.14 329.32 l +380.80 328.78 l +382.46 328.27 l +384.13 327.78 l +385.79 327.31 l +387.46 326.86 l +389.12 326.43 l +390.78 326.02 l +392.45 325.63 l +394.11 325.26 l +395.78 324.91 l +397.44 324.57 l +399.10 324.24 l +400.77 323.94 l +402.43 323.64 l +404.09 323.37 l +405.76 323.10 l +407.42 322.85 l +409.09 322.61 l +410.75 322.38 l +412.41 322.16 l +414.08 321.96 l +415.74 321.76 l +417.41 321.58 l +419.07 321.40 l +420.73 321.23 l +422.40 321.07 l +424.06 320.92 l +425.72 320.78 l +427.39 320.64 l +429.05 320.52 l +430.72 320.39 l +432.38 320.28 l +434.04 320.17 l +435.71 320.06 l +437.37 319.97 l +439.04 319.87 l +440.70 319.78 l +442.36 319.70 l +444.03 319.62 l +445.69 319.55 l +447.35 319.47 l +449.02 319.41 l +450.68 319.34 l +452.35 319.28 l +454.01 319.22 l +455.67 319.17 l +457.34 319.12 l +459.00 319.07 l +460.67 319.02 l +462.33 318.98 l +463.99 318.94 l +465.66 318.90 l +467.32 318.86 l +468.98 318.83 l +470.65 318.79 l +472.31 318.76 l +S +Q q 49.00 60.96 177.90 142.04 re W n +Q q 49.00 60.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +55.59 66.22 m +57.26 66.22 l +58.92 66.22 l +60.58 66.22 l +62.25 67.80 l +63.91 67.57 l +65.58 73.52 l +67.24 72.54 l +68.90 74.36 l +70.57 75.37 l +72.23 75.29 l +73.89 78.91 l +75.56 83.08 l +77.22 83.83 l +78.89 86.92 l +80.55 81.48 l +82.21 81.11 l +83.88 82.05 l +85.54 77.49 l +87.20 80.68 l +88.87 79.92 l +90.53 79.92 l +92.20 82.29 l +93.86 82.66 l +95.52 81.16 l +97.19 77.58 l +98.85 80.24 l +100.52 81.59 l +102.18 80.06 l +103.84 80.24 l +105.51 75.10 l +107.17 75.22 l +108.83 73.52 l +110.50 73.73 l +112.16 76.03 l +113.83 73.95 l +115.49 72.10 l +117.15 76.65 l +118.82 74.57 l +120.48 72.38 l +122.15 74.19 l +123.81 74.19 l +125.47 74.19 l +127.14 70.26 l +128.80 68.30 l +130.46 70.46 l +132.13 68.34 l +133.79 68.37 l +135.46 66.22 l +137.12 66.22 l +138.78 66.22 l +140.45 66.22 l +142.11 68.37 l +143.78 66.22 l +145.44 66.22 l +147.10 66.22 l +148.77 66.22 l +150.43 66.22 l +152.09 68.21 l +153.76 68.21 l +155.42 68.21 l +157.09 70.20 l +158.75 68.27 l +160.41 70.26 l +162.08 70.33 l +163.74 70.33 l +165.41 70.26 l +167.07 70.26 l +168.73 70.33 l +170.40 70.39 l +172.06 70.39 l +173.72 70.39 l +175.39 70.46 l +177.05 70.39 l +178.72 70.39 l +180.38 70.46 l +182.04 70.46 l +183.71 68.34 l +185.37 66.22 l +187.04 66.22 l +188.70 66.22 l +190.36 68.34 l +192.03 68.34 l +193.69 68.30 l +195.35 66.22 l +197.02 66.22 l +198.68 66.22 l +200.35 66.22 l +202.01 66.22 l +203.67 66.22 l +205.34 66.22 l +207.00 66.22 l +208.67 66.22 l +210.33 66.22 l +211.99 66.22 l +213.66 66.22 l +215.32 66.22 l +216.98 66.22 l +218.65 66.22 l +220.31 66.22 l +S +Q q +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +55.39 60.96 m 199.91 60.96 l S +55.39 60.96 m 55.39 54.98 l S +84.29 60.96 m 84.29 54.98 l S +113.19 60.96 m 113.19 54.98 l S +142.10 60.96 m 142.10 54.98 l S +171.00 60.96 m 171.00 54.98 l S +199.91 60.96 m 199.91 54.98 l S +BT +0.000 0.000 0.000 rg +/F2 1 Tf 10.00 0.00 -0.00 10.00 52.61 39.44 Tm (0) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 78.73 39.44 Tm (10) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 107.63 39.44 Tm (20) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 136.54 39.44 Tm (30) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 165.44 39.44 Tm (40) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 194.35 39.44 Tm (50) Tj +ET +49.00 66.22 m 49.00 197.74 l S +49.00 66.22 m 43.03 66.22 l S +49.00 92.52 m 43.03 92.52 l S +49.00 118.82 m 43.03 118.82 l S +49.00 145.13 m 43.03 145.13 l S +49.00 171.43 m 43.03 171.43 l S +49.00 197.74 m 43.03 197.74 l S +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 63.44 Tm (0) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 86.96 Tm (20) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 113.26 Tm (40) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 139.57 Tm (60) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 165.87 Tm (80) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 34.66 189.40 Tm (100) Tj +ET +49.00 60.96 m +226.90 60.96 l +226.90 203.00 l +49.00 203.00 l +49.00 60.96 l +S +Q q 0.00 0.00 252.00 252.00 re W n +BT +0.000 0.000 0.000 rg +/F3 1 Tf 12.00 0.00 -0.00 12.00 118.28 223.19 Tm (State 3) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 124.34 15.54 Tm (Times) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 10.76 98.08 Tm [(Pre) 30 (v) 25 (alence \(%\))] TJ +ET +Q q 49.00 60.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[ 3.00 5.00] 0 d +1 J +1 j +10.00 M +55.59 66.22 m +57.26 66.59 l +58.92 67.59 l +60.58 69.03 l +62.25 70.78 l +63.91 72.72 l +65.58 74.75 l +67.24 76.81 l +68.90 78.83 l +70.57 81.31 l +72.23 84.20 l +73.89 86.69 l +75.56 88.74 l +77.22 90.35 l +78.89 91.53 l +80.55 92.31 l +82.21 92.73 l +83.88 92.83 l +85.54 90.46 l +87.20 87.78 l +88.87 85.53 l +90.53 83.64 l +92.20 82.05 l +93.86 80.70 l +95.52 79.55 l +97.19 78.57 l +98.85 77.70 l +100.52 76.56 l +102.18 75.65 l +103.84 74.91 l +105.51 74.30 l +107.17 73.77 l +108.83 73.32 l +110.50 72.93 l +112.16 72.57 l +113.83 72.24 l +115.49 71.94 l +117.15 71.66 l +118.82 71.40 l +120.48 71.16 l +122.15 70.92 l +123.81 70.70 l +125.47 70.49 l +127.14 70.29 l +128.80 70.09 l +130.46 69.91 l +132.13 69.73 l +133.79 69.56 l +135.46 69.40 l +137.12 69.24 l +138.78 69.10 l +140.45 68.95 l +142.11 68.82 l +143.78 68.69 l +145.44 68.57 l +147.10 68.45 l +148.77 68.34 l +150.43 68.23 l +152.09 68.13 l +153.76 68.03 l +155.42 67.94 l +157.09 67.85 l +158.75 67.77 l +160.41 67.69 l +162.08 67.61 l +163.74 67.54 l +165.41 67.47 l +167.07 67.41 l +168.73 67.34 l +170.40 67.28 l +172.06 67.23 l +173.72 67.18 l +175.39 67.12 l +177.05 67.08 l +178.72 67.03 l +180.38 66.99 l +182.04 66.95 l +183.71 66.91 l +185.37 66.87 l +187.04 66.84 l +188.70 66.80 l +190.36 66.77 l +192.03 66.74 l +193.69 66.72 l +195.35 66.69 l +197.02 66.66 l +198.68 66.64 l +200.35 66.62 l +202.01 66.60 l +203.67 66.57 l +205.34 66.56 l +207.00 66.54 l +208.67 66.52 l +210.33 66.50 l +211.99 66.49 l +213.66 66.47 l +215.32 66.46 l +216.98 66.45 l +218.65 66.43 l +220.31 66.42 l +S +Q q 301.00 60.96 177.90 142.04 re W n +Q q 301.00 60.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +307.59 66.22 m +309.26 66.22 l +310.92 66.22 l +312.58 66.22 l +314.25 67.80 l +315.91 68.93 l +317.58 68.65 l +319.24 70.01 l +320.90 69.71 l +322.57 71.93 l +324.23 74.15 l +325.89 75.45 l +327.56 76.33 l +329.22 80.31 l +330.89 85.70 l +332.55 89.70 l +334.21 94.75 l +335.88 95.44 l +337.54 100.04 l +339.20 101.73 l +340.87 104.58 l +342.53 104.58 l +344.20 112.98 l +345.86 118.53 l +347.52 120.02 l +349.19 131.16 l +350.85 136.36 l +352.52 134.54 l +354.18 137.17 l +355.84 138.11 l +357.51 146.19 l +359.17 150.89 l +360.83 152.07 l +362.50 156.40 l +364.16 160.44 l +365.83 160.99 l +367.49 164.37 l +369.15 172.68 l +370.82 174.77 l +372.48 175.13 l +374.15 173.82 l +375.81 173.82 l +377.47 175.82 l +379.14 179.53 l +380.80 183.12 l +382.46 185.01 l +384.13 185.01 l +385.79 186.96 l +387.46 188.97 l +389.12 186.96 l +390.78 188.97 l +392.45 186.96 l +394.11 189.11 l +395.78 187.30 l +397.44 185.41 l +399.10 183.57 l +400.77 181.79 l +402.43 183.57 l +404.09 181.79 l +405.76 181.79 l +407.42 181.79 l +409.09 181.79 l +410.75 185.41 l +412.41 183.57 l +414.08 185.41 l +415.74 185.41 l +417.41 183.57 l +419.07 185.60 l +420.73 187.46 l +422.40 189.39 l +424.06 189.39 l +425.72 189.39 l +427.39 191.37 l +429.05 189.39 l +430.72 189.39 l +432.38 191.37 l +434.04 191.37 l +435.71 193.49 l +437.37 195.61 l +439.04 195.61 l +440.70 195.61 l +442.36 195.61 l +444.03 195.61 l +445.69 193.56 l +447.35 195.65 l +449.02 195.65 l +450.68 195.65 l +452.35 195.65 l +454.01 195.65 l +455.67 195.65 l +457.34 195.65 l +459.00 195.65 l +460.67 195.65 l +462.33 195.65 l +463.99 195.65 l +465.66 195.65 l +467.32 195.65 l +468.98 195.65 l +470.65 195.65 l +472.31 197.74 l +S +Q q +0.000 0.000 0.000 RG +0.75 w +[] 0 d +1 J +1 j +10.00 M +307.39 60.96 m 451.91 60.96 l S +307.39 60.96 m 307.39 54.98 l S +336.29 60.96 m 336.29 54.98 l S +365.19 60.96 m 365.19 54.98 l S +394.10 60.96 m 394.10 54.98 l S +423.00 60.96 m 423.00 54.98 l S +451.91 60.96 m 451.91 54.98 l S +BT +0.000 0.000 0.000 rg +/F2 1 Tf 10.00 0.00 -0.00 10.00 304.61 39.44 Tm (0) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 330.73 39.44 Tm (10) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 359.63 39.44 Tm (20) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 388.54 39.44 Tm (30) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 417.44 39.44 Tm (40) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 446.35 39.44 Tm (50) Tj +ET +301.00 66.22 m 301.00 197.74 l S +301.00 66.22 m 295.03 66.22 l S +301.00 92.52 m 295.03 92.52 l S +301.00 118.82 m 295.03 118.82 l S +301.00 145.13 m 295.03 145.13 l S +301.00 171.43 m 295.03 171.43 l S +301.00 197.74 m 295.03 197.74 l S +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 63.44 Tm (0) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 86.96 Tm (20) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 113.26 Tm (40) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 139.57 Tm (60) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 165.87 Tm (80) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 286.66 189.40 Tm (100) Tj +ET +301.00 60.96 m +478.90 60.96 l +478.90 203.00 l +301.00 203.00 l +301.00 60.96 l +S +Q q 252.00 0.00 252.00 252.00 re W n +BT +0.000 0.000 0.000 rg +/F3 1 Tf 12.00 0.00 -0.00 12.00 370.28 223.19 Tm (State 4) Tj +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 376.34 15.54 Tm (Times) Tj +ET +BT +/F2 1 Tf 0.00 10.00 -10.00 0.00 262.76 98.08 Tm [(Pre) 30 (v) 25 (alence \(%\))] TJ +ET +Q q 301.00 60.96 177.90 142.04 re W n +0.000 0.000 0.000 RG +0.75 w +[ 3.00 5.00] 0 d +1 J +1 j +10.00 M +307.59 66.22 m +309.26 66.23 l +310.92 66.33 l +312.58 66.57 l +314.25 66.99 l +315.91 67.63 l +317.58 68.50 l +319.24 69.60 l +320.90 70.94 l +322.57 73.00 l +324.23 76.15 l +325.89 79.82 l +327.56 83.91 l +329.22 88.36 l +330.89 93.07 l +332.55 97.96 l +334.21 102.97 l +335.88 108.03 l +337.54 112.91 l +339.20 117.24 l +340.87 121.11 l +342.53 124.59 l +344.20 127.74 l +345.86 130.62 l +347.52 133.25 l +349.19 135.68 l +350.85 138.04 l +352.52 141.44 l +354.18 144.52 l +355.84 147.35 l +357.51 149.96 l +359.17 152.40 l +360.83 154.69 l +362.50 156.84 l +364.16 158.88 l +365.83 160.81 l +367.49 162.65 l +369.15 164.39 l +370.82 166.05 l +372.48 167.63 l +374.15 169.14 l +375.81 170.57 l +377.47 171.94 l +379.14 173.24 l +380.80 174.48 l +382.46 175.66 l +384.13 176.78 l +385.79 177.85 l +387.46 178.87 l +389.12 179.84 l +390.78 180.76 l +392.45 181.64 l +394.11 182.47 l +395.78 183.27 l +397.44 184.02 l +399.10 184.73 l +400.77 185.41 l +402.43 186.06 l +404.09 186.67 l +405.76 187.25 l +407.42 187.81 l +409.09 188.33 l +410.75 188.83 l +412.41 189.30 l +414.08 189.75 l +415.74 190.17 l +417.41 190.57 l +419.07 190.95 l +420.73 191.31 l +422.40 191.66 l +424.06 191.98 l +425.72 192.29 l +427.39 192.58 l +429.05 192.86 l +430.72 193.12 l +432.38 193.37 l +434.04 193.60 l +435.71 193.82 l +437.37 194.03 l +439.04 194.23 l +440.70 194.42 l +442.36 194.60 l +444.03 194.77 l +445.69 194.93 l +447.35 195.08 l +449.02 195.23 l +450.68 195.36 l +452.35 195.49 l +454.01 195.61 l +455.67 195.73 l +457.34 195.84 l +459.00 195.94 l +460.67 196.04 l +462.33 196.13 l +463.99 196.22 l +465.66 196.30 l +467.32 196.38 l +468.98 196.45 l +470.65 196.52 l +472.31 196.59 l +S +0.75 w +[] 0 d +373.36 118.82 83.74 -35.86 re S +382.32 106.87 m 400.25 106.87 l S +0.75 w +[ 3.00 5.00] 0 d +382.32 94.92 m 400.25 94.92 l S +BT +0.000 0.000 0.000 rg +/F2 1 Tf 10.00 0.00 -0.00 10.00 409.21 103.28 Tm [(Obser) -30 (v) 25 (ed)] TJ +ET +BT +/F2 1 Tf 10.00 0.00 -0.00 10.00 409.21 91.33 Tm (Expected) Tj +ET +Q +endstream +endobj +7 0 obj +20215 +endobj +3 0 obj +<< +/Type /Pages +/Kids [ +5 0 R +] +/Count 1 +/MediaBox [0 0 504 504] +>> +endobj +4 0 obj +<< +/ProcSet [/PDF /Text] +/Font <</F2 9 0 R /F3 10 0 R >> +/ExtGState << >> +>> +endobj +8 0 obj +<< +/Type /Encoding +/BaseEncoding /WinAnsiEncoding +/Differences [ 45/minus 96/quoteleft +144/dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent +/dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron /space] +>> +endobj +9 0 obj << +/Type /Font +/Subtype /Type1 +/Name /F2 +/BaseFont /Helvetica +/Encoding 8 0 R +>> endobj +10 0 obj << +/Type /Font +/Subtype /Type1 +/Name /F3 +/BaseFont /Helvetica-Bold +/Encoding 8 0 R +>> endobj +xref +0 11 +0000000000 65535 f +0000000021 00000 n +0000000163 00000 n +0000020581 00000 n +0000020664 00000 n +0000000212 00000 n +0000000292 00000 n +0000020560 00000 n +0000020756 00000 n +0000021013 00000 n +0000021109 00000 n +trailer +<< +/Size 11 +/Info 1 0 R +/Root 2 0 R +>> +startxref +21211 +%%EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-06-12 22:39:21
|
Revision: 229 http://rmol.svn.sourceforge.net/rmol/?rev=229&view=rev Author: denis_arnaud Date: 2009-06-12 22:38:33 +0000 (Fri, 12 Jun 2009) Log Message: ----------- [R-msm] Integrated the latest upstream version (0.9.1) of R-msm. Modified Paths: -------------- trunk/R/R-msm.spec trunk/R/msm/ChangeLog trunk/R/msm/DESCRIPTION trunk/R/msm/R/boot.R trunk/R/msm/R/msm.R trunk/R/msm/R/outputs.R trunk/R/msm/R/pearson.R trunk/R/msm/inst/NEWS trunk/R/msm/inst/doc/msm-manual.pdf trunk/R/msm/man/ematrix.msm.Rd trunk/R/msm/man/hmm-dists.Rd trunk/R/msm/man/lrtest.msm.Rd trunk/R/msm/man/msm.Rd trunk/R/msm/man/pearson.msm.Rd trunk/R/msm/man/plot.survfit.msm.Rd trunk/R/msm/man/pmatrix.msm.Rd trunk/R/msm/man/totlos.msm.Rd trunk/R/msm/src/doc/msm-manual.Rnw trunk/R/msm/src/lik.c trunk/R/msm/src/msm.h trunk/R/msm/src/pijt.c trunk/R/msm/tests/deriv.R trunk/R/msm/tests/pci.R trunk/R/msm/tests/simple.R Modified: trunk/R/R-msm.spec =================================================================== --- trunk/R/R-msm.spec 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/R-msm.spec 2009-06-12 22:38:33 UTC (rev 229) @@ -2,10 +2,9 @@ %global packrel 1 Name: R-%{packname} -Version: 0.8.2 -Release: 2%{?dist} +Version: 0.9.1 +Release: 1%{?dist} Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}.tar.gz -Source1: README_License_msm License: GPLv2+ URL: http://cran.r-project.org/web/packages/msm/ Group: Applications/Engineering @@ -44,9 +43,6 @@ mkdir -p $RPM_BUILD_ROOT%{_libdir}/R/library %{_bindir}/R CMD INSTALL -l $RPM_BUILD_ROOT%{_libdir}/R/library %{packname} -# Temporary fix for the license issue (https://bugzilla.redhat.com/show_bug.cgi?id=498845#c1) -install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_libdir}/R/library/%{packname} - # Remove the temporary object files test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) @@ -69,7 +65,6 @@ %files %defattr(-, root, root, -) %dir %{_libdir}/R/library/%{packname} -%doc %{_libdir}/R/library/%{packname}/README_License_msm %doc %{_libdir}/R/library/%{packname}/latex %doc %{_libdir}/R/library/%{packname}/data %doc %{_libdir}/R/library/%{packname}/doc @@ -87,6 +82,9 @@ %{_libdir}/R/library/%{packname}/libs/%{packname}.so %changelog +* Fri Jun 12 2009 Denis Arnaud <den...@m4...> 0.9.1-1 +- Integrated the new upstream (0.9.1) version + * Sat Jun 06 2009 Denis Arnaud <den...@m4...> 0.8.2-2 - Altered the license so as to reflect upstream, after clarification with them Modified: trunk/R/msm/ChangeLog =================================================================== --- trunk/R/msm/ChangeLog 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/ChangeLog 2009-06-12 22:38:33 UTC (rev 229) @@ -1,3 +1,69 @@ +2009-06-12 Chris Jackson <chr...@mr...> + + * tests/simple.R: Removed a couple of tests which fail due to + floating point fuzz on Fedora/Red Hat PPC Linux. + + * DESCRIPTION: Version 0.9.1 released. + +2009-06-09 Chris Jackson <chr...@mr...> + + * R/pearson.R: Covariate grouping fixed to 1 for pci models with + no other covariates, as the covariate group is equivalent to the + time group. + + * DESCRIPTION: Version 0.9 released. + +2009-06-05 Chris Jackson <chr...@mr...> + + * DESCRIPTION: Licence altered from GPLv2 to GPL v2 or later. + Licence text removed from src/pijt.c. + + * R/msm.R(msm): Default changed to use.deriv=TRUE. + + * R/msm.R(msm.pci): Don't impute observations for pci models at + times when there is already an observation. This fixes "times not + ordered" errors when bootstrap resampling for Pearson test. + +2009-04-29 Chris Jackson <chr...@mr...> + + * R/outputs.R(factorcov2numeric.msm): Extractor functions now set + unspecified covariate values in covariate lists to 0, and ignore + unknown covariates. + + * R/outputs.R(factorcov2numeric.msm): All extractor functions can + now accept covariate values as numeric contrasts as well as factor + levels. + + * R/outputs.R(plot.survfit.msm): Call to survfit fixed for + compatibility with R version 2.9.0. + + * R/outputs.R(pmatrix.msm): Adapted to automatically handle "pci" + models with piecewise constant intensities, with new "t1" argument + representing start time. New internal function + "msm.fill.pci.covs" to enable time-constant covariates to be + passed through this facility properly. Arguments of all calls to + pmatrix.msm changed. As a result, functions which call + pmatrix.msm (prevalence.msm, expected.msm, totlos.msm, + plot.survfit.msm) now handle time-inhomogeneous models specified + using "pci". + + * R/msm.R(msm.pci): Bug fix - covmeans calculated wrong in pci + models with other covariates, leading to error in qmatrix.msm for + covariates=0. + +2009-04-29 Chris Jackson <chr...@mr...> + + * src/lik.c: Bug fix - score residuals were being calculated + wrongly for models with covariates. + +2009-04-24 Chris Jackson <chr...@mr...> + + * R/pearson.R: Fixed "second argument must be a list" bug. + + * R/outputs.R: Order of effects in hazard.msm and odds.msm changed + to read across rows of the transition/misclassification + matrix. This is for consistency with, e.g. fixedpars. + 2009-04-08 Chris Jackson <chr...@mr...> * man/msm.Rd: Documentation for qconstraint clarified. Modified: trunk/R/msm/DESCRIPTION =================================================================== --- trunk/R/msm/DESCRIPTION 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/DESCRIPTION 2009-06-12 22:38:33 UTC (rev 229) @@ -1,18 +1,15 @@ -Package: msm -Version: 0.8.2 -Date: 2009-04-08 -Title: Multi-state Markov and hidden Markov models in continuous time -Author: Christopher Jackson <chr...@mr...> -Maintainer: Christopher Jackson <chr...@mr...> -Description: Functions for fitting general continuous-time Markov and - hidden Markov multi-state models to longitudinal data. Both - Markov transition rates and the hidden Markov output process - can be modelled in terms of covariates. A variety of - observation schemes are supported, including processes observed - at arbitrary times, completely-observed processes, and censored - states. -License: GPL-2 -Imports: survival,mvtnorm -Packaged: 2009-04-08 19:03:15 UTC; chris -Repository: CRAN -Date/Publication: 2009-04-14 17:32:26 +Package: msm +Version: 0.9.1 +Date: 2009-06-12 +Title: Multi-state Markov and hidden Markov models in continuous time +Author: Christopher Jackson <chr...@mr...> +Maintainer: Christopher Jackson <chr...@mr...> +Description: Functions for fitting general continuous-time Markov and hidden + Markov multi-state models to longitudinal data. Both Markov + transition rates and the hidden Markov output process can be modelled + in terms of covariates. A variety of observation schemes are + supported, including processes observed at arbitrary times, + completely-observed processes, and censored states. +License: GPL version 2 or later +Imports: survival,mvtnorm +Packaged: 2009-06-12 10:22:54 UTC; chris Modified: trunk/R/msm/R/boot.R =================================================================== --- trunk/R/msm/R/boot.R 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/R/boot.R 2009-06-12 22:38:33 UTC (rev 229) @@ -112,8 +112,8 @@ c(quantile(q.vec, c(0.5 - cl/2, 0.5 + cl/2)), sd(q.vec)) } -pmatrix.ci.msm <- function(x, t, covariates="mean", cl=0.95, B=1000) { - p.list <- boot.msm(x, function(x)pmatrix.msm(x=x, t=t, covariates=covariates,ci="none"), B) +pmatrix.ci.msm <- function(x, t, t1, covariates="mean", cl=0.95, B=1000) { + p.list <- boot.msm(x, function(x)pmatrix.msm(x=x, t=t, t1=t1, covariates=covariates,ci="none"), B) p.array <- array(unlist(p.list), dim=c(dim(p.list[[1]]), length(p.list))) p.ci <- apply(p.array, c(1,2), function(x)(quantile(x, c(0.5 - cl/2, 0.5 + cl/2)))) aperm(p.ci, c(2,3,1)) @@ -203,8 +203,8 @@ c(quantile(q.vec, c(0.5 - cl/2, 0.5 + cl/2)), sd(q.vec)) } -pmatrix.normci.msm <- function(x, t, covariates="mean", cl=0.95, B=1000) { - p.list <- normboot.msm(x, function(x)pmatrix.msm(x=x, t=t, covariates=covariates, ci="none"), B) +pmatrix.normci.msm <- function(x, t, t1, covariates="mean", cl=0.95, B=1000) { + p.list <- normboot.msm(x, function(x)pmatrix.msm(x=x, t=t, t1=t1, covariates=covariates, ci="none"), B) p.array <- array(unlist(p.list), dim=c(dim(p.list[[1]]), length(p.list))) p.ci <- apply(p.array, c(1,2), function(x)(quantile(x, c(0.5 - cl/2, 0.5 + cl/2)))) aperm(p.ci, c(2,3,1)) Modified: trunk/R/msm/R/msm.R =================================================================== --- trunk/R/msm/R/msm.R 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/R/msm.R 2009-06-12 22:38:33 UTC (rev 229) @@ -36,7 +36,7 @@ center = TRUE, # center covariates at their means opt.method = c("optim","nlm"), hessian = TRUE, - use.deriv = FALSE, + use.deriv = TRUE, analyticp = TRUE, ... # options to optim or nlm ) @@ -296,6 +296,7 @@ ecmodel = ecmodel, hmodel = hmodel, cmodel = cmodel, + pci = pci, paramdata=p ) attr(msmobject, "fixed") <- p$fixed @@ -1194,7 +1195,8 @@ as.integer(qmodel$npars), as.integer(qmodel$ndpars), as.integer(qcmodel$ndpars), - as.integer(msmdata$nobs), + as.integer(msmdata$nobs), # number of aggregated observations + as.integer(msmdata$n), # number of observations as.integer(msmdata$npts), # HMM only as.integer(rep(qcmodel$ncovs, qmodel$npars)), @@ -1426,6 +1428,16 @@ maxtime <- tapply(old$time, old$subject, max)[as.character(unique(old$subject))] nobspt <- as.numeric(table(new$subject)[as.character(unique(new$subject))]) new <- new[new$time >= rep(mintime, nobspt) & new$time <= rep(maxtime, nobspt), ] + + ## drop imputed observations at times when there was already an observation + ## assumes there wasn't already duplicated obs times + prevsubj <- c(NA,new$subject[1:(nrow(new)-1)]); nextsubj <- c(new$subject[2:nrow(new)], NA) + prevtime <- c(NA,new$time[1:(nrow(new)-1)]); nexttime <- c(new$time[2:nrow(new)], NA) + prevstate <- c(NA,new$state[1:(nrow(new)-1)]); nextstate <- c(new$state[2:nrow(new)], NA) + new <- new[!((new$subject==prevsubj & new$time==prevtime & new$state==label & prevstate!=label) | + (new$subject==nextsubj & new$time==nexttime & new$state==label & nextstate!=label)) + ,] + ## Carry last value forward for other covariates if (dat$ncovs > 0) { eind <- which(is.na(new$covmat[,1])) @@ -1467,9 +1479,8 @@ assign(tcovlabel, tcov) mm <- model.matrix(as.formula(paste("~", tcovlabel)))[,-1,drop=FALSE] new$covmat <- cbind(new$covmat, mm) - new$covmat.orig <- cbind(new$covmat.orig, timeperiod=tcov) - covmeans <- colMeans(new$covmat) - if (center) new$covmat <- sweep(new$covmat, 2, covmeans) + new$covmat.orig <- if(is.null(new$covmat.orig)) data.frame(timeperiod=tcov) else cbind(new$covmat.orig, timeperiod=tcov) + if (center) new$covmat <- sweep(new$covmat, 2, colMeans(new$covmat)) ## new censoring model cmodel$ncens <- cmodel$ncens + 1 @@ -1484,7 +1495,7 @@ new$covlabels.orig <- c(dat$covlabels.orig, tcovlabel) new$covdata$covlabels <- c(dat$covdata$covlabels, colnames(mm)) new$covdata$ncovs <- dat$covdata$ncovs + ntcut - new$covdata$covmeans <- c(dat$covdata$covmeans, covmeans) + new$covdata$covmeans <- c(dat$covdata$covmeans, colMeans(mm)) new$covdata$covfactor <- c(dat$covdata$covfactor, timeperiod=TRUE) new$covdata$covfactorlevels <- c(dat$covdata$covfactorlevels, list(timeperiod=levels(tcov))) new$covdata$covlabels.orig <- c(dat$covdata$covlabels.orig, tcovlabel) Modified: trunk/R/msm/R/outputs.R =================================================================== --- trunk/R/msm/R/outputs.R 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/R/outputs.R 2009-06-12 22:38:33 UTC (rev 229) @@ -117,14 +117,14 @@ pr <- numeric() cols <- rainbow(length(from)) for (t in times) - pr <- c(pr, pmatrix.msm(x, t, covariates)[from[1], to]) + pr <- c(pr, pmatrix.msm(x, t, times[1], covariates)[from[1], to]) plot(times, 1 - pr, type="l", xlab=xlab, ylab=ylab, lwd=lwd, ylim=c(0,1), lty = 1, col=cols[1],...) lt <- 2 for (st in from[-1]){ pr <- numeric() for (t in times) - pr <- c(pr, pmatrix.msm(x, t, covariates)[st, to]) + pr <- c(pr, pmatrix.msm(x, t, times[1], covariates)[st, to]) lines(times, 1 - pr, type="l", lty = lt, lwd=lwd, col=cols[lt],...) lt <- lt+1 } @@ -158,7 +158,7 @@ mintime = if(any(x[,"state"]>=i)) min(x[x[,"state"] >= i, "time"]) else max(x[,"time"])) } ))) # slow - lines(survfit(Surv(st$mintime,st$anystate)),col=cols[i-1],lty=i-1, lwd=lwd,...) + lines(survfit(Surv(st$mintime,st$anystate) ~ 1),col=cols[i-1],lty=i-1, lwd=lwd,...) } timediff <- (rg[2] - rg[1]) / 50 if (!is.numeric(legend.pos) || length(legend.pos) != 2) @@ -242,17 +242,24 @@ ### contrasts. For example, for a categorical covariate "smoke" with ### three levels "NON","CURRENT","EX", with baseline level "NON", ### convert list(smoke="CURRENT") to list(smokeCURRENT=1, smokeEX=0) +### Any unspecified covariate values are set to zero. +### Any unknown covariates are dropped with a warning. +### covlabels includes interactions + factorcov2numeric.msm <- function(covariates, x, intmisc="intens") { covdata <- if (intmisc=="intens") x$data$covdata else x$data$misccovdata covnames <- names(covdata$covfactor) - if (length(covariates) != length(covnames)) - stop(paste("Supplied", length(covariates), "covariate values, expected", length(covnames))) - if (any(! names(covariates) %in% covnames)) - stop("Covariates \"", paste(names(covariates)[which(!names(covariates) %in% covnames)], collapse=", "), "\" unknown") - if (is.null(names(covariates))) + if (is.null(names(covariates))) { + if (length(covariates)!=length(covnames)) stop("Expected covariate list of length ",length(covnames)) names(covariates) <- covnames - covariates <- covariates[covnames] + } + all.covnames <- union(x$data$covdata$covlabels,covnames) # including both factor and contrast names + miss.covs <- ! names(covariates) %in% all.covnames + if (any(miss.covs)){ + plural <- if(sum(miss.covs)>1) "s" else "" + warning("Covariate",plural," \"", paste(names(covariates)[which(!names(covariates) %in% all.covnames)], collapse=", "), "\" unknown, ignoring") + } cfac <- covariates[names(covariates) %in% covnames[which(covdata$covfactor)]] cnum <- covariates[! names(covariates) %in% covnames[which(covdata$covfactor)]] cfac.new <- list() @@ -265,7 +272,11 @@ cfac.i <- as.list(cfac.i[-1]) cfac.new <- c(cfac.new, cfac.i) } - covs.out <- c(cnum, cfac.new)[covdata$covlabels[setdiff(seq(along=covdata$covlabels), grep(":", covdata$covlabels))]] + covlabels.noint <- covdata$covlabels[setdiff(seq(along=covdata$covlabels), grep(":", covdata$covlabels))] + covs.out <- as.list(numeric(length(covlabels.noint))) + names(covs.out) <- covlabels.noint + covs.out[names(cnum)] <- cnum + covs.out[names(cfac.new)] <- cfac.new covs.out <- expand.interactions.msm(covs.out, covdata$covlabels) covs.out } @@ -343,14 +354,16 @@ covs.orig <- covariates # with factors as labels if (nc > 0) { if (!is.list(covariates)) { - if (covariates == 0 && x$center) + if (covariates == 0 && x$center) # if no centering, then can't end up in this block, as no need to adjust. {covariates <- list(); for (i in 1 : nc) covariates[[covlabels[i]]] <- 0} - else if (covariates == "mean" && !x$center) + else if (covariates == "mean" && !x$center) # if center, then can't end up in this block, as no need to adjust. {covariates <- list(); for (i in 1 : nc) covariates[[covlabels[i]]] <- covmeans[i]} else stop("covariates argument must be 0, \"mean\", or a list of values for each named covariate") } else { - covariates <- factorcov2numeric.msm(covariates, x, intmisc) # with factors as numeric contrasts + ## Check supplied list of covariate values, convert factors to numeric contrasts, expand interactions, set unknown values to zero. + ## Maybe merge above block of code with this? tidy up other calls e.g. qratio.se, qmatrix.diagse? + covariates <- factorcov2numeric.msm(covariates, x, intmisc) } if (intmisc=="intens"){ logest <- x$Qmatrices$logbaseline @@ -744,6 +757,7 @@ pmatrix.msm <- function(x, # fitted msm model t = 1, # time interval + t1 = 0, # start time for pci models covariates = "mean", # covariate values to calculate transition matrix for ci=c("none","normal","bootstrap"), # calculate a confidence interval # using either simulation from asymptotic normal dist of MLEs, or bootstrap @@ -752,15 +766,21 @@ ) { if (!is.numeric(t) || (t < 0)) stop("t must be a positive number") - q <- qmatrix.msm(x, covariates) - p <- MatrixExp(q$estimates, t) - colnames(p) <- rownames(p) <- rownames(q$estimates) - ci <- match.arg(ci) - p.ci <- switch(ci, - bootstrap = pmatrix.ci.msm(x=x, t=t, covariates=covariates, cl=cl, B=B), - normal = pmatrix.normci.msm(x=x, t=t, covariates=covariates, cl=cl, B=B), - none = NULL) - res <- if (ci=="none") p else list(estimates = p, L=p.ci[,,1], U=p.ci[,,2]) + if (is.null(x$pci)) { + q <- qmatrix.msm(x, covariates) + p <- MatrixExp(q$estimates, t) + colnames(p) <- rownames(p) <- rownames(q$estimates) + ci <- match.arg(ci) + p.ci <- switch(ci, + bootstrap = pmatrix.ci.msm(x=x, t=t, t1=t1, covariates=covariates, cl=cl, B=B), + normal = pmatrix.normci.msm(x=x, t=t, t1=t1, covariates=covariates, cl=cl, B=B), + none = NULL) + res <- if (ci=="none") p else list(estimates = p, L=p.ci[,,1], U=p.ci[,,2]) + } + else { + piecewise.covariates <- msm.fill.pci.covs(x, covariates) + res <- pmatrix.piecewise.msm(x, t1, t1 + t, x$pci, piecewise.covariates, ci, cl, B) + } class(res) <- "msm.est" res } @@ -778,6 +798,7 @@ B = 1000 # number of bootstrap replicates or normal simulations ) { + x$pci <- NULL # to avoid infinite recursion when calling pmatrix.msm ## Input checks if (t2 < t1) stop("Stop time t2 should be greater than or equal to start time t1") if (!is.numeric(times) || is.unsorted(times)) stop("times should be a vector of numbers in increasing order") @@ -804,21 +825,21 @@ ## Calculate accumulated pmatrix ## Three cases: ind1, ind2 in the same interval if (ind1 == ind2) { - P <- pmatrix.msm(x, t2 - t1, covariates[[ind1]]) + P <- pmatrix.msm(x, t = t2 - t1, covariates=covariates[[ind1]]) } ## ind1, ind2 in successive intervals else if (ind2 == ind1 + 1) { - P.start <- pmatrix.msm(x, times[ind1] - t1 , covariates[[ind1]]) - P.end <- pmatrix.msm(x, t2 - times[ind2-1], covariates[[ind2]]) + P.start <- pmatrix.msm(x, t = times[ind1] - t1 , covariates=covariates[[ind1]]) + P.end <- pmatrix.msm(x, t = t2 - times[ind2-1], covariates=covariates[[ind2]]) P <- P.start %*% P.end } ## ind1, ind2 separated by one or more whole intervals else { - P.start <- pmatrix.msm(x, times[ind1] - t1 , covariates[[ind1]]) - P.end <- pmatrix.msm(x, t2 - times[ind2-1], covariates[[ind2]]) + P.start <- pmatrix.msm(x, t = times[ind1] - t1, covariates=covariates[[ind1]]) + P.end <- pmatrix.msm(x, t = t2 - times[ind2-1], covariates=covariates[[ind2]]) P.middle <- diag(x$qmodel$nstates) for (i in (ind1+1):(ind2-1)) { - P.middle <- P.middle %*% pmatrix.msm(x, times[i] - times[i-1], covariates[[i]]) + P.middle <- P.middle %*% pmatrix.msm(x, t = times[i] - times[i-1], covariates=covariates[[i]]) } P <- P.start %*% P.middle %*% P.end } @@ -832,7 +853,50 @@ res } +### Make a list of covariate lists to supply to pmatrix.piecewise.msm for models with "pci" time-dependent intensities. +### One for each time period, with time constant covariates replicated. +### For use in model assessment functions +### Returns factor covariates as contrasts, not factor levels. +msm.fill.pci.covs <- function(x, covariates="mean"){ + nc <- x$qcmodel$ncovs + ## indices of covariates representing time periods + ti <- grep("timeperiod\\[([0-9]+|Inf),([0-9]+|Inf)\\)", x$qcmodel$covlabels) + ni <- setdiff(1:nc, ti) # indices of other covariates + covlist <- vector(nc, mode="list") + names(covlist) <- x$qcmodel$covlabels + if (!is.list(covariates)){ + if (covariates == 0){ + for (i in ni) covlist[[i]] <- 0 + } + else if (covariates == "mean"){ + for (i in ni) covlist[[i]] <- x$qcmodel$covmeans[i] + } + } + else { + ## supplied values of non-time covariates + covariates <- factorcov2numeric.msm(covariates, x, intmisc="intens") # convert any factors to numeric contrasts + for (i in names(covariates)) + if (length(grep("^timeperiod",i))==0) { + if (i %in% union(x$qcmodel$covlabels.orig,x$qcmodel$covlabels)) + covlist[[i]] <- covariates[[i]] + else warning("Covariate ",i," unknown") + } + } + for (i in ti) covlist[[i]] <- 0 + ## set contrasts for each successive time period to 1 + ncut <- length(x$pci) + covlistlist <- vector(ncut+1, mode="list") + names(covlistlist) <- x$data$covdata$covfactorlevels$timeperiod + covlistlist[[1]] <- covlist + for (i in seq(length=ncut)){ + covlistlist[[i+1]] <- covlist + covlistlist[[i+1]][[ti[i]]] <- 1 + } + covlistlist +} + + ### Extract the mean sojourn times for given covariate values sojourn.msm <- function(x, covariates = "mean", ci=c("delta","normal","bootstrap","none"), cl=0.95, B=1000) @@ -894,8 +958,6 @@ } ## Estimate total length of stay in a given state. -## TODO: non-homogeneous models, using pmatrix.piecewise.msm. -## currently fixes covariates at their values at the start of the interval to be forecasted. totlos.msm <- function(x, start=1, end=NULL, fromt=0, tot=Inf, covariates="mean", ci=c("none","normal","bootstrap"), # calculate a confidence interval @@ -923,7 +985,7 @@ f <- function(time) { y <- numeric(length(time)) for (i in seq(along=y)) - y[i] <- pmatrix.msm(x, time[i], covariates)[start,end[j]] + y[i] <- pmatrix.msm(x, time[i], covariates=covariates)[start,end[j]] y } totlos[j] <- integrate(f, fromt, tot, ...)$value @@ -1094,7 +1156,7 @@ for (j in start:length(times)) { pmat <- if (is.null(piecewise.times)) - pmatrix.msm(x, times[j] - timezero, covariates=covariates) + pmatrix.msm(x, t=times[j] - timezero, t1=timezero, covariates=covariates) else pmatrix.piecewise.msm(x, timezero, times[j], piecewise.times, piecewise.covariates) emat <- ematrix.msm(x, covariates=misccovariates)$estimates @@ -1113,7 +1175,7 @@ for (j in start:length(times)) { pmat <- if (is.null(piecewise.times)) - pmatrix.msm(x, times[j] - timezero, covariates=covariates) + pmatrix.msm(x, t=times[j] - timezero, t1=timezero, covariates=covariates) else pmatrix.piecewise.msm(x, timezero, times[j], piecewise.times, piecewise.covariates) expj <- risk[j] * initprobs %*% pmat @@ -1223,8 +1285,9 @@ timediff <- (rg[2] - rg[1]) / 50 times <- seq(rg[1], rg[2], timediff) pr <- lower <- upper <- numeric() + for (t in times) { - P <- pmatrix.msm(x, t, covariates, ci=ci, B=B) + P <- pmatrix.msm(x, t, t1=times[1], covariates=covariates, ci=ci, B=B) if (ci != "none") { pr <- c(pr, P$estimates[from, to]) lower <- c(lower, P$L[from, to]) @@ -1249,7 +1312,7 @@ c(anystate = as.numeric(any(x[,"state"]==to)), mintime = mintime) } ))) # slow - lines(survfit(Surv(st$mintime,st$anystate)),col="blue",lty=2, lwd=lwd,...) + lines(survfit(Surv(st$mintime,st$anystate) ~ 1),col="blue",lty=2, lwd=lwd,...) timediff <- (rg[2] - rg[1]) / 50 if (!is.numeric(legend.pos) || length(legend.pos) != 2) legend.pos <- c(max(x$data$time) - 25*timediff, 1) @@ -1272,17 +1335,17 @@ stop ("hazard.scale of length ", length(hazard.scale), ", expected ", x$qcmodel$ncovs) keep <- (x$qmodel$imatrix != 0) nst <- x$qmodel$nstates - keepvec <- as.vector(keep) - fromlabs <- rep(rownames(keep), nst) [keepvec] - tolabs <- rep(colnames(keep), rep(nst, nst)) [keepvec] + keepvec <- as.vector(t(keep)) + fromlabs <- rep(rownames(keep), each=nst) [keepvec] + tolabs <- rep(colnames(keep), nst) [keepvec] if (x$qcmodel$ncovs > 0) { haz.list <- list() if (x$foundse) { for (i in 1:x$qcmodel$ncovs) { cov <- x$qcmodel$covlabels[i] - haz.rat <- exp(hazard.scale[i]*x$Qmatrices[[cov]])[keepvec] - LCL <- exp(hazard.scale[i]*(x$Qmatrices[[cov]] - qnorm(1 - 0.5*(1 - cl))*x$QmatricesSE[[cov]]) )[keepvec] - UCL <- exp(hazard.scale[i]*(x$Qmatrices[[cov]] + qnorm(1 - 0.5*(1 - cl))*x$QmatricesSE[[cov]]) )[keepvec] + haz.rat <- t(exp(hazard.scale[i]*x$Qmatrices[[cov]]))[keepvec] + LCL <- t(exp(hazard.scale[i]*(x$Qmatrices[[cov]] - qnorm(1 - 0.5*(1 - cl))*x$QmatricesSE[[cov]]) ))[keepvec] + UCL <- t(exp(hazard.scale[i]*(x$Qmatrices[[cov]] + qnorm(1 - 0.5*(1 - cl))*x$QmatricesSE[[cov]]) ))[keepvec] haz.tab <- cbind(haz.rat, LCL, UCL) dimnames(haz.tab) <- list(paste(fromlabs, "-", tolabs), c("HR", "L", "U")) @@ -1292,7 +1355,7 @@ else { for (i in 1:x$qcmodel$ncovs) { cov <- x$qcmodel$covlabels[i] - haz.tab <- as.matrix(exp(hazard.scale[i]*x$Qmatrices[[cov]])[keepvec]) + haz.tab <- as.matrix(t(exp(hazard.scale[i]*x$Qmatrices[[cov]]))[keepvec]) dimnames(haz.tab) <- list(paste(fromlabs, "-", tolabs), "HR") haz.list[[cov]] <- haz.tab } @@ -1315,17 +1378,17 @@ stop ("odds.scale of length ", length(odds.scale), ", expected ", x$ecmodel$ncovs) keep <- (x$emodel$imatrix != 0) nst <- x$qmodel$nstates - keepvec <- as.vector(keep) - truelabs <- rep(rownames(keep), nst) [keepvec] - obslabs <- rep(colnames(keep), rep(nst, nst)) [keepvec] + keepvec <- as.vector(t(keep)) + truelabs <- rep(rownames(keep), each=nst) [keepvec] + obslabs <- rep(colnames(keep), nst) [keepvec] if (x$ecmodel$ncovs > 0) { odds.list <- list() if (x$foundse) { for (i in 1:x$ecmodel$ncovs) { cov <- x$ecmodel$covlabels[i] - odds.rat <- exp(odds.scale[i]*x$Ematrices[[cov]])[keepvec] - LCL <- exp(odds.scale[i]*(x$Ematrices[[cov]] - qnorm(1 - 0.5*(1 - cl))*x$EmatricesSE[[cov]]) )[keepvec] - UCL <- exp(odds.scale[i]*(x$Ematrices[[cov]] + qnorm(1 - 0.5*(1 - cl))*x$EmatricesSE[[cov]]) )[keepvec] + odds.rat <- t(exp(odds.scale[i]*x$Ematrices[[cov]]))[keepvec] + LCL <- t(exp(odds.scale[i]*(x$Ematrices[[cov]] - qnorm(1 - 0.5*(1 - cl))*x$EmatricesSE[[cov]]) ))[keepvec] + UCL <- t(exp(odds.scale[i]*(x$Ematrices[[cov]] + qnorm(1 - 0.5*(1 - cl))*x$EmatricesSE[[cov]]) ))[keepvec] odds.tab <- cbind(odds.rat, LCL, UCL) dimnames(odds.tab) <- list(paste("Obs", obslabs, "|", truelabs), c("OR", "L", "U")) @@ -1335,7 +1398,7 @@ else { for (i in 1:x$ecmodel$ncovs) { cov <- x$ecmodel$covlabels[i] - odds.tab <- as.matrix(exp(odds.scale[i]*x$Ematrices[[cov]])[keepvec]) + odds.tab <- as.matrix(t(exp(odds.scale[i]*x$Ematrices[[cov]]))[keepvec]) dimnames(odds.tab) <- list(paste("Obs", obslabs, "|", truelabs), "OR") odds.list[[cov]] <- odds.tab } @@ -1433,6 +1496,7 @@ as.integer(x$qmodel$ndpars), as.integer(x$qcmodel$ndpars), as.integer(x$data$nobs), + as.integer(x$data$n), as.integer(x$data$npts), # HMM only as.integer(rep(x$qcmodel$ncovs, x$qmodel$npars)), Modified: trunk/R/msm/R/pearson.R =================================================================== --- trunk/R/msm/R/pearson.R 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/R/pearson.R 2009-06-12 22:38:33 UTC (rev 229) @@ -1,5 +1,7 @@ ### Pearson-type goodness-of fit test (Aguirre-Hernandez and Farewell, 2002; Titman and Sharples, 2007) +### TODO for pci models, don't group by + pearson.msm <- function(x, transitions=NULL, timegroups=3, intervalgroups=3, covgroups=3, groups=NULL, boot=FALSE, B=500, next.obstime=NULL, # user-supplied next observation times, if known. @@ -19,7 +21,11 @@ if (!is.numeric(covgroups) || length(covgroups) != 1) stop ("expected \"covgroups\" to be a single number") if (!is.numeric(B) || length(B) != 1) stop ("expected \"B\" to be a single number") if (!is.numeric(N) || length(N) != 1) stop ("expected \"N\" to be a single number") - + + ## Use only one covariate group for pci models with no other covariates + if (!is.null(x$pci) && length(grep("timeperiod\\[([0-9]+|Inf),([0-9]+|Inf)\\)", x$qcmodel$covlabels)) == x$qcmodel$ncovs) + covgroups <- 1 + ## Label various constants nst <- x$qmodel$nstates exact.death <- any(dat$obstype == 3) @@ -97,10 +103,10 @@ ## Determine unique Q matrices determined by covariate combinations ncovs <- x$qcmodel$ncovs if (ncovs>0) { - uniq <- unique(od$cov[dat$covdata$whichcov.orig]) + uniq <- unique(as.data.frame(od$cov[,dat$covdata$whichcov.orig,drop=FALSE])) nouniq <- dim(uniq)[1] pastedu <- do.call("paste",uniq) - pastedc <- do.call("paste",od$cov[dat$covdata$whichcov.orig]) + pastedc <- do.call("paste",as.data.frame(od$cov[,dat$covdata$whichcov.orig,drop=FALSE])) qmatindex <- match(pastedc,pastedu) qmat <- array(0,dim=c(nst,nst,nouniq)) for (i in 1:nouniq) Modified: trunk/R/msm/inst/NEWS =================================================================== --- trunk/R/msm/inst/NEWS 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/inst/NEWS 2009-06-12 22:38:33 UTC (rev 229) @@ -3,8 +3,41 @@ USER-VISIBLE CHANGES (for detailed changes see ChangeLog in the source package) -------------------- +Version 0.9.1 (2009-06-12) +------------- -Version 0.8.2 (2008-04-08) +o Minor update to the test suite to allow build on Fedora / Red Hat + Linux. + + +Version 0.9 (2009-06-09) +----------- + +o Time-inhomogeneous models fitted with the "pci" argument to msm are + now fully supported in all output functions. + + pmatrix.msm can now compute transition probabilities over any given + time interval for time-inhomogeneous models fitted with "pci". A + new argument "t1" to pmatrix.msm specifies the starting time, while + "t" still specifies the interval length. + + All functions which call on pmatrix.msm, such as plot.msm, + plot.survfit.msm, prevalence.msm and totlos.msm, now account for + time-inhomogeneity in models fitted using "pci". + +o Extractor functions are now more tolerant. If a list of covariate + values is supplied, unknown covariates are ignored and covariates + with unspecified values are set to zero. Factor values can be + specified either by factor levels or by 0/1 contrasts. + +o Bug fix - score residuals were being calculated wrongly for models + with covariates. + +o Licence clarified as GPL-2 or later, to enable packaging of msm for + Fedora/Red Hat Linux. + + +Version 0.8.2 (2009-04-08) ------------- o Bug fix - extractor functions were not being calculated for models Modified: trunk/R/msm/inst/doc/msm-manual.pdf =================================================================== (Binary files differ) Modified: trunk/R/msm/man/ematrix.msm.Rd =================================================================== --- trunk/R/msm/man/ematrix.msm.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/ematrix.msm.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -60,7 +60,8 @@ \value{ A list with components: - \item{estimate}{Estimated misclassification probability matrix.} + \item{estimate}{Estimated misclassification probability matrix. The + rows correspond to true states, and columns observed states.} \item{SE}{Corresponding approximate standard errors.} \item{L}{Lower confidence limits.} \item{U}{Upper confidence limits.} Modified: trunk/R/msm/man/hmm-dists.Rd =================================================================== --- trunk/R/msm/man/hmm-dists.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/hmm-dists.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -135,7 +135,9 @@ \details{ See the PDF manual \file{msm-manual.pdf} in the \file{doc} subdirectory for algebraic definitions of all these distributions. - + New hidden Markov model response distributions can be added to + \pkg{msm} by following the instructions in Section 2.18.1. + Parameters which can be modelled in terms of covariates, on the scale of a link function, are as follows. Modified: trunk/R/msm/man/lrtest.msm.Rd =================================================================== --- trunk/R/msm/man/lrtest.msm.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/lrtest.msm.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -21,6 +21,10 @@ they are fitted to the same dataset. This may be a problem if there are missing values and R's default of 'na.action = na.omit' is used. + + The likelihood ratio statistic only has the indicated chi-squared + distribution if the models are nested. An alternative for comparing + non-nested models is Akaike's information criterion. } \seealso{\code{\link{logLik.msm}},\code{\link{msm}}} \keyword{models} Modified: trunk/R/msm/man/msm.Rd =================================================================== --- trunk/R/msm/man/msm.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/msm.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -19,7 +19,7 @@ est.initprobs=FALSE, initcovariates = NULL, initcovinits = NULL, death = FALSE, exacttimes = FALSE, censor=NULL, censor.states=NULL, pci=NULL, cl = 0.95, fixedpars = NULL, center=TRUE, - opt.method=c("optim","nlm"), hessian=TRUE, use.deriv=FALSE, + opt.method=c("optim","nlm"), hessian=TRUE, use.deriv=TRUE, analyticp=TRUE, ... ) } \arguments{ @@ -444,7 +444,8 @@ piecewise constant covariate is known to change, then censored states can be inserted in the data on those occasions. The covariate may represent time itself, or some other - time-dependent variable. + time-dependent variable. The \code{pci} option to msm can be used + to perform this trick automatically. } \item{censor.states}{ Modified: trunk/R/msm/man/pearson.msm.Rd =================================================================== --- trunk/R/msm/man/pearson.msm.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/pearson.msm.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -36,7 +36,7 @@ the process.} \item{intervalgroups}{Number of groups based on quantiles of the time interval between observations.} - \item{covgroups}{Number of groups based on quantiles of \eqn{sum_r + \item{covgroups}{Number of groups based on quantiles of \eqn{\sum_r q_{irr}}{sum_r q_{irr}}, where \eqn{q_{irr}} are the diagonal entries of the transition intensity matrix for the \emph{i}th transition. These are a function of the covariate effects and the covariate values at the @@ -46,10 +46,15 @@ Thus \code{covgroups} summarises the impact of covariates at each observation, by calculating the overall rate of progression through - states at that observation. + states at that observation. + + For time-inhomogeneous models specified using the \code{pci} + argument to \code{\link{msm}}, if the only covariate is the time + period, \code{covgroups} is set to 1, since \code{timegroups} + ensures that transitions are grouped by time. } \item{groups}{A vector of arbitrary groups in which to categorise each - observation in the data. This can be an integer vector or a factor. + transition. This can be an integer vector or a factor. This can be used to diagnose specific areas of poor fit. For example, the contingency table might be grouped by arbitrary combinations of covariates to detect types of individual for whom @@ -57,7 +62,11 @@ The length of \code{groups} should be \code{x$data$n}, the number of observations used in the model fit, which is the number of observations - in the original dataset with any missing values excluded.} + in the original dataset with any missing values excluded. The value + of \code{groups} at observation \eqn{i} is used to categorise the + transition which \emph{ends} at observation i. Values of + \code{groups} at the first observation for each subject are + ignored. } \item{boot}{Estimate an exact p-value using a parametric bootstrap. @@ -73,7 +82,7 @@ \item{next.obstime}{This is a vector of length \code{x$data$n} (the number of observations used in the model fit) giving the time to the next \emph{scheduled} observation following each time point. - This is ignored unless times to death are known exactly. + This is only used when times to death are known exactly. For individuals who died (entered an absorbing state) before the next scheduled observation, and the time of death is known exactly, @@ -164,7 +173,7 @@ When times of death are known exactly, states are misclassified, or an individual's final observation is a censored - state, the modification by Titman and Sharples (2007) is + state, the modification by Titman and Sharples (2008) is used. The only form of censoring supported is a state at the end of an individual's series which represents an unknown transient state (i.e. the individual is only known to be alive at this time). Other @@ -173,7 +182,7 @@ See these references for further details of the methods. The method used for censored states is a modification of the method - in the appendix to Titman and Sharples (2007), described at + in the appendix to Titman and Sharples (2008), described at \url{http://www.mrc-bsu.cam.ac.uk/personal/chris/papers/robustcensoring.pdf} (Titman, 2007). @@ -202,9 +211,8 @@ goodness-of-fit test for stationary and time-continuous Markov regression models. \emph{Statistics in Medicine} 21:1899-1911. - Titman, A. and Sharples, L. (2007) A general goodness-of-fit test for - Markov and hidden Markov models. \emph{Statistics in Medicine} - (available online in advance of print) + Titman, A. and Sharples, L. (2008) A general goodness-of-fit test for + Markov and hidden Markov models. \emph{Statistics in Medicine} 27(12):2177-2195 Titman, A. (2008) Model diagnostics in multi-state models of biological systems. PhD thesis, University of Cambridge. Modified: trunk/R/msm/man/plot.survfit.msm.Rd =================================================================== --- trunk/R/msm/man/plot.survfit.msm.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/plot.survfit.msm.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -75,7 +75,9 @@ the first occurrence of the absorbing state in the data will usually be greater than the actual first transition time to that state. Therefore the Kaplan-Meier estimate of the survival probability will - be an overestimate. + be an overestimate. + + This currently only handles time-homogeneous models. } \seealso{\code{\link{survfit}}, \code{\link{plot.survfit}}, \code{\link{plot.prevalence.msm}}} \keyword{models} Modified: trunk/R/msm/man/pmatrix.msm.Rd =================================================================== --- trunk/R/msm/man/pmatrix.msm.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/pmatrix.msm.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -6,7 +6,7 @@ model for a given time interval, at a given set of covariate values. } \usage{ -pmatrix.msm(x, t=1, covariates="mean", ci=c("none","normal","bootstrap"), cl=0.95, B=1000) +pmatrix.msm(x, t=1, t1=0, covariates="mean", ci=c("none","normal","bootstrap"), cl=0.95, B=1000) } \arguments{ @@ -15,6 +15,10 @@ \item{t}{The time interval to estimate the transition probabilities for, by default one unit. } +\item{t1}{The starting time of + the interval. Used for models \code{x} with piecewise-constant intensities fitted + using the \code{pci} option to \code{\link{msm}}. The probabilities will be computed on the interval [t1, t1+t].} + \item{covariates}{ The covariate values at which to estimate the transition probabilities. This can either be:\cr @@ -33,6 +37,11 @@ originally given in the model formula, or a named list, \code{list (age = 60, sex = 1)} + + For time-inhomogeneous models fitted using the \code{pci} option to + \code{msm}, the covariate \code{timeperiod} will + + the time periods according to the time interval given } \item{ci}{If \code{"normal"}, then calculate a confidence interval for Modified: trunk/R/msm/man/totlos.msm.Rd =================================================================== --- trunk/R/msm/man/totlos.msm.Rd 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/man/totlos.msm.Rd 2009-06-12 22:38:33 UTC (rev 229) @@ -3,8 +3,7 @@ \title{Total length of stay} \description{ Estimate the expected total length of stay in each set of states, - for a given period of evolution of a multi-state model. This assumes that the - transition rates do not change with time. + for a given period of evolution of a multi-state model. } \usage{ totlos.msm(x, start=1, end=NULL, fromt=0, tot=Inf, covariates="mean", @@ -99,6 +98,11 @@ expected total time diseased is a forecast for a healthy individual, who may die before getting the disease. + The only time-inhomogeneous models handled by this function are those + specified using the \code{pci} option to \code{\link{msm}}. + For any other inhomogeneous models, the function assumes that + covariates are constant on the forecasted interval. + } \seealso{ \code{\link{sojourn.msm}}, \code{\link{pmatrix.msm}}, \code{\link{integrate}}, \code{\link{boot.msm}}. Modified: trunk/R/msm/src/doc/msm-manual.Rnw =================================================================== --- trunk/R/msm/src/doc/msm-manual.Rnw 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/src/doc/msm-manual.Rnw 2009-06-12 22:38:33 UTC (rev 229) @@ -1,4 +1,4 @@ -%\VignetteIndexEntry{Multi-state modelling with R: the msm package} +%%\VignetteIndexEntry{User guide to msm with worked examples} %\VignettePackage{msm} \documentclass{article} @@ -125,12 +125,12 @@ In a continuous-time Markov model, a single period of occupancy (or \emph{sojourn time}) in state $r$ has an exponential distribution, -with rate given by $q_{rr}$, the $r$th diagonal element of $Q$ (or -mean $1 / q_{rr}$). The remaining elements of the $r$th row of $Q$ +with rate given by $-q_{rr}$, (or +mean $-1 / q_{rr}$). The remaining elements of the $r$th row of $Q$ are \emph{proportional to} the probabilities governing the next state after $r$ to which the individual makes a transition. The probability that the individual occupies state $s$ immediately after state $r$ is -$q_{rs} / q_{rr}$. +$-q_{rs} / q_{rr}$. \subsection{Disease progression models} @@ -431,14 +431,14 @@ time of death is known, but the state on the previous instant before death is unknown. If $S(t_{j+1}) = D $ is such a death state, then the contribution to the likelihood is summed over the unknown state $m$ on -the day before death: +the instant before death: \begin{equation} \label{eq:multi:lik:death} L_{i, j} = \sum_{m \neq D} p_{S(t_j),m}(t_{j+1} - t_j) q_{m, D} \end{equation} -assuming a time unit of days. The sum is taken over all possible -states $m$ which can be visited between $S(t_j)$ and $D$. +The sum is taken over all possible states $m$ which can be visited +between $S(t_j)$ and $D$. \paragraph{Exactly observed transition times} If the times $(t_{i1}, \ldots, t_{in_i})$ had been the {\em exact} @@ -451,10 +451,12 @@ \end{equation} since the state is assumed to be $S(t_j)$ throughout the interval between $t_j$ and $t_{j+1}$ with a known transition to state -$S(t_{j+1})$ at $t_{j+1}$. Note that much richer models are possible -for this type of data, for example semi-parametric models based on Cox -regression, as reviewed by Putter \etal~\cite{putter:mstate}. The -Markov assumption is restrictive but necessary in general to compute a +$S(t_{j+1})$ at $t_{j+1}$. \Rpackage{msm} is restricted to Markov +models, but much richer models are possible for this type of data. For +example, Putter \etal~\cite{putter:mstate} discussed the +\Rpackage{mstate} software for semi-parametric multi-state models with +non-parametric baseline hazards and Cox regression. The Markov +assumption is restrictive but necessary in general to compute a likelihood for intermittently-observed processes. \paragraph{Censored states} @@ -540,10 +542,13 @@ Section~\ref{sec:multi:likelihood}). The \Rpackage{msm} package allows individual-specific or time -dependent covariates to be fitted to transition intensities. -Time-dependent covariates are assumed to be piecewise-constant, -changing only at the observation (or censoring) times of the main -response. +dependent covariates to be fitted to transition intensities. In order +to calculate transition probabilities $P(t)$ on which the likelihood +depends, time-dependent covariates are assumed to be +piecewise-constant. Models whose intensities change with time are +called \emph{time-inhomogeneous}. An important special case handled by +\Rpackage{msm} is the model in which intensities change at a series of +times common to each individual. Marshall and Jones~\cite{retino2} described likelihood ratio and Wald tests for covariate selection and testing hypotheses, for example @@ -730,8 +735,7 @@ If $S(t_{j}) = D$ is an absorbing state such as death, measured without error, whose entry time is known exactly, then the contribution to the likelihood is summed over the unknown state at the -previous instant before death. the day before entry. The $(r,s)$ -entry of $T_{ij}$ is then +previous instant before death. The $(r,s)$ entry of $T_{ij}$ is then \[ p_{rs}(t_{j} - t_{j-1}) q_{s, D} \] @@ -1484,7 +1488,9 @@ \begin{description} \item[Initial values] Make sure that a sensible set of initial values have been chosen. The optimisation may only converge within a - limited range of `informative' initial values. + limited range of `informative' initial values. It is also sensible + to run the model for several different initial values to ensure that + the estimation has converged to a global rather than a local optimum. \item[Scaling] It is often necessary to apply a scaling factor to normalise the likelihood (\Rfunarg{fnscale}), or certain individual @@ -2472,43 +2478,10 @@ For a detailed list of the changes in recent versions of \Rpackage{msm}, see the \texttt{NEWS} file in the top-level directory -of the installed package. +of the installed package. The \texttt{Changelog} file in the +top-level directory of the source package contains more technical +detail about these changes. -Version 0.5 (March 2005) was a major update to \Rpackage{msm}, -introducing hidden Markov models with general responses. Much of the -underlying R and C code was re-organised or re-written. Some syntax -changes were made to simplify the process of specifying models. - -To convert code written for previous versions of \Rpackage{msm} to run in 0.5 or later, -the following changes will need to be made. -\begin{itemize} -\item Replace the \Rfunarg{qmatrix} of ones and zeroes with a - \Rfunarg{qmatrix} containing initial values for transition - intensities. -\item Replace the \Rfunarg{ematrix} of ones and zeroes with a - \Rfunarg{ematrix} containing initial values for misclassification - probabilities. -\item Put any initial values for covariate effects in - \Rfunarg{covinits} or \Rfunarg{misccovinits} arguments. These are - set to zero if not specified. -\item Remove the \Rfunarg{inits} argument. -\item Remove unnecessary \Rfunarg{misc = TRUE} for misclassification models. -\item Replace any \Rfunarg{fromto}-style datasets with proper - longitudinal datasets with one row per observation time. - \Rfunarg{fromto} support has been withdrawn. -\item \Rfunarg{covmatch} has been abolished. If you were using - \Rfunarg{covmatch='next'}, covariates will need to be matched - with observations by moving covariates one row back in the data. -\item \Rfunction{crudeinits.msm} now takes an formula \Rfunarg{state $\sim$ - time} instead of two arguments \Rfunarg{state}, \Rfunarg{time} -\item \Rfunction{simmulti.msm} takes an argument \Rfunarg{covariates} - instead of \Rfunarg{beta}, for consistency with \Rfunction{msm}. -\end{itemize} - -Saved model objects from previous versions will need to be generated -again under 0.5 to work with the post-processing functions from 0.5. - - \section{Get in touch} If you use \Rpackage{msm} in your work, whatever your field of Modified: trunk/R/msm/src/lik.c =================================================================== --- trunk/R/msm/src/lik.c 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/src/lik.c 2009-06-12 22:38:33 UTC (rev 229) @@ -92,8 +92,8 @@ newpars[i] = link(newpars[i]); for (j = 0; j < ncovs[i]; ++j) { x = cov[MI(obs, whichcov[j]-1, nobs)]; - newpars[i] += coveffect[k] * x; - ++k; + newpars[i] += coveffect[k] * x; + ++k; } newpars[i] = invlink(newpars[i]); *totcovs += ncovs[i]; @@ -673,9 +673,10 @@ for (p = 0; p < ndp+ndc; ++p) { deriv[MI(pt,p,d->npts)] = 0; } - GetCovData(i, d->covobs, d->whichcov, x, qcm->ncovs[0], d->nobs); - AddCovs(i, d->nobs, np, qcm->ncovs, qm->intens, newintens, + GetCovData(i, d->covobs, d->whichcov, x, qcm->ncovs[0], d->n); + AddCovs(i, d->n, np, qcm->ncovs, qm->intens, newintens, qcm->coveffect, d->covobs, d->whichcov, &totcovs, log, exp); + dt = d->time[i] - d->time[i-1]; from = fprec(d->obs[i-1] - 1, 0); /* convert state outcome to integer */ to = fprec(d->obs[i] - 1, 0); @@ -692,12 +693,9 @@ for (p = 0; p < ndp+ndc; ++p) dcontrib[p] = dpmat[MI3(from, to, p, qm->nst, qm->nst)]; } -/* printf("pt=%d,obs=%d,from=%d,to=%d,dt=%4.3lf,contrib=%lf,",pt,i,from,to,dt,contrib); */ for (p = 0; p < ndp+ndc; ++p) { -/* printf("d%d = %4.3f,",p,dcontrib[p]); */ - deriv[MI(pt,p,d->npts)] += dcontrib[p] / contrib; /* on loglik scale not -2*loglik */ + deriv[MI(pt,p,d->npts)] += dcontrib[p] / contrib; /* on loglik scale not -2*loglik */ } -/* printf("\n"); */ } for (p = 0; p < ndp+ndc; ++p) deriv[MI(pt,p,d->npts)] *= -2; @@ -778,7 +776,8 @@ int *nintens, /* number of intensity parameters */ int *ndintens, /* number of distinct intensity parameters */ int *ndcovpars, /* number of distinct covariate parameters */ - int *nobs, /* number of observations in data set */ + int *nobs, /* number of observations in data set (hmm/cens) or number of aggregated transitions (standard) */ + int *n, /* number of observations in data set (used for derivs by individual in standard models. no of rows of covobsvec) */ int *npts, /* number of individuals in data set */ int *ncovs, /* number of covariates on transition rates */ @@ -800,7 +799,7 @@ d.cov = covvec; d.covobs = covobsvec; d.nocc = nocc; d.whicha = whicha; d.obstype = obstype; d.obstrue = obstrue; d.whichcov = whichcov; d.whichcovh = whichcovh; d.whichcovi=whichcovi; d.subject = subjvec; d.time = timevec; d.obs = obsvec; d.firstobs = firstobs; - d.nobs = *nobs; d.npts = *npts; + d.nobs = *nobs; d.n = *n; d.npts = *npts; qm.nst = *nst; qm.npars = *nintens; qm.ndpars = *ndintens; qm.ivector = qvector; qm.intens = intens; qm.analyticp = *analyticp; qm.iso = *iso; qm.perm = perm; qm.qperm = qperm; qm.constr = qconstraint; Modified: trunk/R/msm/src/msm.h =================================================================== --- trunk/R/msm/src/msm.h 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/src/msm.h 2009-06-12 22:38:33 UTC (rev 229) @@ -49,6 +49,7 @@ int *whichcovi; int nobs; + int n; int npts; }; Modified: trunk/R/msm/src/pijt.c =================================================================== --- trunk/R/msm/src/pijt.c 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/src/pijt.c 2009-06-12 22:38:33 UTC (rev 229) @@ -10,11 +10,6 @@ based on matexp.cc from JAGS, Copyright (c) 2004, Martyn Plummer. http://www-fis.iarc.fr/~martyn/software/jags - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - ****************************************************************** */ #include "msm.h" Modified: trunk/R/msm/tests/deriv.R =================================================================== --- trunk/R/msm/tests/deriv.R 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/tests/deriv.R 2009-06-12 22:38:33 UTC (rev 229) @@ -173,7 +173,7 @@ system.time(psor.msm <- msm(state ~ months, subject=ptnum, data=psor2, qmatrix = psor.q, covariates = ~ollwsdrt+hieffusn, # covinits=list(hieffusn = c(0.5, 0.1, 0), ollwsdrt=c(0.2, 0.1, -0.1)), constraint = list(hieffusn=c(1,1,1),ollwsdrt=c(1,1,2)), - fixedpars=FALSE, control = list(REPORT=1,trace=2), method="BFGS")) + fixedpars=FALSE, use.deriv=FALSE, control = list(REPORT=1,trace=2), method="BFGS")) sres <- scoreresid.msm(psor.msm) if (interactive()) { sres <- scoreresid.msm(psor.msm, plot=TRUE) Modified: trunk/R/msm/tests/pci.R =================================================================== --- trunk/R/msm/tests/pci.R 2009-06-09 17:00:23 UTC (rev 228) +++ trunk/R/msm/tests/pci.R 2009-06-12 22:38:33 UTC (rev 229) @@ -16,23 +16,23 @@ cav5.msm <- msm( state ~ years, subject=PTNUM, data = cav, qmatrix = twoway4.q, death = TRUE, fixedpars=TRUE, pci = c(5), covinits = list("timeperiod[5,Inf)"=rep(0.01,7)), ) -stopifnot(isTRUE(all.equal(4905.58684722393, cav5.msm$minus2loglik, tol=1e-06))) +stopifnot(isTRUE(all.equal(4905.59585756786, cav5.msm$minus2loglik, tol=1e-06))) cav10.msm <- msm( state ~ years, subject=PTNUM, data = cav, qmatrix = twoway4.q, death = TRUE, pci = c(5,10), fixedpars=TRUE, covinits = list("timeperiod[5,10)"=rep(0.01,7), "timeperiod[10,Inf)"=rep(0.01,7)), ) -stopifnot(isTRUE(all.equal(4905.27634460236, cav10.msm$minus2loglik, tol=1e-06))) +stopifnot(isTRUE(all.equal(4905.28758421853, cav10.msm$minus2loglik, tol=1e-06))) if (developer.local) { cav5.msm <- msm( state ~ years, subject=PTNUM, data = cav, qmatrix = twoway4.q, death = TRUE, pci = c(5), covinits = list("timeperiod[5,Inf)"=rep(0.01,7)), method="BFGS", control=list(trace=5, REPORT=1)) - stopifnot(isTRUE(all.equal(3919.99601337682, cav5.msm$minus2loglik, tol=1e-06))) + stopifnot(isTRUE(all.equal(3919.99601396194, cav5.msm$minus2loglik, tol=1e-06))) cav10.msm <- msm( state ~ years, subject=PTNUM, data = cav, qmatrix = twoway4.q, death = TRUE, pci = c(5,10), covinits = list("timeperiod[5,10)"=rep(0.01,7), "timeperiod[10,Inf)"=rep(0.01,7)), method="BFGS", control=list(trace=5, REPORT=1)) - stopifnot(isTRUE(all.equal(3882.08842673942, cav10.msm$minus2loglik, tol=1e-06))) + stopifnot(isTRUE(all.equal(3882.08834017773, cav10.msm$minus2loglik, tol=1e-06))) } ## Compare with old method - create artificial covariate @@ -72,8 +72,8 @@ ## Make sure works for pci outside time range, with warning cav5.msm <- msm( state ~ years, subject=PTNUM, data = cav, qmatrix = twoway4.q, death = TRUE, fixedpars=TRUE, pci = c(-1,5,50,60), covinits = list("timeperiod[5,Inf)"=rep(0.01,7)), - method="BFGS", control=list(trace=5, REPORT=1)) -stopifnot(isTRUE(all.equal(4905.58684722393, cav5.msm$minus2loglik, tol=1e-06))) + method="BFGS", control=list(trace=5, REPORT=1)) +stopifnot(isTRUE(all.equal(4905.59585756786, cav5.msm$minus2loglik, tol=1e-06))) ## No cuts left , degrades to time homogeneous model cav.msm <- msm( state ~ years, subject=PTNUM, data = cav, @@ -137,7 +137,7 @@ qmatrix = twoway4.q, death = TRUE, censor=99, pci = 5, covinits=list("timeperiod[5,Inf)"=rep(0.02,7)), fixedpars=TRUE, method="BFGS", control=list(trace=5, REPORT=1)) -stopifnot(isTRUE(all.equal(4753.51295496850, cav5cens.msm$minus2loglik, tol=1e-06))) +stopifnot(isTRUE(all.equal(4753.53207003774, cav5cens.msm$minus2loglik, tol=1e-06))) cav2.cens <- cav2[cav2$state!=999,] cav2.cens$state[cav2.cens$state==4][1:50] <- 998 @@ -146,7 +146,7 @@ covinits=list(after510=rep(0.02,7)), fixedpars=TRUE, center=FALSE, censor=c(99,998), censor.states=list(1:4,1:3), method="BFGS", control=list(trace=5, REPORT=1)) -stopifnot(isTRUE(all.equal(4753.51295496850, cav5cens.msm$minus2loglik, tol=1e-06))) +stopifnot(isTRUE(all.equal(4753.53207003774, cav5cens.msm$minus2loglik, tol=1e-06))) ## test bootstrap with factor / other covs @@ -177,7 +177,7 @@ pci = 5, covinits=list("timeperiod... [truncated message content] |
From: <den...@us...> - 2009-06-09 17:00:31
|
Revision: 228 http://rmol.svn.sourceforge.net/rmol/?rev=228&view=rev Author: denis_arnaud Date: 2009-06-09 17:00:23 +0000 (Tue, 09 Jun 2009) Log Message: ----------- [Doc HTML] Altered the colour of the header and footer parts of the HTML generated documentation. Modified Paths: -------------- trunk/rmol/doc/local/rmol_footer.html trunk/rmol/doc/local/rmol_header.html Modified: trunk/rmol/doc/local/rmol_footer.html =================================================================== --- trunk/rmol/doc/local/rmol_footer.html 2009-06-08 08:10:43 UTC (rev 227) +++ trunk/rmol/doc/local/rmol_footer.html 2009-06-09 17:00:23 UTC (rev 228) @@ -1,4 +1,4 @@ -<div style="clear: both; width: 100%; height: 31px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;"> +<div style="clear: both; width: 100%; height: 31px; background-color: #ffffff; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;"> <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=177703&type=1" alt="SourceForge Logo" style="float: right; border: 0;"></a> <p style="padding-left: 10px; font-size: 85%;">Generated on $datetime for $projectname by <a href="http://www.doxygen.org/index.html">Doxygen</a> $doxygenversion</p> </div> Modified: trunk/rmol/doc/local/rmol_header.html =================================================================== --- trunk/rmol/doc/local/rmol_header.html 2009-06-08 08:10:43 UTC (rev 227) +++ trunk/rmol/doc/local/rmol_header.html 2009-06-09 17:00:23 UTC (rev 228) @@ -9,7 +9,7 @@ </head> <body> -<div style="width: 100%; height: 40px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;"> +<div style="width: 100%; height: 40px; background-color: #ffffff; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;"> <a href="http://rmol.sourceforge.net"><img width="150" height="40" src="rmol_logo.png" alt="RMOL Logo" style="float: left; border: 0;"></a> <a href="http://sourceforge.net/projects/rmol"><img This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2009-06-08 08:10:52
|
Revision: 227 http://rmol.svn.sourceforge.net/rmol/?rev=227&view=rev Author: quannaus Date: 2009-06-08 08:10:43 +0000 (Mon, 08 Jun 2009) Log Message: ----------- Creating a private branch of rmol for the working version of 0.23.0. Added Paths: ----------- branches/rmol-0.23.0-working/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-06-06 21:27:19
|
Revision: 226 http://rmol.svn.sourceforge.net/rmol/?rev=226&view=rev Author: denis_arnaud Date: 2009-06-06 21:26:21 +0000 (Sat, 06 Jun 2009) Log Message: ----------- [R-msm] Fixed the license issue (cf. https://bugzilla.redhat.com/show_bug.cgi?id=498845). Modified Paths: -------------- trunk/R/R-msm.spec Added Paths: ----------- trunk/R/README_License_msm Modified: trunk/R/R-msm.spec =================================================================== --- trunk/R/R-msm.spec 2009-06-05 19:17:18 UTC (rev 225) +++ trunk/R/R-msm.spec 2009-06-06 21:26:21 UTC (rev 226) @@ -3,10 +3,11 @@ Name: R-%{packname} Version: 0.8.2 -Release: 1%{?dist} +Release: 2%{?dist} Source0: ftp://cran.r-project.org/pub/R/contrib/main/%{packname}_%{version}.tar.gz -License: GPLv2 -URL: http://cran.r-project.org/src/contrib +Source1: README_License_msm +License: GPLv2+ +URL: http://cran.r-project.org/web/packages/msm/ Group: Applications/Engineering Summary: Multi-state Markov and hidden Markov models in continuous time BuildRequires: R-devel, tetex-latex, R-mvtnorm @@ -28,6 +29,7 @@ # Fix some permissions and formats # find . -type f -perm 755 -exec chmod 644 {} \; find . -type f -name '*.[hc]' -exec chmod 644 {} \; + # Fix the encoding of the NEWS file chmod 644 %{packname}/inst/NEWS iconv -f ISO88591 -t UTF8 -o NEWS %{packname}/inst/NEWS @@ -37,12 +39,21 @@ %install rm -rf $RPM_BUILD_ROOT + +# Specific installation procedure for R mkdir -p $RPM_BUILD_ROOT%{_libdir}/R/library %{_bindir}/R CMD INSTALL -l $RPM_BUILD_ROOT%{_libdir}/R/library %{packname} + +# Temporary fix for the license issue (https://bugzilla.redhat.com/show_bug.cgi?id=498845#c1) +install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_libdir}/R/library/%{packname} + +# Remove the temporary object files test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so) + +# Remove the generic cascading style sheet for R rm -rf $RPM_BUILD_ROOT%{_libdir}/R/library/R.css -# find ./doc -type f -perm 755 -exec chmod 644 {} \; + %check %{_bindir}/R CMD check %{packname} @@ -58,6 +69,7 @@ %files %defattr(-, root, root, -) %dir %{_libdir}/R/library/%{packname} +%doc %{_libdir}/R/library/%{packname}/README_License_msm %doc %{_libdir}/R/library/%{packname}/latex %doc %{_libdir}/R/library/%{packname}/data %doc %{_libdir}/R/library/%{packname}/doc @@ -75,5 +87,8 @@ %{_libdir}/R/library/%{packname}/libs/%{packname}.so %changelog +* Sat Jun 06 2009 Denis Arnaud <den...@m4...> 0.8.2-2 +- Altered the license so as to reflect upstream, after clarification with them + * Sun May 03 2009 Denis Arnaud <den...@m4...> 0.8.2-1 - Initial package creation Added: trunk/R/README_License_msm =================================================================== --- trunk/R/README_License_msm (rev 0) +++ trunk/R/README_License_msm 2009-06-06 21:26:21 UTC (rev 226) @@ -0,0 +1,53 @@ + +As noticed by Jason Tibbitts <ti...@ma...> on June 6, 2009, the license +is a bit unclear. DESCRIPTION states "GPL-2", but src/pijt.c, the only other +file which seems to have a license, uses the FSF-recommended language and +states GPLv2+. That needed to be clarified with upstream. + +The maintainer, namely Denis Arnaud <den...@m4...>, therefore +sent an email to the (R-)msm project owner, namely Chris Jackson +<chr...@mr...>, to clarify that license issue. Following is +a copy of the corresponding emails, including the answer from the project +owner: the license was intended to be GPLv2+. + +============================================================================== +Subject: Re: License of (R-)msm - Packaging for Fedora/RedHat +Date: Fri 5 Jun 2009 6:22pm +From: "Chris Jackson" <chr...@mr...> + +"Denis Arnaud" <den...@m4...> wrote: +> Hello Chris, +> +> First of all, thank you very much for your nice work on R-based software! +> Also, I would like to package your R software, namely MSM (Multi-State +> Markov), for Fedora and RedHat (RPM packages): +> https://bugzilla.redhat.com/show_bug.cgi?id=498845 +> +> A question arises: "The license is a bit unclear. DESCRIPTION says "GPL-2", +> but src/pijt.c (the only other file that seems to have a license) uses the +> FSF-recommended language and says GPLv2+." +> +> So, is the license GPL-v2 strictly, or should it be GPLv2+ ("GPL-v2 and +> later")? And would you be so kind as to alter accordingly the DESCRIPTION +> and/or src/pijt.c files? + +Dear Denis, + +Thanks for pointing that out, it was an oversight. I will alter the DESCRIPTION +file to put the whole package under GPL version 2 or later. I am working on +several updates and bug fixes at the moment, so I intend to release the next +version with this change within the next two weeks. + +Thanks for packaging it - it has also recently been included in Debian! + +Chris + +-- Christopher Jackson <chr...@mr...> +Research Statistician, MRC Biostatistics Unit, Institute of Public +Health, Robinson Way, Cambridge, UK, CB2 0SR. +44 (1223) 330381 +============================================================================== + +Note: when the license statement will be clarified upstream, that README file +will be removed from the (R-msm) RPM package. + + Property changes on: trunk/R/README_License_msm ___________________________________________________________________ Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |