8 #include <boost/date_time/gregorian/gregorian.hpp>
9 #include <boost/date_time/posix_time/posix_time.hpp>
11 #include <boost/python.hpp>
13 #include <boost/accumulators/accumulators.hpp>
14 #include <boost/accumulators/statistics.hpp>
16 #include <stdair/stdair_basic_types.hpp>
17 #include <stdair/service/Logger.hpp>
23 namespace ba = boost::accumulators;
39 std::string
rmol (
const int& iRandomDraws,
const short& iMethod,
40 const double& iCapacity) {
41 std::ostringstream oStream;
44 if (_logOutputStream == NULL) {
45 oStream <<
"The log filepath is not valid." << std::endl;
48 assert (_logOutputStream != NULL);
53 *_logOutputStream <<
"Optimisation for " << iRandomDraws <<
" draws, "
54 <<
"capacity of " << iCapacity
55 <<
", and with the following method: "
56 << iMethod << std::endl;
58 if (_rmolService == NULL) {
59 oStream <<
"The RMOL service has not been initialised, "
60 <<
"i.e., the init() method has not been called "
61 <<
"correctly on the RMOLer object. Please "
62 <<
"check that all the parameters are not empty and "
63 <<
"point to actual files.";
64 *_logOutputStream << oStream.str();
67 assert (_rmolService != NULL);
102 *_logOutputStream <<
"End of the optimisation." << std::endl;
105 *_logOutputStream <<
"RMOL output: "
106 << oStream.str() << std::endl;
108 }
catch (
const stdair::RootException& eRMOLError) {
109 oStream <<
"RMOL error: " << eRMOLError.what() << std::endl;
111 }
catch (
const std::exception& eStdError) {
112 oStream <<
"Error: " << eStdError.what() << std::endl;
115 oStream <<
"Unknown error" << std::endl;
119 oStream <<
"RMOL has completed the generation of the booking "
120 <<
"requests. See the log file for more details." << std::endl;
122 return oStream.str();
127 RMOLer() : _rmolService (NULL), _logOutputStream (NULL) {
132 : _rmolService (iRMOLer._rmolService),
133 _logOutputStream (iRMOLer._logOutputStream) {
139 _logOutputStream = NULL;
145 bool init (
const std::string& iLogFilepath,
146 const short& iCapacity,
const bool isBuiltin,
147 const stdair::Filename_T& iInputFilename) {
148 bool isEverythingOK =
true;
153 const bool isWriteable = (iLogFilepath.empty() ==
false);
155 if (isWriteable ==
false) {
156 isEverythingOK =
false;
157 return isEverythingOK;
161 _logOutputStream =
new std::ofstream;
162 assert (_logOutputStream != NULL);
165 _logOutputStream->open (iLogFilepath.c_str());
166 _logOutputStream->clear();
169 *_logOutputStream <<
"Python wrapper initialisation" << std::endl;
170 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
175 assert (_rmolService != NULL);
178 if (isBuiltin ==
true) {
188 *_logOutputStream <<
"Python wrapper initialised" << std::endl;
190 }
catch (
const stdair::RootException& eRMOLError) {
191 *_logOutputStream <<
"RMOL error: " << eRMOLError.what()
194 }
catch (
const std::exception& eStdError) {
195 *_logOutputStream <<
"Error: " << eStdError.what() << std::endl;
198 *_logOutputStream <<
"Unknown error" << std::endl;
201 return isEverythingOK;
207 std::ofstream* _logOutputStream;
214 boost::python::class_<RMOL::RMOLer> (
"RMOLer")