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>
16 #include <rmol/config/rmol-paths.hpp>
48 template<
class T> std::ostream&
operator<< (std::ostream& os,
49 const std::vector<T>& v) {
50 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout,
" "));
59 int& ioRandomDraws,
double& ioCapacity,
60 short& ioMethod,
bool& ioIsBuiltin,
61 std::string& ioInputFilename, std::string& ioLogFilename){
67 boost::program_options::options_description
generic (
"Generic options");
69 (
"prefix",
"print installation prefix")
70 (
"version,v",
"print version string")
71 (
"help,h",
"produce help message");
75 boost::program_options::options_description config (
"Configuration");
79 "Number of to-be-generated random draws")
82 "Resource capacity (e.g., for a flight leg)")
85 "Revenue Management method to be used (0 = Monte-Carlo, 1 = Dynamic Programming, 2 = EMSR, 3 = EMSR-a, 4 = EMSR-b)")
87 "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")
90 "(CSV) input file for the demand distribution parameters and resource (leg-cabin) capacities")
93 "Filename for the logs")
98 boost::program_options::options_description hidden (
"Hidden options");
101 boost::program_options::value< std::vector<std::string> >(),
102 "Show the copyright (license)");
104 boost::program_options::options_description cmdline_options;
105 cmdline_options.add(
generic).add(config).add(hidden);
107 boost::program_options::options_description config_file_options;
108 config_file_options.add(config).add(hidden);
110 boost::program_options::options_description visible (
"Allowed options");
111 visible.add(
generic).add(config);
113 boost::program_options::positional_options_description p;
114 p.add (
"copyright", -1);
116 boost::program_options::variables_map vm;
117 boost::program_options::
118 store (boost::program_options::command_line_parser (argc, argv).
119 options (cmdline_options).positional(p).run(), vm);
121 std::ifstream ifs (
"rmol.cfg");
122 boost::program_options::store (parse_config_file (ifs, config_file_options),
124 boost::program_options::notify (vm);
126 if (vm.count (
"help")) {
127 std::cout << visible << std::endl;
131 if (vm.count (
"version")) {
132 std::cout << PACKAGE_NAME <<
", version " << PACKAGE_VERSION << std::endl;
136 if (vm.count (
"prefix")) {
137 std::cout <<
"Installation prefix: " << PREFIXDIR << std::endl;
141 if (vm.count (
"builtin")) {
144 const std::string isBuiltinStr = (ioIsBuiltin ==
true)?
"yes":
"no";
145 std::cout <<
"The BOM should be built-in? " << isBuiltinStr << std::endl;
147 if (ioIsBuiltin ==
false) {
148 if (vm.count (
"input")) {
149 ioInputFilename = vm[
"input"].as< std::string >();
150 std::cout <<
"Input filename is: " << ioInputFilename << std::endl;
154 if (vm.count (
"log")) {
155 ioLogFilename = vm[
"log"].as< std::string >();
156 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
159 std::cout <<
"The number of random draws is: " << ioRandomDraws << std::endl;
160 std::cout <<
"The resource capacity is: " << ioCapacity << std::endl;
161 std::cout <<
"The optimisation method is: " << ioMethod << std::endl;
162 std::cout << std::endl;
169 const short& iMethod,
const int& iRandomDraws) {
205 int main (
int argc,
char* argv[]) {
208 int lRandomDraws = 0;
211 double lCapacity = 0.0;
221 std::string lInputFilename;
224 std::string lLogFilename;
227 const int lOptionParserStatus =
229 isBuiltin, lInputFilename, lLogFilename);
236 std::ofstream logOutputFile;
238 logOutputFile.open (lLogFilename.c_str());
239 logOutputFile.clear();
242 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
247 if (isBuiltin ==
true) {
249 STDAIR_LOG_DEBUG (
"No input file has been given."
250 "A sample BOM tree will therefore be built.");
257 STDAIR_LOG_DEBUG (
"RMOL will parse " << lInputFilename
258 <<
" and build the corresponding BOM tree.");
265 optimise (rmolService, lMethod, lRandomDraws);
268 logOutputFile.close();