From 2ef89ae3b860f5c8cc58fdb9287716459c1cd29b Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 16 Jul 2025 20:47:06 +0200 Subject: [PATCH 1/2] Move the sample bin-packing solver from `algorithms` to `set_cover`, the only place it is used. The main reason is that we have several solvers, including some being open-sourced, in the `packing/` folder. --- ortools/{algorithms => set_cover/samples}/bin_packing.cc | 2 +- ortools/{algorithms => set_cover/samples}/bin_packing.h | 6 +++--- .../{algorithms => set_cover}/samples/bin_packing_cft.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename ortools/{algorithms => set_cover/samples}/bin_packing.cc (99%) rename ortools/{algorithms => set_cover/samples}/bin_packing.h (97%) rename ortools/{algorithms => set_cover}/samples/bin_packing_cft.cc (98%) diff --git a/ortools/algorithms/bin_packing.cc b/ortools/set_cover/samples/bin_packing.cc similarity index 99% rename from ortools/algorithms/bin_packing.cc rename to ortools/set_cover/samples/bin_packing.cc index 0f512b131b..20ff1361c1 100644 --- a/ortools/algorithms/bin_packing.cc +++ b/ortools/set_cover/samples/bin_packing.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "ortools/algorithms/bin_packing.h" +#include "ortools/set_cover/samples/bin_packing.h" #include #include diff --git a/ortools/algorithms/bin_packing.h b/ortools/set_cover/samples/bin_packing.h similarity index 97% rename from ortools/algorithms/bin_packing.h rename to ortools/set_cover/samples/bin_packing.h index 17ce141784..0b9e7c367f 100644 --- a/ortools/algorithms/bin_packing.h +++ b/ortools/set_cover/samples/bin_packing.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef OR_TOOLS_ORTOOLS_ALGORITHMS_BIN_PACKING_H -#define OR_TOOLS_ORTOOLS_ALGORITHMS_BIN_PACKING_H +#ifndef OR_TOOLS_ORTOOLS_SET_COVER_SAMPLES_BIN_PACKING_H +#define OR_TOOLS_ORTOOLS_SET_COVER_SAMPLES_BIN_PACKING_H #include #include @@ -177,4 +177,4 @@ void AddRandomizedBins(const BinPackingModel& model, BaseInt num_bins, BinPackingSetCoverModel& scp_model, std::mt19937& rnd); } // namespace operations_research -#endif /* OR_TOOLS_ORTOOLS_ALGORITHMS_BIN_PACKING_H */ +#endif /* OR_TOOLS_ORTOOLS_SET_COVER_SAMPLES_BIN_PACKING_H */ diff --git a/ortools/algorithms/samples/bin_packing_cft.cc b/ortools/set_cover/samples/bin_packing_cft.cc similarity index 98% rename from ortools/algorithms/samples/bin_packing_cft.cc rename to ortools/set_cover/samples/bin_packing_cft.cc index 0eafd47416..68fc436bdb 100644 --- a/ortools/algorithms/samples/bin_packing_cft.cc +++ b/ortools/set_cover/samples/bin_packing_cft.cc @@ -18,10 +18,10 @@ #include #include -#include "ortools/algorithms/bin_packing.h" #include "ortools/base/init_google.h" #include "ortools/set_cover/base_types.h" #include "ortools/set_cover/set_cover_cft.h" +#include "ortools/set_cover/samples/bin_packing.h" using namespace operations_research; ABSL_FLAG(std::string, instance, "", "BPP instance int RAIL format."); From 1f042bf9b42a29e358897bf44c6802166a5e8d02 Mon Sep 17 00:00:00 2001 From: Mizux Seiha Date: Tue, 15 Jul 2025 23:13:47 +0200 Subject: [PATCH 2/2] cleanup bin_packing_cft --- ortools/set_cover/samples/bin_packing.cc | 6 +++--- ortools/set_cover/samples/bin_packing.h | 4 ++-- ortools/set_cover/samples/bin_packing_cft.cc | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ortools/set_cover/samples/bin_packing.cc b/ortools/set_cover/samples/bin_packing.cc index 20ff1361c1..c89a8ee4db 100644 --- a/ortools/set_cover/samples/bin_packing.cc +++ b/ortools/set_cover/samples/bin_packing.cc @@ -37,10 +37,10 @@ void BinPackingModel::set_bin_capacity(Cost capacity) { LOG(WARNING) << "Bin capacity must be positive."; return; } - bin_capcaity_ = capacity; + bin_capacity_ = capacity; } void BinPackingModel::AddItem(Cost weight) { - if (weight > bin_capcaity_) { + if (weight > bin_capacity_) { LOG(WARNING) << "Element weight exceeds bin capacity."; return; } @@ -259,7 +259,7 @@ void AddRandomizedBins(const BinPackingModel& model, BaseInt num_bins, items.push_back(n); if (unique_bin_num == scp_model.full_model().num_subsets()) { - VLOG(1) << "No new bins generated."; + LOG(INFO) << "No new bins generated."; break; } } diff --git a/ortools/set_cover/samples/bin_packing.h b/ortools/set_cover/samples/bin_packing.h index 0b9e7c367f..5bdba77135 100644 --- a/ortools/set_cover/samples/bin_packing.h +++ b/ortools/set_cover/samples/bin_packing.h @@ -33,7 +33,7 @@ class BinPackingModel { public: BinPackingModel() = default; BaseInt num_items() const { return weigths_.size(); } - Cost bin_capacity() const { return bin_capcaity_; } + Cost bin_capacity() const { return bin_capacity_; } void set_bin_capacity(Cost capacity); const ElementCostVector& weights() const { return weigths_; } void AddItem(Cost weight); @@ -44,7 +44,7 @@ class BinPackingModel { private: bool is_sorted_ = false; - Cost bin_capcaity_ = .0; + Cost bin_capacity_ = .0; ElementCostVector weigths_ = {}; }; diff --git a/ortools/set_cover/samples/bin_packing_cft.cc b/ortools/set_cover/samples/bin_packing_cft.cc index 68fc436bdb..4a311d71e1 100644 --- a/ortools/set_cover/samples/bin_packing_cft.cc +++ b/ortools/set_cover/samples/bin_packing_cft.cc @@ -95,7 +95,7 @@ void KnapsackTest() { int main(int argc, char** argv) { InitGoogle(argv[0], &argc, &argv, true); - + absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); // KnapsackTest(); // return 0; @@ -141,4 +141,4 @@ int main(int argc, char** argv) { } return EXIT_SUCCESS; -} \ No newline at end of file +}