Skip to content
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 71 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
3423dfc
start Math log
a-zakir Nov 20, 2023
f184ff7
add overloaded method
a-zakir Nov 20, 2023
4cfd573
fix platform specific standard
a-zakir Nov 20, 2023
d3527c4
add MathloggerDriver
a-zakir Nov 20, 2023
d341b1b
print basic data
a-zakir Nov 20, 2023
f28101c
add math logger in benders
a-zakir Nov 20, 2023
3710fbb
Benders take mathlooger
a-zakir Nov 20, 2023
e2e9a91
print maths log
a-zakir Nov 20, 2023
847b9db
add missing include
a-zakir Nov 20, 2023
b2680f0
fix
a-zakir Nov 20, 2023
ef37857
print more data
a-zakir Nov 22, 2023
896fdde
Reset Simplex Iterations Bounds
a-zakir Nov 24, 2023
3616fcf
introducing MathlogImplementation
a-zakir Nov 24, 2023
ff73b89
fix
a-zakir Nov 24, 2023
53adca3
fix
a-zakir Nov 24, 2023
7307b13
ok
a-zakir Nov 24, 2023
707b6e5
set log destination
a-zakir Nov 24, 2023
52984bd
merge fork change (#729)
a-zakir Dec 12, 2023
a2d5b33
fix python typing
a-zakir Dec 12, 2023
4bc7224
Merge branch 'develop' into feature/low-level-logs
a-zakir Dec 12, 2023
71b8f88
writing warning in stdout
a-zakir Dec 12, 2023
815273b
delete useless print
a-zakir Dec 12, 2023
bd0d77f
rename var
a-zakir Dec 12, 2023
6f1f42b
avoid dangling refs
a-zakir Dec 12, 2023
3089987
clarity
a-zakir Dec 12, 2023
e7d74d9
update
a-zakir Dec 12, 2023
e0295d7
test
a-zakir Dec 13, 2023
43435f3
about benders time
a-zakir Dec 13, 2023
2dcc76f
make log headers identical
a-zakir Dec 13, 2023
36f50ab
clean
a-zakir Dec 13, 2023
9313166
add check to Logdestination's stream handler
a-zakir Dec 13, 2023
29b8db2
LogDestinationTest
a-zakir Dec 13, 2023
9314057
test ok
a-zakir Dec 13, 2023
b959f9f
move implementation details
a-zakir Dec 13, 2023
6b9199c
add test
a-zakir Dec 19, 2023
25e590e
Merge branch 'develop' into feature/low-level-logs
a-zakir Dec 19, 2023
f00f769
Merge branch 'develop' into feature/low-level-logs
a-zakir Dec 19, 2023
249319a
test log file content
a-zakir Dec 20, 2023
8e2af9c
fix
a-zakir Dec 20, 2023
9d1bc82
small changes
a-zakir Dec 20, 2023
bc0ab43
test passed
a-zakir Dec 20, 2023
31dd692
test by batch mathlogger headers
a-zakir Dec 20, 2023
7b4c9f4
test bbb LONG headers
a-zakir Dec 20, 2023
acfaf42
HeadersManager test
a-zakir Dec 20, 2023
f48ffa3
HeadersManager completed
a-zakir Dec 20, 2023
ec8f1dd
MathLoggerBendersByBatchTest printed data
a-zakir Dec 20, 2023
7ea33ac
MathLoggerBendersByBatchTest printed datastdout
a-zakir Dec 20, 2023
e8d3564
MathLoggerBendersByBatchTest printed datastdout
a-zakir Dec 20, 2023
a2d6f41
MathLoggerBendersBaseTest
a-zakir Dec 20, 2023
4f40605
windows
a-zakir Dec 20, 2023
fdf3c62
fix parsing of "expert_logs"
a-zakir Dec 21, 2023
ed5e00b
control all logs with log_level option
a-zakir Dec 22, 2023
d77e497
control solver logs
a-zakir Dec 22, 2023
e92292a
benders logs in file: only data
a-zakir Dec 22, 2023
04a69fa
redirect console logs
a-zakir Dec 22, 2023
41bbb64
COIN solver logs only if log_level >1 & log file provided
a-zakir Dec 22, 2023
b6ee322
shorten whitespaces
a-zakir Dec 22, 2023
84bcefc
update doc
a-zakir Dec 22, 2023
10e2a22
delete useless if/else statement
a-zakir Jan 2, 2024
7524e72
remove code duplications
a-zakir Jan 2, 2024
62c8114
fix
a-zakir Jan 2, 2024
136b8cb
Pr remarks
a-zakir Jan 2, 2024
2abbe7d
Pr remarks 2
a-zakir Jan 2, 2024
713d899
units
a-zakir Jan 4, 2024
2d92aff
rename vars
a-zakir Jan 4, 2024
a596298
2 rename vars
a-zakir Jan 4, 2024
bb85059
fix iteration time
a-zakir Jan 4, 2024
fc64ca2
fix
a-zakir Jan 4, 2024
434222f
fix test
a-zakir Jan 4, 2024
fdbfaa2
fix iteration_time
a-zakir Jan 4, 2024
c8ff834
Update docs
tbittar Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/cpp/benders/benders_by_batch/BendersByBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ void BendersByBatch::MasterLoop() {
random_batch_permutation_.size(), rank_0);
SeparationLoop();
if (Rank() == rank_0) {
_data.elapsed_time = GetBendersTime();
_data.iteration_time = -_data.benders_time;
_data.benders_time = GetBendersTime();
_data.iteration_time += _data.benders_time;
_data.stop = ShouldBendersStop();
}
BroadCast(_data.stop, rank_0);
Expand Down Expand Up @@ -310,7 +312,7 @@ double BendersByBatch::Gap() const {
*
*/
void BendersByBatch::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))
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/benders/benders_core/BendersBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,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))
Expand Down Expand Up @@ -650,7 +650,7 @@ 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.cumulative_number_of_subproblem_solved +
Expand Down Expand Up @@ -806,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;
}
Expand Down Expand Up @@ -852,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(); }
Expand Down
10 changes: 5 additions & 5 deletions src/cpp/benders/benders_core/BendersMathLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ HeadersManager::HeadersManager(HEADERSTYPE type, const BENDERSMETHOD& method) {
if (type == HEADERSTYPE::LONG) {
headers_list.push_back("CumulNbSubPbSolv");
}
headers_list.push_back("IteTime");
headers_list.push_back("MasterTime");
headers_list.push_back("SPWallTime");
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");
headers_list.push_back("NotSolvingWallTime");
headers_list.push_back("SPCpuTime (s)");
headers_list.push_back("NotSolvingWallTime (s)");
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/cpp/benders/benders_core/include/BendersStructsDatas.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct CurrentIterationData {
double best_ub;
int deletedcut;
int it;
double iteration_time;
bool stop;
double overall_subpb_cost_under_approx;
std::vector<double> single_subpb_costs_under_approx;
Expand All @@ -28,7 +29,7 @@ struct CurrentIterationData {
Point max_invest;
int nsubproblem;
int master_status;
double elapsed_time;
double benders_time;
StoppingCriterion stopping_criterion;
bool is_in_initial_relaxation;
int number_of_subproblem_solved;
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/benders/benders_mpi/BendersMPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ void BendersMpi::step_4_update_best_solution(int rank) {
_logger->log_at_iteration_end(bendersDataToLogData(_data));

UpdateTrace();
_data.elapsed_time = GetBendersTime();
_data.iteration_time = -_data.benders_time;
_data.benders_time = GetBendersTime();
_data.iteration_time += _data.benders_time;
_data.stop = ShouldBendersStop();
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/cpp/benders/benders_sequential/BendersSequential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ void BendersSequential::Run() {
UpdateTrace();

set_timer_master(timer_master.elapsed());
_data.elapsed_time = GetBendersTime();
_data.iteration_time = -_data.benders_time;
_data.benders_time = GetBendersTime();
_data.iteration_time += _data.benders_time;
_data.stop = ShouldBendersStop();
SaveCurrentBendersData();
}
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/benders/logger/MathLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <iomanip>
#include <sstream>

double getDurationNotSolving(double interation, double master,
double getDurationNotSolving(double iteration, double master,
double subproblems) {
return interation - master - subproblems;
return iteration - master - subproblems;
}

void MathLoggerBase::setHeadersList() {
Expand Down Expand Up @@ -41,15 +41,15 @@ void PrintData(LogDestination& log_destination,
log_destination << data.cumulative_number_of_subproblem_solved;
}

log_destination << std::setprecision(2) << data.elapsed_time;
log_destination << std::setprecision(2) << data.benders_time;
tbittar marked this conversation as resolved.
Show resolved Hide resolved
log_destination << std::setprecision(2) << data.timer_master;
log_destination << std::setprecision(2) << data.subproblems_walltime;

if (type == HEADERSTYPE::LONG) {
log_destination << std::setprecision(2)
<< data.subproblems_cumulative_cputime;
log_destination << std::setprecision(2)
<< getDurationNotSolving(data.elapsed_time,
<< getDurationNotSolving(data.iteration_time,
data.timer_master,
data.subproblems_walltime);
}
Expand Down
50 changes: 25 additions & 25 deletions tests/cpp/logger/logger_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,11 @@ TEST(MathLoggerHeadersManagerTest, LongBenders) {
"MaxSpx",
"NbSubPbSolv",
"CumulNbSubPbSolv",
"IteTime",
"MasterTime",
"SPWallTime",
"SPCpuTime",
"NotSolvingWallTime"};
"IteTime (s)",
"MasterTime (s)",
"SPWallTime (s)",
"SPCpuTime (s)",
"NotSolvingWallTime (s)"};
ASSERT_EQ(expected_headers, headers_manager.headers_list);
}

Expand All @@ -821,7 +821,7 @@ TEST(MathLoggerHeadersManagerTest, ShortBenders) {

std::vector<std::string> expected_headers = {
"Ite", "Lb", "Ub", "BestUb", "AbsGap", "RelGap",
"MinSpx", "MaxSpx", "IteTime", "MasterTime", "SPWallTime"};
"MinSpx", "MaxSpx", "IteTime (s)", "MasterTime (s)", "SPWallTime (s)"};
ASSERT_EQ(expected_headers, headers_manager.headers_list);
}

Expand All @@ -835,11 +835,11 @@ TEST(MathLoggerHeadersManagerTest, LongBendersByBatch) {
"MaxSpx",
"NbSubPbSolv",
"CumulNbSubPbSolv",
"IteTime",
"MasterTime",
"SPWallTime",
"SPCpuTime",
"NotSolvingWallTime"};
"IteTime (s)",
"MasterTime (s)",
"SPWallTime (s)",
"SPCpuTime (s)",
"NotSolvingWallTime (s)"};
ASSERT_EQ(expected_headers, headers_manager.headers_list);
}

Expand All @@ -849,7 +849,7 @@ TEST(MathLoggerHeadersManagerTest, ShortBendersByBatch) {

std::vector<std::string> expected_headers = {
"Ite", "Lb", "MinSpx", "MaxSpx",
"NbSubPbSolv", "IteTime", "MasterTime", "SPWallTime"};
"NbSubPbSolv", "IteTime (s)", "MasterTime (s)", "SPWallTime (s)"};
ASSERT_EQ(expected_headers, headers_manager.headers_list);
}

Expand Down Expand Up @@ -903,12 +903,12 @@ TEST(MathLoggerBendersByBatchTest, DataInFileLong) {
data.max_simplexiter = 30;
data.number_of_subproblem_solved = 657;
data.cumulative_number_of_subproblem_solved = 1387;
data.elapsed_time = 1000;
data.benders_time = 1000;
data.timer_master = 10;
data.subproblems_walltime = 16;
data.subproblems_cumulative_cputime = 160;
auto time_not_solving =
data.elapsed_time - data.timer_master - data.subproblems_walltime;
data.benders_time - data.timer_master - data.subproblems_walltime;

std::ostringstream expected_msg;
expected_msg << std::left << std::setw(width) << data.it;
Expand All @@ -922,7 +922,7 @@ TEST(MathLoggerBendersByBatchTest, DataInFileLong) {
expected_msg << std::left << std::setw(width)
<< data.cumulative_number_of_subproblem_solved;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.elapsed_time;
<< data.benders_time;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.timer_master;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
Expand Down Expand Up @@ -954,12 +954,12 @@ TEST(MathLoggerBendersByBatchTest, DataInStdOutShort) {
data.max_simplexiter = 30;
data.number_of_subproblem_solved = 657;
data.cumulative_number_of_subproblem_solved = 1387;
data.elapsed_time = 1000;
data.benders_time = 1000;
data.timer_master = 10;
data.subproblems_walltime = 16;
data.subproblems_cumulative_cputime = 160;
auto time_not_solving =
data.elapsed_time - data.timer_master - data.subproblems_walltime;
data.benders_time - data.timer_master - data.subproblems_walltime;

std::ostringstream expected_msg;
expected_msg << std::left << std::setw(width) << data.it;
Expand All @@ -971,7 +971,7 @@ TEST(MathLoggerBendersByBatchTest, DataInStdOutShort) {
<< data.number_of_subproblem_solved;

expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.elapsed_time;
<< data.benders_time;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.timer_master;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
Expand Down Expand Up @@ -1000,12 +1000,12 @@ TEST(MathLoggerBendersBaseTest, DataInFileLong) {
data.max_simplexiter = 30;
data.number_of_subproblem_solved = 657;
data.cumulative_number_of_subproblem_solved = 1387;
data.elapsed_time = 1000;
data.benders_time = 1000;
data.timer_master = 10;
data.subproblems_walltime = 16;
data.subproblems_cumulative_cputime = 160;
auto time_not_solving =
data.elapsed_time - data.timer_master - data.subproblems_walltime;
data.benders_time - data.timer_master - data.subproblems_walltime;

std::ostringstream expected_msg;
expected_msg << std::left << std::setw(width) << data.it;
Expand All @@ -1028,7 +1028,7 @@ TEST(MathLoggerBendersBaseTest, DataInFileLong) {
expected_msg << std::left << std::setw(width)
<< data.cumulative_number_of_subproblem_solved;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.elapsed_time;
<< data.benders_time;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.timer_master;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
Expand Down Expand Up @@ -1060,12 +1060,12 @@ TEST(MathLoggerBendersBaseTest, DataInStdOutShort) {
data.max_simplexiter = 30;
data.number_of_subproblem_solved = 657;
data.cumulative_number_of_subproblem_solved = 1387;
data.elapsed_time = 1000;
data.benders_time = 1000;
data.timer_master = 10;
data.subproblems_walltime = 16;
data.subproblems_cumulative_cputime = 160;
auto time_not_solving =
data.elapsed_time - data.timer_master - data.subproblems_walltime;
data.benders_time - data.timer_master - data.subproblems_walltime;

std::ostringstream expected_msg;
expected_msg << std::left << std::setw(width) << data.it;
Expand All @@ -1085,7 +1085,7 @@ TEST(MathLoggerBendersBaseTest, DataInStdOutShort) {
expected_msg << std::left << std::setw(width) << data.max_simplexiter;

expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.elapsed_time;
<< data.benders_time;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
<< data.timer_master;
expected_msg << std::left << std::setw(width) << std::setprecision(2)
Expand All @@ -1099,4 +1099,4 @@ TEST(MathLoggerBendersBaseTest, DataInStdOutShort) {
std::cout.rdbuf(initialBufferCout);

ASSERT_EQ(expected_msg.str(), redirectedStdout.str());
}
}
Loading