Skip to content

Commit

Permalink
[skip ci] will not work thank u @guilpier-code
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Nov 16, 2023
1 parent 78790e6 commit 151dedd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/solver/utils/ortools_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <antares/exception/AssertionError.hpp>
#include <antares/Enum.hpp>
#include <filesystem>
#include <thread>

using namespace operations_research;

Expand Down Expand Up @@ -41,6 +42,18 @@ ProblemSimplexeNommeConverter::ProblemSimplexeNommeConverter(
variableNameManager_.SetTarget(problemeSimplexe_->VariableNames());
constraintNameManager_.SetTarget(problemeSimplexe_->ConstraintNames());
}

// 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 = log_directory / (std::string("thread_") + ss.str() + ".log");
// TODO
log_writer_.open(log_file, std::ofstream::out | std::ofstream::app);
log_streams.push_back(&log_writer_);
}

MPSolver* ProblemSimplexeNommeConverter::Convert()
Expand All @@ -57,11 +70,7 @@ MPSolver* ProblemSimplexeNommeConverter::Convert()
CopyMatrix(solver);
if (problemeSimplexe_->SolverLogs())
{
solver->EnableOutput();
// 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();
// solver->set_solver_logs_directory(log_file.parent_path());
solver->EnableOutput(&log_streams);
}

return solver;
Expand Down
3 changes: 3 additions & 0 deletions src/solver/utils/ortools_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ class ProblemSimplexeNommeConverter
void CopyRows(MPSolver* solver);
void TuneSolverSpecificOptions(MPSolver* solver) const;
void CopyMatrix(const MPSolver* solver);
std::ofstream log_writer_; // one per thread

std::vector<std::ostream*> log_streams;
};
} // namespace Optimization
} // namespace Antares

0 comments on commit 151dedd

Please sign in to comment.