Skip to content

Commit

Permalink
Fix double comparisons in solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed Oct 8, 2024
1 parent 804d8d6 commit 3c48950
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/onedimensional/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ bool Solution::operator<(const Solution& solution) const
return true;
return solution.waste() < waste();
} case Objective::Knapsack: {
return solution.profit() > profit();
return strictly_greater(solution.profit(), profit());
} case Objective::VariableSizedBinPacking: {
if (!solution.full())
return false;
if (!full())
return true;
return solution.cost() < cost();
return strictly_lesser(solution.cost(), cost());
} default: {
std::stringstream ss;
ss << "Solution onedimensional::Solution does not support objective \""
Expand Down
10 changes: 5 additions & 5 deletions src/rectangle/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ bool Solution::operator<(const Solution& solution) const
return true;
if (solution.number_of_bins() != number_of_bins())
return solution.number_of_bins() < number_of_bins();
return solution.leftover_value() > leftover_value();
return strictly_greater(solution.leftover_value(), leftover_value());
} case Objective::OpenDimensionX: {
if (!solution.full())
return false;
Expand All @@ -257,16 +257,16 @@ bool Solution::operator<(const Solution& solution) const
return true;
return solution.y_max() < y_max();
} case Objective::Knapsack: {
return solution.profit() > profit();
return strictly_greater(solution.profit(), profit());
} case Objective::VariableSizedBinPacking: {
if (!solution.full())
return false;
if (!full())
return true;
return solution.cost() < cost();
return strictly_lesser(solution.cost(), cost());
} case Objective::SequentialOneDimensionalRectangleSubproblem: {
if (solution.profit() != profit())
return solution.profit() > profit();
if (!equal(solution.profit(), profit()))
return strictly_greater(solution.profit(), profit());
if (solution.middle_axle_overweight() + solution.rear_axle_overweight()
!= middle_axle_overweight() + rear_axle_overweight())
return solution.middle_axle_overweight() + solution.rear_axle_overweight()
Expand Down
4 changes: 2 additions & 2 deletions src/rectangleguillotine/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ bool Solution::operator<(const Solution& solution) const
return true;
return solution.height() < height();
} case Objective::Knapsack: {
return solution.profit() > profit();
return strictly_greater(solution.profit(), profit());
} case Objective::VariableSizedBinPacking: {
if (!solution.full())
return false;
if (!full())
return true;
return solution.cost() < cost();
return strictly_lesser(solution.cost(), cost());
} default: {
std::stringstream ss;
ss << "Solution rectangleguillotine::Solution does not support objective \""
Expand Down

0 comments on commit 3c48950

Please sign in to comment.