8 #include <boost/date_time/posix_time/posix_time.hpp>
9 #include <boost/date_time/gregorian/gregorian.hpp>
10 #include <boost/program_options.hpp>
12 #include <stdair/service/Logger.hpp>
47 template<
class T> std::ostream&
operator<< (std::ostream& os,
48 const std::vector<T>& v) {
49 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout,
" "));
58 int& ioRandomDraws,
double& ioCapacity,
59 short& ioMethod,
bool& ioIsBuiltin,
60 std::string& ioInputFilename, std::string& ioLogFilename){
66 boost::program_options::options_description
generic (
"Generic options");
68 (
"prefix",
"print installation prefix")
69 (
"version,v",
"print version string")
70 (
"help,h",
"produce help message");
74 boost::program_options::options_description config (
"Configuration");
78 "Number of to-be-generated random draws")
81 "Resource capacity (e.g., for a flight leg)")
84 "Revenue Management method to be used (0 = Monte-Carlo, 1 = Dynamic Programming, 2 = EMSR, 3 = EMSR-a, 4 = EMSR-b)")
86 "The cabin set up can be either built-in or parsed from an input file. That latter must then be given with the -i/--input option")
89 "(CSV) input file for the demand distribution parameters and resource (leg-cabin) capacities")
92 "Filename for the logs")
97 boost::program_options::options_description hidden (
"Hidden options");
100 boost::program_options::value< std::vector<std::string> >(),
101 "Show the copyright (license)");
103 boost::program_options::options_description cmdline_options;
104 cmdline_options.add(
generic).add(config).add(hidden);
106 boost::program_options::options_description config_file_options;
107 config_file_options.add(config).add(hidden);
109 boost::program_options::options_description visible (
"Allowed options");
110 visible.add(
generic).add(config);
112 boost::program_options::positional_options_description p;
113 p.add (
"copyright", -1);
115 boost::program_options::variables_map vm;
116 boost::program_options::
117 store (boost::program_options::command_line_parser (argc, argv).
118 options (cmdline_options).positional(p).run(), vm);
120 std::ifstream ifs (
"rmol.cfg");
121 boost::program_options::store (parse_config_file (ifs, config_file_options),
123 boost::program_options::notify (vm);
125 if (vm.count (
"help")) {
126 std::cout << visible << std::endl;
130 if (vm.count (
"version")) {
135 if (vm.count (
"prefix")) {
136 std::cout <<
"Installation prefix: " <<
PREFIXDIR << std::endl;
140 if (vm.count (
"builtin")) {
143 const std::string isBuiltinStr = (ioIsBuiltin ==
true)?
"yes":
"no";
144 std::cout <<
"The BOM should be built-in? " << isBuiltinStr << std::endl;
146 if (ioIsBuiltin ==
false) {
147 if (vm.count (
"input")) {
148 ioInputFilename = vm[
"input"].as< std::string >();
149 std::cout <<
"Input filename is: " << ioInputFilename << std::endl;
153 if (vm.count (
"log")) {
154 ioLogFilename = vm[
"log"].as< std::string >();
155 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
158 std::cout <<
"The number of random draws is: " << ioRandomDraws << std::endl;
159 std::cout <<
"The resource capacity is: " << ioCapacity << std::endl;
160 std::cout <<
"The optimisation method is: " << ioMethod << std::endl;
161 std::cout << std::endl;
168 const short& iMethod,
const int& iRandomDraws) {
204 int main (
int argc,
char* argv[]) {
207 int lRandomDraws = 0;
210 double lCapacity = 0.0;
220 std::string lInputFilename;
223 std::string lLogFilename;
226 const int lOptionParserStatus =
228 isBuiltin, lInputFilename, lLogFilename);
235 std::ofstream logOutputFile;
237 logOutputFile.open (lLogFilename.c_str());
238 logOutputFile.clear();
241 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
246 if (isBuiltin ==
true) {
248 STDAIR_LOG_DEBUG (
"No input file has been given."
249 "A sample BOM tree will therefore be built.");
256 STDAIR_LOG_DEBUG (
"RMOL will parse " << lInputFilename
257 <<
" and build the corresponding BOM tree.");
264 optimise (rmolService, lMethod, lRandomDraws);
267 logOutputFile.close();