8#include "BendersStructsDatas.h"
9#include "antares-xpansion/xpansion_interfaces/ILogger.h"
11const std::string MATHLOGGERCONTEXT =
"Benders";
13enum class HEADERSTYPE { SHORT, LONG };
15 explicit HeadersManager(HEADERSTYPE type,
const BENDERSMETHOD& method);
18 BENDERSMETHOD method_;
20 virtual std::vector<std::string> HeadersList();
24 const BENDERSMETHOD& method);
25 std::vector<std::string> HeadersList()
override;
32 std::streamsize width = 40);
34 std::ostream& operator<<(std::ostream& (*function)(std::ostream&)) {
35 return function(*stream_);
39 std::ostream& operator<<(
const T& obj);
40 std::ostream& InsertDelimiter() {
return *stream_ << delimiter_; }
43 std::ofstream file_stream_;
44 std::ostream* stream_;
45 std::streamsize width_ = 40;
46 std::string delimiter_ =
"\t";
49 void setDelimiter(
const std::string& delimiter);
52std::ostream& LogDestination::operator<<(
const T& obj) {
53 return (*stream_) << std::left << std::setw(width_) << obj;
57 const BENDERSMETHOD& method);
61 const HEADERSTYPE& type,
62 const BENDERSMETHOD& method);
68 virtual std::vector<std::string> Headers()
const = 0;
71 virtual void PrintIterationSeparatorBegin()
override;
72 virtual void PrintIterationSeparatorEnd()
override;
73 virtual void setHeadersList() = 0;
78 explicit MathLogger(
const std::filesystem::path& file_path,
79 std::streamsize width = 40,
80 HEADERSTYPE type = HEADERSTYPE::LONG);
82 explicit MathLogger(std::streamsize width = 40,
83 HEADERSTYPE type = HEADERSTYPE::SHORT);
87 const std::string& context)
override;
89 std::vector<std::string> Headers()
const override;
91 virtual void setHeadersList() = 0;
92 HEADERSTYPE HeadersType()
const;
96 void setHeadersList(
const std::vector<std::string>& headers);
99 std::vector<std::string> headers_;
105 using MathLogger::MathLogger;
108 void setHeadersList()
override;
113 using MathLoggerBase::MathLoggerBase;
115 void setHeadersList()
override;
120 using MathLogger::MathLogger;
122 void setHeadersList()
override;
126 using MathLoggerBendersByBatch::MathLoggerBendersByBatch;
128 void setHeadersList()
override;
135 const std::filesystem::path& file_path,
136 const std::vector<std::string>& headers,
139 headers_.push_back(
"Outer loop");
140 headers_.push_back(
"Ite");
141 headers_.insert(headers_.end(), headers.begin(), headers.end());
144 void setHeadersList()
override;
148 const std::string& context)
override;
152 std::vector<std::string> headers_;
159 const std::filesystem::path& file_path,
160 std::streamsize width = 40,
161 HEADERSTYPE type = HEADERSTYPE::LONG);
163 std::streamsize width = 40,
164 HEADERSTYPE type = HEADERSTYPE::LONG);
169 const std::string& context)
override;
171 void PrintIterationSeparatorBegin()
override;
172 void PrintIterationSeparatorEnd()
override;
177 void setHeadersList()
override;
178 std::vector<std::string> Headers()
const override;
182 std::shared_ptr<MathLogger> implementation_;
191 const std::string& context)
override;
192 void add_logger(std::shared_ptr<MathLoggerImplementation> logger);
194 void add_logger(
const std::filesystem::path& file_path,
195 const std::vector<std::string>& headers,
198 virtual void PrintIterationSeparatorBegin()
override;
199 virtual void PrintIterationSeparatorEnd()
override;
203 std::vector<std::shared_ptr<MathLoggerImplementation>> math_loggers_;
207void MathLoggerDriver::add_logger(
const std::filesystem::path& file_path,
208 const std::vector<std::string>& headers,
210 auto impl = std::make_shared<MathLoggerExternalLoopSpecific<T>>(file_path,
212 add_logger(std::make_shared<MathLoggerImplementation>(impl));
217 MathLogger::setHeadersList(headers_);
222 LogsDestination().InsertDelimiter();
223 LogsDestination() << data.criteria_current_iteration_data.benders_num_run;
224 LogsDestination().InsertDelimiter();
225 LogsDestination() << data.it;
226 LogsDestination().InsertDelimiter();
227 for (
const auto& t : data.criteria_current_iteration_data.*ptr_) {
228 LogsDestination() << std::scientific << std::setprecision(10) << t;
229 LogsDestination().InsertDelimiter();
231 LogsDestination() << std::endl;
236 const std::string& msg) {
242 const std::string& str, LogUtils::LOGLEVEL level,
243 const std::string& context) {
Definition BendersMathLogger.h:28
Definition BendersMathLogger.h:185
void display_message(const std::string &str) override
pure virtual method to display a std::string message
Definition BendersMathLogger.cpp:291
Definition BendersMathLogger.h:156
void display_message(const std::string &str) override
pure virtual method to display a std::string message
Definition BendersMathLogger.cpp:371
Definition BendersStructsDatas.h:8
Definition BendersStructsDatas.h:24
Xpansion Unique log Interface.
Definition ILogger.h:74
Definition BendersMathLogger.h:112
Definition BendersMathLogger.h:104
Definition BendersMathLogger.h:64
Definition BendersMathLogger.h:125
Definition BendersMathLogger.h:119
Definition BendersMathLogger.h:133
void display_message(const std::string &msg) override
pure virtual method to display a std::string message
Definition BendersMathLogger.h:235
Definition BendersMathLogger.h:77
void display_message(const std::string &str) override
pure virtual method to display a std::string message
Definition BendersMathLogger.cpp:118