Skip to content

Commit

Permalink
[skip] better
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Nov 16, 2023
1 parent b6e4720 commit 1586ab5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
21 changes: 10 additions & 11 deletions src/solver/utils/ortools_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,19 @@ namespace Optimization
{
void setOrtoolsSolverLogs(MPSolver* solver, OrtoolsLogHandler& ortools_logger)
{
// TODO won't work in ci, needs ortools update
// see https://github.com/rte-france/or-tools/pull/112
// std::filesystem::path log_file = logs.logfile().c_str();
// auto log_directory = log_file.parent_path();
// auto myid = std::this_thread::get_id();
// std::stringstream ss;
// ss << myid;
// auto log_file_per_thread = log_directory / (std::string("thread_") + ss.str() + ".log");
// // TODO
// log_writer.open(log_file_per_thread, std::ofstream::out | std::ofstream::app);
// log_streams.push_back(&log_writer);
solver->EnableOutput(&ortools_logger);
}

OrtoolsLogHandler::OrtoolsLogHandler()
{
std::filesystem::path log_file = logs.logfile().c_str();
auto log_directory = log_file.parent_path();
auto myid = std::this_thread::get_id();
std::stringstream ss;
ss << myid;
auto log_file_per_thread = log_directory / (std::string("thread_") + ss.str() + ".log");
log_writer_.open(log_file_per_thread, std::ofstream::out | std::ofstream::app);
}
ProblemSimplexeNommeConverter::ProblemSimplexeNommeConverter(
const std::string& solverName,
const Antares::Optimization::PROBLEME_SIMPLEXE_NOMME* problemeSimplexe) :
Expand Down
30 changes: 20 additions & 10 deletions src/solver/utils/ortools_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@

using namespace operations_research;

class OrtoolsLogHandler : public LogHandlerInterface
{
public:
// tmp test with std::cout
explicit OrtoolsLogHandler() = default;
void message(const char* msg) override
{
std::cout << msg << std::endl;
}
};
void ORTOOLS_EcrireJeuDeDonneesLineaireAuFormatMPS(MPSolver* solver,
Antares::Solver::IResultWriter& writer,
const std::string& filename);
Expand Down Expand Up @@ -58,6 +48,26 @@ namespace Antares
{
namespace Optimization
{

class OrtoolsLogHandler : public LogHandlerInterface
{
public:
// tmp test with std::cout
explicit OrtoolsLogHandler();
void message(const char* msg) override
{
log_writer_ << msg << std::endl;
}

private:
// TODO won't work in ci, needs ortools update
// see https://github.com/rte-france/or-tools/pull/112

// // TODO
std::ofstream log_writer_;
// log_writer.open(log_file_per_thread, std::ofstream::out | std::ofstream::app);
// log_streams.push_back(&log_writer);
};
void setOrtoolsSolverLogs(MPSolver* solver, OrtoolsLogHandler &ortools_logger);
class Nomenclature
{
Expand Down

0 comments on commit 1586ab5

Please sign in to comment.