Skip to content

Commit

Permalink
Remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrockm committed Oct 15, 2023
1 parent 3c29d86 commit 0e1153a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 78 deletions.
2 changes: 0 additions & 2 deletions tsplp/include/MtspResult.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,5 @@ class MtspResult
void SetTimeoutHit();
Bounds UpdateUpperBound(double newUpperBound, std::vector<std::vector<size_t>>&& newPaths);
Bounds UpdateLowerBound(double newLowerBound);

void Print() const;
};
}
35 changes: 0 additions & 35 deletions tsplp/src/BranchAndCutQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "Model.hpp"

#include <algorithm>
#include <iostream>

tsplp::BranchAndCutQueue::BranchAndCutQueue(size_t threadCount)
: m_workedOnLowerBounds(threadCount)
Expand Down Expand Up @@ -192,37 +191,3 @@ double tsplp::BranchAndCutQueue::CalculateLowerBound() const

return std::min(lbHeap, lbWorkedOn);
}

void tsplp::BranchAndCutQueue::Print() const
{
std::unique_lock lock { m_mutex };

std::cout << "BranchAndCutQueue:\nHeap:";
for (const auto& [lb, v0, v1, r] : m_heap)
{
std::cout << "LB:" << lb << ", v0:";
for (const auto& v : v0)
std::cout << v.GetId() << ",";
std::cout << " v1:";
for (const auto& v : v1)
std::cout << v.GetId() << ",";
std::cout << " is result: " << r;
std::cout << std::endl;
}

std::cout << "\nworked on LBs: ";
for (size_t i = 0; i < m_workedOnLowerBounds.size(); ++i)
{
if (m_workedOnLowerBounds[i])
{
std::cout << i << ":" << *m_workedOnLowerBounds[i];
}
else
{
std::cout << i << ":<>";
}
std::cout << " ";
}

std::cout << "\nis cleared: " << m_isCleared << std::endl << std::endl;
}
1 change: 0 additions & 1 deletion tsplp/src/BranchAndCutQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class BranchAndCutQueue
double lowerBound, std::vector<Variable> fixedVariables0,
std::vector<Variable> fixedVariables1, Variable branchingVariable,
std::vector<Variable> recursivelyFixed0);
void Print() const;

private:
void NotifyNodeDone(size_t threadId);
Expand Down
34 changes: 2 additions & 32 deletions tsplp/src/MtspModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ void tsplp::MtspModel::BranchAndCutSolve(
queue.Push(0, {}, {});
ConstraintDeque constraints(threadCount);

std::mutex print_mutex;

const auto threadLoop = [&](const size_t threadId)
{
auto model = m_model;
Expand All @@ -322,18 +320,12 @@ void tsplp::MtspModel::BranchAndCutSolve(
if (initialBounds.Lower >= initialBounds.Upper)
{
queue.ClearAll();
std::unique_lock lock { print_mutex };
std::cout << m_name << ": thread " << threadId << " exited because bounds crossed"
<< std::endl;
break;
}

if (std::chrono::steady_clock::now() >= m_endTime)
{
queue.ClearAll();
std::unique_lock lock { print_mutex };
std::cout << m_name << ": thread " << threadId << " exited because timeout"
<< std::endl;
break;
}

Expand All @@ -344,9 +336,6 @@ void tsplp::MtspModel::BranchAndCutSolve(
auto top = queue.Pop(threadId);
if (!top.has_value())
{
std::unique_lock lock { print_mutex };
std::cout << m_name << ": thread " << threadId
<< " exited because Pop returned nothing" << std::endl;
break;
}

Expand Down Expand Up @@ -386,12 +375,7 @@ void tsplp::MtspModel::BranchAndCutSolve(
throw std::logic_error(m_name + ": Unexpected error happened while solving LP.");
case Status::Timeout: // timeout will be handled at the beginning of the next iteration

Check warning on line 376 in tsplp/src/MtspModel.cpp

View check run for this annotation

Codecov / codecov/patch

tsplp/src/MtspModel.cpp#L376

Added line #L376 was not covered by tests
case Status::Infeasible: // fixation of some variable makes this infeasible, skip it
{
std::unique_lock lock { print_mutex };
std::cout << m_name << ", thread " << threadId << ": Infeasible, skipping."
<< std::endl;
continue;
}
case Status::Optimal:
break;
}
Expand Down Expand Up @@ -423,11 +407,6 @@ void tsplp::MtspModel::BranchAndCutSolve(
// trying to improve it further
if (currentLowerBound >= currentUpperBound)
{
std::unique_lock lock { print_mutex };
std::cout << m_name << ", thread " << threadId
<< ": currentLowerBound=" << currentLowerBound
<< " >= currentUpperBound=" << currentUpperBound << " skipping"
<< std::endl;
queue.PushResult(currentLowerBound);
continue;
}
Expand Down Expand Up @@ -507,14 +486,8 @@ void tsplp::MtspModel::BranchAndCutSolve(
currentLowerBound, CreatePathsFromVariables(model));
}

{
std::unique_lock lock { print_mutex };
std::cout << m_name << ", thread " << threadId
<< ": non-fractional solution found: " << currentLowerBound
<< std::endl;
queue.PushResult(currentLowerBound);
continue;
}
queue.PushResult(currentLowerBound);
continue;
}

// As a last resort, split the problem on a fractional variable
Expand All @@ -541,9 +514,6 @@ void tsplp::MtspModel::BranchAndCutSolve(
{
if (std::chrono::steady_clock::now() < m_endTime)
{
std::unique_lock lock { print_mutex };
queue.Print();
m_bestResult.Print();
throw std::logic_error(
m_name + ": Logic Error: Timeout not reached, but no optimal solution found.");
}
Expand Down
8 changes: 0 additions & 8 deletions tsplp/src/MtspResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,4 @@ MtspResult::Bounds MtspResult::UpdateLowerBound(double newLowerBound)

return Bounds { .Lower = m_lowerBound, .Upper = m_upperBound };
}

void MtspResult::Print() const
{
std::unique_lock lock { m_mutex };
std::cout << "MtspResult:\nLB:" << m_lowerBound << " UB:" << m_upperBound
<< " is timeout hit: " << m_isTimeoutHit << std::endl
<< std::endl;
}
}

0 comments on commit 0e1153a

Please sign in to comment.