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>
15#include <stdair/stdair_basic_types.hpp>
16#include <stdair/service/Logger.hpp>
19#include <rmol/config/rmol-paths.hpp>
22namespace ba = boost::accumulators;
38 std::string
rmol (
const int& iRandomDraws,
const short& iMethod,
39 const double& iCapacity) {
40 std::ostringstream oStream;
43 if (_logOutputStream == NULL) {
44 oStream <<
"The log filepath is not valid." << std::endl;
47 assert (_logOutputStream != NULL);
52 *_logOutputStream <<
"Optimisation for " << iRandomDraws <<
" draws, "
53 <<
"capacity of " << iCapacity
54 <<
", and with the following method: "
55 << iMethod << std::endl;
57 if (_rmolService == NULL) {
58 oStream <<
"The RMOL service has not been initialised, "
59 <<
"i.e., the init() method has not been called "
60 <<
"correctly on the RMOLer object. Please "
61 <<
"check that all the parameters are not empty and "
62 <<
"point to actual files.";
63 *_logOutputStream << oStream.str();
66 assert (_rmolService != NULL);
101 *_logOutputStream <<
"End of the optimisation." << std::endl;
104 *_logOutputStream <<
"RMOL output: "
105 << oStream.str() << std::endl;
107 }
catch (
const stdair::RootException& eRMOLError) {
108 oStream <<
"RMOL error: " << eRMOLError.what() << std::endl;
110 }
catch (
const std::exception& eStdError) {
111 oStream <<
"Error: " << eStdError.what() << std::endl;
114 oStream <<
"Unknown error" << std::endl;
118 oStream <<
"RMOL has completed the generation of the booking "
119 <<
"requests. See the log file for more details." << std::endl;
121 return oStream.str();
126 RMOLer() : _rmolService (NULL), _logOutputStream (NULL) {
131 : _rmolService (iRMOLer._rmolService),
132 _logOutputStream (iRMOLer._logOutputStream) {
138 _logOutputStream = NULL;
144 bool init (
const std::string& iLogFilepath,
145 const short& iCapacity,
const bool isBuiltin,
146 const stdair::Filename_T& iInputFilename) {
147 bool isEverythingOK =
true;
152 const bool isWriteable = (iLogFilepath.empty() ==
false);
154 if (isWriteable ==
false) {
155 isEverythingOK =
false;
156 return isEverythingOK;
160 _logOutputStream =
new std::ofstream;
161 assert (_logOutputStream != NULL);
164 _logOutputStream->open (iLogFilepath.c_str());
165 _logOutputStream->clear();
168 *_logOutputStream <<
"Python wrapper initialisation" << std::endl;
169 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
174 assert (_rmolService != NULL);
177 if (isBuiltin ==
true) {
187 *_logOutputStream <<
"Python wrapper initialised" << std::endl;
189 }
catch (
const stdair::RootException& eRMOLError) {
190 *_logOutputStream <<
"RMOL error: " << eRMOLError.what()
193 }
catch (
const std::exception& eStdError) {
194 *_logOutputStream <<
"Error: " << eStdError.what() << std::endl;
197 *_logOutputStream <<
"Unknown error" << std::endl;
200 return isEverythingOK;
206 std::ofstream* _logOutputStream;
213 boost::python::class_<RMOL::RMOLer> (
"RMOLer")
BOOST_PYTHON_MODULE(pyrmol)
Wrapper structure around the C++ API, so as to expose a Python API.
bool init(const std::string &iLogFilepath, const short &iCapacity, const bool isBuiltin, const stdair::Filename_T &iInputFilename)
RMOLer(const RMOLer &iRMOLer)
std::string rmol(const int &iRandomDraws, const short &iMethod, const double &iCapacity)
Interface for the RMOL Services.
void parseAndLoad(const stdair::CabinCapacity_T &iCabinCapacity, const stdair::Filename_T &iDemandAndClassDataFile)
void optimize(const stdair::NbOfSamples_T iDraws=0)