From 9aa3687319aeffe02cd71c596c929e4ad8d1deb3 Mon Sep 17 00:00:00 2001 From: Florian Fontan Date: Thu, 18 Apr 2024 23:44:12 +0200 Subject: [PATCH 1/6] Add missing read of optimization-mode option in onedimensional --- packingsolver/onedimensional/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packingsolver/onedimensional/main.cpp b/packingsolver/onedimensional/main.cpp index a91021827..e13e34137 100644 --- a/packingsolver/onedimensional/main.cpp +++ b/packingsolver/onedimensional/main.cpp @@ -133,6 +133,8 @@ int main(int argc, char *argv[]) OptimizeParameters parameters; read_args(parameters, vm); + if (vm.count("optimization-mode")) + parameters.optimization_mode = vm["optimization-mode"].as(); if (vm.count("use-tree-search")) parameters.use_tree_search = vm["use-tree-search"].as(); From a83363c1d32a379103c795acce93eb44faab68a0 Mon Sep 17 00:00:00 2001 From: Florian Fontan Date: Thu, 18 Apr 2024 23:45:06 +0200 Subject: [PATCH 2/6] Rename beam_size into queue_size --- packingsolver/onedimensional/optimize.cpp | 4 ++-- packingsolver/onedimensional/optimize.hpp | 2 +- packingsolver/rectangle/optimize.cpp | 4 ++-- packingsolver/rectangle/optimize.hpp | 2 +- packingsolver/rectangleguillotine/optimize.cpp | 4 ++-- packingsolver/rectangleguillotine/optimize.hpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packingsolver/onedimensional/optimize.cpp b/packingsolver/onedimensional/optimize.cpp index a056e3184..d88d05b1b 100644 --- a/packingsolver/onedimensional/optimize.cpp +++ b/packingsolver/onedimensional/optimize.cpp @@ -121,7 +121,7 @@ void optimize_sequential_single_knapsack( for (Counter queue_size = 1;;) { if (parameters.optimization_mode != OptimizationMode::Anytime) - queue_size = parameters.not_anytime_dichotomic_search_subproblem_beam_size; + queue_size = parameters.not_anytime_dichotomic_search_subproblem_queue_size; SequentialValueCorrectionFunction kp_solve = [¶meters, &queue_size](const Instance& kp_instance) @@ -212,7 +212,7 @@ void optimize_dichotomic_search( for (Counter queue_size = 1;;) { if (parameters.optimization_mode != OptimizationMode::Anytime) - queue_size = parameters.not_anytime_dichotomic_search_subproblem_beam_size; + queue_size = parameters.not_anytime_dichotomic_search_subproblem_queue_size; DichotomicSearchFunction bpp_solve = [¶meters, &queue_size](const Instance& bpp_instance) diff --git a/packingsolver/onedimensional/optimize.hpp b/packingsolver/onedimensional/optimize.hpp index e6c4f3377..5bc01eb02 100644 --- a/packingsolver/onedimensional/optimize.hpp +++ b/packingsolver/onedimensional/optimize.hpp @@ -85,7 +85,7 @@ struct OptimizeParameters: packingsolver::Parameters * Size of the queue in the bin packing subproblem of the dichotomic search * algorithm. */ - NodeId not_anytime_dichotomic_search_subproblem_beam_size = 256; + NodeId not_anytime_dichotomic_search_subproblem_queue_size = 256; }; const Output optimize( diff --git a/packingsolver/rectangle/optimize.cpp b/packingsolver/rectangle/optimize.cpp index b1dff1740..40830c0c0 100644 --- a/packingsolver/rectangle/optimize.cpp +++ b/packingsolver/rectangle/optimize.cpp @@ -144,7 +144,7 @@ void optimize_sequential_single_knapsack( for (Counter queue_size = 1;;) { if (parameters.optimization_mode != OptimizationMode::Anytime) - queue_size = parameters.not_anytime_dichotomic_search_subproblem_beam_size; + queue_size = parameters.not_anytime_dichotomic_search_subproblem_queue_size; SequentialValueCorrectionFunction kp_solve = [¶meters, &queue_size](const Instance& kp_instance) @@ -235,7 +235,7 @@ void optimize_dichotomic_search( for (Counter queue_size = 1;;) { if (parameters.optimization_mode != OptimizationMode::Anytime) - queue_size = parameters.not_anytime_dichotomic_search_subproblem_beam_size; + queue_size = parameters.not_anytime_dichotomic_search_subproblem_queue_size; DichotomicSearchFunction bpp_solve = [¶meters, &queue_size](const Instance& bpp_instance) diff --git a/packingsolver/rectangle/optimize.hpp b/packingsolver/rectangle/optimize.hpp index b306d8179..4fec168b0 100644 --- a/packingsolver/rectangle/optimize.hpp +++ b/packingsolver/rectangle/optimize.hpp @@ -88,7 +88,7 @@ struct OptimizeParameters: packingsolver::Parameters * Size of the queue in the bin packing subproblem of the dichotomic search * algorithm. */ - NodeId not_anytime_dichotomic_search_subproblem_beam_size = 1024; + NodeId not_anytime_dichotomic_search_subproblem_queue_size = 1024; }; const Output optimize( diff --git a/packingsolver/rectangleguillotine/optimize.cpp b/packingsolver/rectangleguillotine/optimize.cpp index 77e26c262..c15dcffdc 100644 --- a/packingsolver/rectangleguillotine/optimize.cpp +++ b/packingsolver/rectangleguillotine/optimize.cpp @@ -130,7 +130,7 @@ void optimize_sequential_single_knapsack( for (Counter queue_size = 1;;) { if (parameters.optimization_mode != OptimizationMode::Anytime) - queue_size = parameters.not_anytime_dichotomic_search_subproblem_beam_size; + queue_size = parameters.not_anytime_dichotomic_search_subproblem_queue_size; SequentialValueCorrectionFunction kp_solve = [¶meters, &queue_size](const Instance& kp_instance) @@ -221,7 +221,7 @@ void optimize_dichotomic_search( for (Counter queue_size = 1;;) { if (parameters.optimization_mode != OptimizationMode::Anytime) - queue_size = parameters.not_anytime_dichotomic_search_subproblem_beam_size; + queue_size = parameters.not_anytime_dichotomic_search_subproblem_queue_size; DichotomicSearchFunction bpp_solve = [¶meters, &queue_size](const Instance& bpp_instance) diff --git a/packingsolver/rectangleguillotine/optimize.hpp b/packingsolver/rectangleguillotine/optimize.hpp index 9d15dd83e..0a4da458a 100644 --- a/packingsolver/rectangleguillotine/optimize.hpp +++ b/packingsolver/rectangleguillotine/optimize.hpp @@ -85,7 +85,7 @@ struct OptimizeParameters: packingsolver::Parameters * Size of the queue in the bin packing subproblem of the dichotomic search * algorithm. */ - NodeId not_anytime_dichotomic_search_subproblem_beam_size = 256; + NodeId not_anytime_dichotomic_search_subproblem_queue_size = 256; }; const Output optimize( From 3c7de682517d6c8bb32615d869458ac71b800022 Mon Sep 17 00:00:00 2001 From: Florian Fontan Date: Thu, 18 Apr 2024 23:45:21 +0200 Subject: [PATCH 3/6] Add not-anytime options in onedimensional main --- packingsolver/onedimensional/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packingsolver/onedimensional/main.cpp b/packingsolver/onedimensional/main.cpp index e13e34137..74866cedd 100644 --- a/packingsolver/onedimensional/main.cpp +++ b/packingsolver/onedimensional/main.cpp @@ -83,7 +83,10 @@ int main(int argc, char *argv[]) ("sequential-value-correction-subproblem-queue-size,", po::value(), "set sequential value correction subproblem queue size") ("sequential-value-correction-number-of-iterations,", po::value(), "set sequential value correction number of iterations") ("column-generation-subproblem-queue-size,", po::value(), "set column generation subproblem queue size") + ("not-anytime-tree-search-queue-size,", po::value(), "") + ("not-anytime-sequential-single-knapsack-subproblem-queue-size,", po::value(), "") ("not-anytime-sequential-value-correction-number-of-iterations,", po::value(), "") + ("not-anytime-dichotomic-search-subproblem-queue-size,", po::value(), "") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -151,8 +154,14 @@ int main(int argc, char *argv[]) parameters.sequential_value_correction_subproblem_queue_size = vm["sequential-value-correction-subproblem-queue-size"].as(); if (vm.count("column-generation-subproblem-queue-size")) parameters.column_generation_subproblem_queue_size = vm["column-generation-subproblem-queue-size"].as(); + if (vm.count("not-anytime-tree-search-queue-size")) + parameters.not_anytime_tree_search_queue_size = vm["not-anytime-tree-search-queue-size"].as(); + if (vm.count("not-anytime-sequential-single-knapsack-subproblem-queue-size")) + parameters.not_anytime_sequential_single_knapsack_subproblem_queue_size = vm["not-anytime-sequential-single-knapsack-subproblem-queue-size"].as(); if (vm.count("not-anytime-sequential-value-correction-number-of-iterations")) parameters.not_anytime_sequential_value_correction_number_of_iterations = vm["not-anytime-sequential-value-correction-number-of-iterations"].as(); + if (vm.count("not-anytime-dichotomic-search-subproblem-queue-size")) + parameters.not_anytime_dichotomic_search_subproblem_queue_size = vm["not-anytime-dichotomic-search-subproblem-queue-size"].as(); const onedimensional::Output output = optimize(instance, parameters); if (vm.count("certificate")) From 5b155ec6204cd880c8e75bcf8efc7d4e6c49abc6 Mon Sep 17 00:00:00 2001 From: Florian Fontan Date: Thu, 18 Apr 2024 23:46:51 +0200 Subject: [PATCH 4/6] Clean comments --- packingsolver/algorithms/column_generation.hpp | 6 +++--- .../algorithms/sequential_value_correction.hpp | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packingsolver/algorithms/column_generation.hpp b/packingsolver/algorithms/column_generation.hpp index b1d020129..6912fc1dd 100644 --- a/packingsolver/algorithms/column_generation.hpp +++ b/packingsolver/algorithms/column_generation.hpp @@ -1,8 +1,8 @@ /** - * Column Generation algorithm + * Column generation algorithm * - * Algorithm for Variable-sized Bin Packing, Bin Packing and (Multiple) - * Knapsack Problems. + * Algorithm for variable-sized bin packing, bin packing and (multiple) + * knapsack problems. * * Input: * - m bin types with lower bounds lᵢ, upper bounds uᵢ and costs cᵢ (i = 0..m) diff --git a/packingsolver/algorithms/sequential_value_correction.hpp b/packingsolver/algorithms/sequential_value_correction.hpp index bcfa59835..3ca0c326a 100644 --- a/packingsolver/algorithms/sequential_value_correction.hpp +++ b/packingsolver/algorithms/sequential_value_correction.hpp @@ -1,23 +1,23 @@ /** - * Sequential Value Correction algorithm + * Sequential value correction algorithm * - * Algorithm for Multiple Knapsack, Bin Packing and Variable-sized Bin Packing + * Algorithm for multiple knapsack, bin packing and variable-sized bin packing * problems. * - * For Variable-sized Bin Packing, it doesn't handle the minimum number of + * For variable-sized bin packing, it doesn't handle the minimum number of * copies of each bin type to use. * - * The algorithm solves a Single Knapsack subproblem for each bin until either + * The algorithm solves a single knapsack subproblem for each bin until either * all items are packed, or there is no bin left. * Then, it restarts but increases the profits of the items that where packed * in bins with high waste, such that they get packed earlier and hopefully * generate less waste. * - * For Variable-sized Bin Packing, this algorithm should require less + * For Variable-sized bin packing, this algorithm should require less * computational effort to find a good solution than the other algorithms for * this objective. - * For Multiple Knapsck and Bin Packing, it is useful for boxstacks problem - * type since, in this case, Tree Search might not be applied directly to get a + * For multiple knapsck and bin packing, it is useful for boxstacks problem + * type since, in this case, tree search might not be applied directly to get a * good solution. * * Some references from which this implementation is inspired: @@ -109,7 +109,9 @@ SequentialValueCorrectionOutput sequential_value_correction( } for (output.number_of_iterations = 0;; output.number_of_iterations++) { - //std::cout << "it " << output.number_of_iterations << std::endl; + //std::cout << "it " << output.number_of_iterations + // << " / " << parameters.maximum_number_of_iterations + // << std::endl; // Check maximum number of iterations. if (parameters.maximum_number_of_iterations != -1 From fc896b8eeff11b52cbcde167799f32fdb6c83dd1 Mon Sep 17 00:00:00 2001 From: Florian Fontan Date: Thu, 18 Apr 2024 23:56:22 +0200 Subject: [PATCH 5/6] Add test for onedimensional --- data/onedimensional/BUILD | 6 ++++++ data/onedimensional/users/2023-08-01_bins.csv | 4 ++++ data/onedimensional/users/2023-08-01_items.csv | 11 +++++++++++ .../onedimensional/users/2024-04-06_t0_bins.csv | 3 +++ .../users/2024-04-06_t0_items.csv | 5 +++++ .../onedimensional/users/2024-04-06_t1_bins.csv | 9 +++++++++ .../users/2024-04-06_t1_items.csv | 7 +++++++ .../onedimensional/users/2024-04-06_t2_bins.csv | 9 +++++++++ .../users/2024-04-06_t2_items.csv | 3 +++ .../onedimensional/users/2024-04-06_t3_bins.csv | 2 ++ .../users/2024-04-06_t3_items.csv | 17 +++++++++++++++++ data/onedimensional/users/2024-04-07_bins.csv | 3 +++ data/onedimensional/users/2024-04-07_items.csv | 5 +++++ data/onedimensional/users/2024-04-09_bins.csv | 3 +++ data/onedimensional/users/2024-04-09_items.csv | 2 ++ packingsolver/onedimensional/BUILD | 2 +- .../onedimensional/onedimensional_test.cpp | 16 ++++++++++++++++ 17 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 data/onedimensional/BUILD create mode 100644 data/onedimensional/users/2023-08-01_bins.csv create mode 100644 data/onedimensional/users/2023-08-01_items.csv create mode 100644 data/onedimensional/users/2024-04-06_t0_bins.csv create mode 100644 data/onedimensional/users/2024-04-06_t0_items.csv create mode 100644 data/onedimensional/users/2024-04-06_t1_bins.csv create mode 100644 data/onedimensional/users/2024-04-06_t1_items.csv create mode 100644 data/onedimensional/users/2024-04-06_t2_bins.csv create mode 100644 data/onedimensional/users/2024-04-06_t2_items.csv create mode 100644 data/onedimensional/users/2024-04-06_t3_bins.csv create mode 100644 data/onedimensional/users/2024-04-06_t3_items.csv create mode 100644 data/onedimensional/users/2024-04-07_bins.csv create mode 100644 data/onedimensional/users/2024-04-07_items.csv create mode 100644 data/onedimensional/users/2024-04-09_bins.csv create mode 100644 data/onedimensional/users/2024-04-09_items.csv diff --git a/data/onedimensional/BUILD b/data/onedimensional/BUILD new file mode 100644 index 000000000..9589fc5a4 --- /dev/null +++ b/data/onedimensional/BUILD @@ -0,0 +1,6 @@ +filegroup( + name = "onedimensional", + srcs = glob(["**/*.csv"]), + visibility = ["//visibility:public"], +) + diff --git a/data/onedimensional/users/2023-08-01_bins.csv b/data/onedimensional/users/2023-08-01_bins.csv new file mode 100644 index 000000000..ad662250f --- /dev/null +++ b/data/onedimensional/users/2023-08-01_bins.csv @@ -0,0 +1,4 @@ +ID,X,COST,COPIES +0,3000,3000,10000 +1,7000,8008,10000 +2,10000,10000,10000 diff --git a/data/onedimensional/users/2023-08-01_items.csv b/data/onedimensional/users/2023-08-01_items.csv new file mode 100644 index 000000000..7d34a24a9 --- /dev/null +++ b/data/onedimensional/users/2023-08-01_items.csv @@ -0,0 +1,11 @@ +ID,X,COPIES +0,9809,236 +1,739,4 +2,4624,241 +3,3589,884 +4,8369,48 +5,3236,348 +6,3470,302 +7,732,299 +8,365,613 +9,2056,299 diff --git a/data/onedimensional/users/2024-04-06_t0_bins.csv b/data/onedimensional/users/2024-04-06_t0_bins.csv new file mode 100644 index 000000000..9dd775c6e --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t0_bins.csv @@ -0,0 +1,3 @@ +ID,X,COST,COPIES +0,3000,3000,3000 +1,7000,7000,5000 diff --git a/data/onedimensional/users/2024-04-06_t0_items.csv b/data/onedimensional/users/2024-04-06_t0_items.csv new file mode 100644 index 000000000..272278ac0 --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t0_items.csv @@ -0,0 +1,5 @@ +ID,X,COPIES,NESTING_LENGTH +0,290,1,-5 +1,1496,2,-5 +2,2751,2,-5 +3,3351,2,-5 diff --git a/data/onedimensional/users/2024-04-06_t1_bins.csv b/data/onedimensional/users/2024-04-06_t1_bins.csv new file mode 100644 index 000000000..fdd163f72 --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t1_bins.csv @@ -0,0 +1,9 @@ +ID,X,COST,COPIES +0,1400,1400,30000 +1,3900,3900,30000 +2,900,900,30000 +3,4500,4500,30000 +4,2900,2900,30000 +5,3400,3400,30000 +6,1900,1900,30000 +7,2400,2400,30000 \ No newline at end of file diff --git a/data/onedimensional/users/2024-04-06_t1_items.csv b/data/onedimensional/users/2024-04-06_t1_items.csv new file mode 100644 index 000000000..6458050d7 --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t1_items.csv @@ -0,0 +1,7 @@ +ID,X,COPIES,NESTING_LENGTH +0,1768,3,-4 +1,1764,5,-4 +2,964,2,-4 +3,864,1,-4 +4,1774,1,-4 +5,764,1,-4 \ No newline at end of file diff --git a/data/onedimensional/users/2024-04-06_t2_bins.csv b/data/onedimensional/users/2024-04-06_t2_bins.csv new file mode 100644 index 000000000..5134c4b92 --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t2_bins.csv @@ -0,0 +1,9 @@ +ID,X,COST,COPIES +0,3900,3900,5000 +1,1900,1900,5000 +2,2400,2400,5000 +3,3400,3400,5000 +4,4500,4500,5000 +5,900,900,5000 +6,1400,1400,5000 +7,2900,2900,5000 \ No newline at end of file diff --git a/data/onedimensional/users/2024-04-06_t2_items.csv b/data/onedimensional/users/2024-04-06_t2_items.csv new file mode 100644 index 000000000..549cc308f --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t2_items.csv @@ -0,0 +1,3 @@ +ID,X,COPIES,NESTING_LENGTH +0,2379,1,-4 +1,1164,1,-4 \ No newline at end of file diff --git a/data/onedimensional/users/2024-04-06_t3_bins.csv b/data/onedimensional/users/2024-04-06_t3_bins.csv new file mode 100644 index 000000000..d8279c729 --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t3_bins.csv @@ -0,0 +1,2 @@ +ID,X,COST,COPIES +0,4000,4000,32767 diff --git a/data/onedimensional/users/2024-04-06_t3_items.csv b/data/onedimensional/users/2024-04-06_t3_items.csv new file mode 100644 index 000000000..0b0dc85a4 --- /dev/null +++ b/data/onedimensional/users/2024-04-06_t3_items.csv @@ -0,0 +1,17 @@ +ID,X,COPIES,NESTING_LENGTH +0,1022,1,-4 +1,1022,1,-4 +2,922,3,-4 +3,512,3,-4 +4,920,5,-4 +5,510,5,-4 +6,415,1,-4 +7,415,1,-4 +8,315,2,-4 +9,315,2,-4 +10,265,1,-4 +11,265,1,-4 +12,925,1,-4 +13,515,1,-4 +14,215,1,-4 +15,215,1,-4 diff --git a/data/onedimensional/users/2024-04-07_bins.csv b/data/onedimensional/users/2024-04-07_bins.csv new file mode 100644 index 000000000..9dd775c6e --- /dev/null +++ b/data/onedimensional/users/2024-04-07_bins.csv @@ -0,0 +1,3 @@ +ID,X,COST,COPIES +0,3000,3000,3000 +1,7000,7000,5000 diff --git a/data/onedimensional/users/2024-04-07_items.csv b/data/onedimensional/users/2024-04-07_items.csv new file mode 100644 index 000000000..272278ac0 --- /dev/null +++ b/data/onedimensional/users/2024-04-07_items.csv @@ -0,0 +1,5 @@ +ID,X,COPIES,NESTING_LENGTH +0,290,1,-5 +1,1496,2,-5 +2,2751,2,-5 +3,3351,2,-5 diff --git a/data/onedimensional/users/2024-04-09_bins.csv b/data/onedimensional/users/2024-04-09_bins.csv new file mode 100644 index 000000000..4f1119360 --- /dev/null +++ b/data/onedimensional/users/2024-04-09_bins.csv @@ -0,0 +1,3 @@ +ID,X,COST,COPIES +0,6950,6950,8 +1,7000,3500,2 diff --git a/data/onedimensional/users/2024-04-09_items.csv b/data/onedimensional/users/2024-04-09_items.csv new file mode 100644 index 000000000..6550258a2 --- /dev/null +++ b/data/onedimensional/users/2024-04-09_items.csv @@ -0,0 +1,2 @@ +ID,X,COPIES,NESTING_LENGTH +0,2408,8,-4 diff --git a/packingsolver/onedimensional/BUILD b/packingsolver/onedimensional/BUILD index 1cb2d07bf..48e101556 100644 --- a/packingsolver/onedimensional/BUILD +++ b/packingsolver/onedimensional/BUILD @@ -58,7 +58,7 @@ cc_test( "@boost//:filesystem", ], copts = STDCPP, - #data = ["//data/onedimensional:onedimensional"], + data = ["//data/onedimensional:onedimensional"], timeout = "short", ) diff --git a/packingsolver/onedimensional/onedimensional_test.cpp b/packingsolver/onedimensional/onedimensional_test.cpp index b0b6d115a..3b4e50d26 100644 --- a/packingsolver/onedimensional/onedimensional_test.cpp +++ b/packingsolver/onedimensional/onedimensional_test.cpp @@ -19,3 +19,19 @@ TEST(OneDimensional, BinCopies) EXPECT_EQ(solution.number_of_bins(), 2); EXPECT_EQ(solution.bin_copies(0), 2); } + +TEST(OneDimensional, Users20240409) +{ + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::BinPackingWithLeftovers); + fs::path directory = fs::path("data") / "onedimensional" / "users"; + instance_builder.read_item_types((directory / "2024-04-09_items.csv").string()); + instance_builder.read_bin_types((directory / "2024-04-09_bins.csv").string()); + Instance instance = instance_builder.build(); + + OptimizeParameters optimize_parameters; + optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime; + Output output = optimize(instance, optimize_parameters); + + EXPECT_EQ(output.solution_pool.best().cost(), 27800); +} From ad93e85592a0e6a5a8c3166ddddb878a8829d0c1 Mon Sep 17 00:00:00 2001 From: Florian Fontan Date: Fri, 19 Apr 2024 00:14:25 +0200 Subject: [PATCH 6/6] Add unit tests for onedimensional --- .../onedimensional/onedimensional_test.cpp | 92 ++++++++++++++++++- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/packingsolver/onedimensional/onedimensional_test.cpp b/packingsolver/onedimensional/onedimensional_test.cpp index 3b4e50d26..dd3647d60 100644 --- a/packingsolver/onedimensional/onedimensional_test.cpp +++ b/packingsolver/onedimensional/onedimensional_test.cpp @@ -20,10 +20,95 @@ TEST(OneDimensional, BinCopies) EXPECT_EQ(solution.bin_copies(0), 2); } -TEST(OneDimensional, Users20240409) +TEST(OneDimensional, Users_2023_08_01) { InstanceBuilder instance_builder; - instance_builder.set_objective(packingsolver::Objective::BinPackingWithLeftovers); + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPacking); + fs::path directory = fs::path("data") / "onedimensional" / "users"; + instance_builder.read_item_types((directory / "2023-08-01_items.csv").string()); + instance_builder.read_bin_types((directory / "2023-08-01_bins.csv").string()); + Instance instance = instance_builder.build(); + + OptimizeParameters optimize_parameters; + optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime; + optimize_parameters.use_column_generation = 1; + Output output = optimize(instance, optimize_parameters); + + EXPECT_EQ(output.solution_pool.best().cost(), 1020 * 10000 + 65 * 8008); +} + +TEST(OneDimensional, Users_2024_04_06_t1) +{ + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPacking); + fs::path directory = fs::path("data") / "onedimensional" / "users"; + instance_builder.read_item_types((directory / "2024-04-06_t1_items.csv").string()); + instance_builder.read_bin_types((directory / "2024-04-06_t1_bins.csv").string()); + Instance instance = instance_builder.build(); + + OptimizeParameters optimize_parameters; + optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime; + optimize_parameters.use_column_generation = 1; + Output output = optimize(instance, optimize_parameters); + + EXPECT_EQ(output.solution_pool.best().cost(), 19900); +} + +TEST(OneDimensional, Users_2024_04_06_t2) +{ + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPacking); + fs::path directory = fs::path("data") / "onedimensional" / "users"; + instance_builder.read_item_types((directory / "2024-04-06_t2_items.csv").string()); + instance_builder.read_bin_types((directory / "2024-04-06_t2_bins.csv").string()); + Instance instance = instance_builder.build(); + + OptimizeParameters optimize_parameters; + optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime; + optimize_parameters.use_column_generation = 1; + Output output = optimize(instance, optimize_parameters); + + EXPECT_EQ(output.solution_pool.best().cost(), 3800); +} + +TEST(OneDimensional, Users_2024_04_06_t3) +{ + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPacking); + fs::path directory = fs::path("data") / "onedimensional" / "users"; + instance_builder.read_item_types((directory / "2024-04-06_t3_items.csv").string()); + instance_builder.read_bin_types((directory / "2024-04-06_t3_bins.csv").string()); + Instance instance = instance_builder.build(); + + OptimizeParameters optimize_parameters; + optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime; + optimize_parameters.use_tree_search = 1; + Output output = optimize(instance, optimize_parameters); + + EXPECT_EQ(output.solution_pool.best().cost(), 20000); +} + +TEST(OneDimensional, Users_2024_04_07) +{ + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPacking); + fs::path directory = fs::path("data") / "onedimensional" / "users"; + instance_builder.read_item_types((directory / "2024-04-07_items.csv").string()); + instance_builder.read_bin_types((directory / "2024-04-07_bins.csv").string()); + Instance instance = instance_builder.build(); + + OptimizeParameters optimize_parameters; + optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime; + optimize_parameters.use_dichotomic_search = 1; + Output output = optimize(instance, optimize_parameters); + + EXPECT_EQ(output.solution_pool.best().cost(), 19000); +} + +TEST(OneDimensional, Users_2024_04_09) +{ + InstanceBuilder instance_builder; + instance_builder.set_objective(packingsolver::Objective::VariableSizedBinPacking); fs::path directory = fs::path("data") / "onedimensional" / "users"; instance_builder.read_item_types((directory / "2024-04-09_items.csv").string()); instance_builder.read_bin_types((directory / "2024-04-09_bins.csv").string()); @@ -31,7 +116,8 @@ TEST(OneDimensional, Users20240409) OptimizeParameters optimize_parameters; optimize_parameters.optimization_mode = packingsolver::OptimizationMode::NotAnytime; + optimize_parameters.use_sequential_value_correction = 1; Output output = optimize(instance, optimize_parameters); - EXPECT_EQ(output.solution_pool.best().cost(), 27800); + EXPECT_EQ(output.solution_pool.best().cost(), 20900); }