-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
print low level logs #719
Merged
Merged
print low level logs #719
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
3423dfc
start Math log
a-zakir f184ff7
add overloaded method
a-zakir 4cfd573
fix platform specific standard
a-zakir d3527c4
add MathloggerDriver
a-zakir d341b1b
print basic data
a-zakir f28101c
add math logger in benders
a-zakir 3710fbb
Benders take mathlooger
a-zakir e2e9a91
print maths log
a-zakir 847b9db
add missing include
a-zakir b2680f0
fix
a-zakir ef37857
print more data
a-zakir 896fdde
Reset Simplex Iterations Bounds
a-zakir 3616fcf
introducing MathlogImplementation
a-zakir ff73b89
fix
a-zakir 53adca3
fix
a-zakir 7307b13
ok
a-zakir 707b6e5
set log destination
a-zakir 52984bd
merge fork change (#729)
a-zakir a2d5b33
fix python typing
a-zakir 4bc7224
Merge branch 'develop' into feature/low-level-logs
a-zakir 71b8f88
writing warning in stdout
a-zakir 815273b
delete useless print
a-zakir bd0d77f
rename var
a-zakir 6f1f42b
avoid dangling refs
a-zakir 3089987
clarity
a-zakir e7d74d9
update
a-zakir e0295d7
test
a-zakir 43435f3
about benders time
a-zakir 2dcc76f
make log headers identical
a-zakir 36f50ab
clean
a-zakir 9313166
add check to Logdestination's stream handler
a-zakir 29b8db2
LogDestinationTest
a-zakir 9314057
test ok
a-zakir b959f9f
move implementation details
a-zakir 6b9199c
add test
a-zakir 25e590e
Merge branch 'develop' into feature/low-level-logs
a-zakir f00f769
Merge branch 'develop' into feature/low-level-logs
a-zakir 249319a
test log file content
a-zakir 8e2af9c
fix
a-zakir 9d1bc82
small changes
a-zakir bc0ab43
test passed
a-zakir 31dd692
test by batch mathlogger headers
a-zakir 7b4c9f4
test bbb LONG headers
a-zakir acfaf42
HeadersManager test
a-zakir f48ffa3
HeadersManager completed
a-zakir ec8f1dd
MathLoggerBendersByBatchTest printed data
a-zakir 7ea33ac
MathLoggerBendersByBatchTest printed datastdout
a-zakir e8d3564
MathLoggerBendersByBatchTest printed datastdout
a-zakir a2d6f41
MathLoggerBendersBaseTest
a-zakir 4f40605
windows
a-zakir fdf3c62
fix parsing of "expert_logs"
a-zakir ed5e00b
control all logs with log_level option
a-zakir d77e497
control solver logs
a-zakir e92292a
benders logs in file: only data
a-zakir 04a69fa
redirect console logs
a-zakir 41bbb64
COIN solver logs only if log_level >1 & log file provided
a-zakir b6ee322
shorten whitespaces
a-zakir 84bcefc
update doc
a-zakir 10e2a22
delete useless if/else statement
a-zakir 7524e72
remove code duplications
a-zakir 62c8114
fix
a-zakir 136b8cb
Pr remarks
a-zakir 2abbe7d
Pr remarks 2
a-zakir 713d899
units
a-zakir 2d92aff
rename vars
a-zakir a596298
2 rename vars
a-zakir bb85059
fix iteration time
a-zakir fc64ca2
fix
a-zakir 434222f
fix test
a-zakir fdbfaa2
fix iteration_time
a-zakir c8ff834
Update docs
tbittar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,14 @@ | |
#include "solver_utils.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR contains console logs. Please review or remove them. |
||
|
||
BendersBase::BendersBase(BendersBaseOptions options, Logger logger, | ||
Writer writer) | ||
Writer writer, | ||
std::shared_ptr<MathLoggerDriver> mathLoggerDriver) | ||
: _options(std::move(options)), | ||
_csv_file_path(std::filesystem::path(_options.OUTPUTROOT) / | ||
(_options.CSV_NAME + ".csv")), | ||
_logger(std::move(logger)), | ||
_writer(std::move(writer)) {} | ||
_writer(std::move(writer)), | ||
mathLoggerDriver_(mathLoggerDriver) {} | ||
|
||
/*! | ||
* \brief Initialize set of data used in the loop | ||
|
@@ -34,7 +36,7 @@ void BendersBase::init_data() { | |
_data.best_it = 0; | ||
_data.stopping_criterion = StoppingCriterion::empty; | ||
_data.is_in_initial_relaxation = false; | ||
_data.number_of_subproblem_resolved = 0; | ||
_data.cumulative_number_of_subproblem_solved = 0; | ||
} | ||
|
||
void BendersBase::OpenCsvFile() { | ||
|
@@ -177,7 +179,7 @@ bool BendersBase::ShouldRelaxationStop() const { | |
* | ||
*/ | ||
void BendersBase::UpdateStoppingCriterion() { | ||
if (_data.elapsed_time > _options.TIME_LIMIT) | ||
if (_data.benders_time > _options.TIME_LIMIT) | ||
_data.stopping_criterion = StoppingCriterion::timelimit; | ||
else if ((_options.MAX_ITERATIONS != -1) && | ||
(_data.it >= _options.MAX_ITERATIONS)) | ||
|
@@ -467,7 +469,7 @@ LogData BendersBase::FinalLogData() const { | |
result.subproblem_cost = best_iteration_data.subproblem_cost; | ||
result.invest_cost = best_iteration_data.invest_cost; | ||
result.cumulative_number_of_subproblem_resolved = | ||
_data.number_of_subproblem_resolved + | ||
_data.cumulative_number_of_subproblem_solved + | ||
cumulative_number_of_subproblem_resolved_before_resume; | ||
|
||
return result; | ||
|
@@ -525,7 +527,7 @@ Output::Iteration BendersBase::iteration( | |
masterDataPtr_l->_invest_cost + masterDataPtr_l->_operational_cost; | ||
iteration.candidates = candidates_data(masterDataPtr_l); | ||
iteration.cumulative_number_of_subproblem_resolved = | ||
_data.number_of_subproblem_resolved + | ||
_data.cumulative_number_of_subproblem_solved + | ||
cumulative_number_of_subproblem_resolved_before_resume; | ||
return iteration; | ||
} | ||
|
@@ -648,10 +650,10 @@ LogData BendersBase::bendersDataToLogData( | |
optimal_gap, | ||
optimal_gap / data.best_ub, | ||
_options.MAX_ITERATIONS, | ||
data.elapsed_time, | ||
data.benders_time, | ||
data.timer_master, | ||
data.subproblems_walltime, | ||
data.number_of_subproblem_resolved + | ||
data.cumulative_number_of_subproblem_solved + | ||
cumulative_number_of_subproblem_resolved_before_resume}; | ||
} | ||
void BendersBase::set_solver_log_file(const std::filesystem::path &log_file) { | ||
|
@@ -772,6 +774,24 @@ void BendersBase::SetSubproblemCost(const double &subproblem_cost) { | |
_data.subproblem_cost = subproblem_cost; | ||
} | ||
|
||
/*! | ||
* \brief Update maximum and minimum of simplex iterations | ||
* | ||
* \param subproblem_iterations : number of iterations done with the subproblem | ||
* | ||
*/ | ||
void BendersBase::BoundSimplexIterations(int subproblem_iterations){ | ||
|
||
_data.max_simplexiter = (_data.max_simplexiter < subproblem_iterations) ? subproblem_iterations : _data.max_simplexiter; | ||
_data.min_simplexiter = (_data.min_simplexiter > subproblem_iterations) ? subproblem_iterations : _data.min_simplexiter; | ||
|
||
} | ||
|
||
void BendersBase::ResetSimplexIterationsBounds() | ||
{ | ||
_data.max_simplexiter = 0; | ||
_data.min_simplexiter = std::numeric_limits<int>::max(); | ||
} | ||
bool BendersBase::IsResumeMode() const { return _options.RESUME; } | ||
|
||
void BendersBase::UpdateMaxNumberIterationResumeMode( | ||
|
@@ -786,7 +806,7 @@ void BendersBase::UpdateMaxNumberIterationResumeMode( | |
} | ||
} | ||
|
||
double BendersBase::execution_time() const { return _data.elapsed_time; } | ||
double BendersBase::execution_time() const { return _data.benders_time; } | ||
LogData BendersBase::GetBestIterationData() const { | ||
return best_iteration_data; | ||
} | ||
|
@@ -832,7 +852,7 @@ void BendersBase::ClearCurrentIterationCutTrace() const { | |
} | ||
void BendersBase::EndWritingInOutputFile() const { | ||
_writer->updateEndTime(); | ||
_writer->write_duration(_data.elapsed_time); | ||
_writer->write_duration(_data.benders_time); | ||
SaveSolutionInOutputFile(); | ||
} | ||
double BendersBase::GetBendersTime() const { return benders_timer.elapsed(); } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "BendersMathLogger.h" | ||
JasonMarechal25 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include "LogUtils.h" | ||
#include "LoggerUtils.h" | ||
|
||
HeadersManager::HeadersManager(HEADERSTYPE type, const BENDERSMETHOD& method) { | ||
headers_list.push_back("Ite"); | ||
headers_list.push_back("Lb"); | ||
if (method == BENDERSMETHOD::BENDERS) { | ||
headers_list.push_back("Ub"); | ||
headers_list.push_back("BestUb"); | ||
headers_list.push_back("AbsGap"); | ||
headers_list.push_back("RelGap"); | ||
} | ||
a-zakir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
headers_list.push_back("MinSpx"); | ||
headers_list.push_back("MaxSpx"); | ||
|
||
if (type == HEADERSTYPE::LONG || method == BENDERSMETHOD::BENDERSBYBATCH) { | ||
headers_list.push_back("NbSubPbSolv"); | ||
} | ||
|
||
if (type == HEADERSTYPE::LONG) { | ||
headers_list.push_back("CumulNbSubPbSolv"); | ||
} | ||
headers_list.push_back("IteTime (s)"); | ||
headers_list.push_back("MasterTime (s)"); | ||
headers_list.push_back("SPWallTime (s)"); | ||
if (type == HEADERSTYPE::LONG) { | ||
headers_list.push_back("SPCpuTime (s)"); | ||
headers_list.push_back("NotSolvingWallTime (s)"); | ||
} | ||
} | ||
|
||
LogDestination::LogDestination(std::streamsize width) | ||
: stream_(&std::cout), width_(width) { | ||
(*stream_) << std::unitbuf; | ||
} | ||
|
||
LogDestination::LogDestination(const std::filesystem::path& file_path, | ||
std::streamsize width) | ||
: width_(width) { | ||
file_stream_.open(file_path, std::ofstream::out | std::ofstream::trunc); | ||
if (file_stream_.is_open()) { | ||
stream_ = &file_stream_; | ||
(*stream_) << std::unitbuf; | ||
} else { | ||
std::ostringstream err_msg; | ||
err_msg << PrefixMessage(LogUtils::LOGLEVEL::WARNING, MATHLOGGERCONTEXT) | ||
<< "Could not open the file: " | ||
<< std::quoted(file_path.string().c_str()) << "\n"; | ||
std::cerr << err_msg.str(); | ||
} | ||
} | ||
void MathLoggerDriver::add_logger( | ||
std::shared_ptr<MathLoggerImplementation> logger) { | ||
if (logger) { | ||
math_loggers_.push_back(logger); | ||
} | ||
} | ||
|
||
void MathLoggerDriver::Print(const CurrentIterationData& data) { | ||
for (auto logger : math_loggers_) { | ||
logger->Print(data); | ||
} | ||
} | ||
|
||
void MathLoggerDriver::write_header() { | ||
for (auto logger : math_loggers_) { | ||
logger->write_header(); | ||
} | ||
} | ||
|
||
void MathLoggerDriver::display_message(const std::string& str) { | ||
for (auto logger : math_loggers_) { | ||
logger->display_message(str); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR contains console logs. Please review or remove them.