From d17606daa5a00318f87fcbd69159542a48ab138c Mon Sep 17 00:00:00 2001 From: Sebastian Brockmeyer <937096+sebrockm@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:39:16 +0200 Subject: [PATCH] TMP: better logging --- tsplp/src/BranchAndCutQueue.cpp | 7 +++---- tsplp/src/MtspModel.cpp | 13 +++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tsplp/src/BranchAndCutQueue.cpp b/tsplp/src/BranchAndCutQueue.cpp index f440dc5..e08cd1d 100644 --- a/tsplp/src/BranchAndCutQueue.cpp +++ b/tsplp/src/BranchAndCutQueue.cpp @@ -184,7 +184,7 @@ void tsplp::BranchAndCutQueue::Print() const std::cout << std::endl; } - std::cout << "worked on LBs: "; + std::cout << "\nworked on LBs: "; for (size_t i = 0; i < m_workedOnLowerBounds.size(); ++i) { if (m_workedOnLowerBounds[i]) @@ -195,9 +195,8 @@ void tsplp::BranchAndCutQueue::Print() const { std::cout << i << ":<>"; } - - std::cout << std::endl; + std::cout << " "; } - std::cout << "is cleared: " << m_isCleared << std::endl << std::endl; + std::cout << "\nis cleared: " << m_isCleared << std::endl << std::endl; } diff --git a/tsplp/src/MtspModel.cpp b/tsplp/src/MtspModel.cpp index f51420e..24f0c60 100644 --- a/tsplp/src/MtspModel.cpp +++ b/tsplp/src/MtspModel.cpp @@ -316,10 +316,17 @@ void tsplp::MtspModel::BranchAndCutSolve( { const auto initialBounds = m_bestResult.UpdateLowerBound(queue.GetLowerBound()); - if (std::chrono::steady_clock::now() >= m_endTime - || initialBounds.Lower >= initialBounds.Upper) + if (initialBounds.Lower >= initialBounds.Upper) { queue.ClearAll(); + std::cout << "thread " << threadId << " exited because bounds crossed" << std::endl; + break; + } + + if (std::chrono::steady_clock::now() >= m_endTime) + { + queue.ClearAll(); + std::cout << "thread " << threadId << " exited because timeout" << std::endl; break; } @@ -330,6 +337,8 @@ void tsplp::MtspModel::BranchAndCutSolve( auto top = queue.Pop(threadId); if (!top.has_value()) { + std::cout << "thread " << threadId << " exited because Pop returned nothing" + << std::endl; break; }