From 1267701a2c5ee370d1aac6b06ab943c272bf84b3 Mon Sep 17 00:00:00 2001 From: Alinson Xavier Date: Sat, 18 Nov 2017 17:14:44 -0600 Subject: [PATCH] Handle instances without reduced costs --- onerow/library/src/wedge_cut_generator.cpp | 5 +++-- onerow/library/tests/wedge_cut_generator_test.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/onerow/library/src/wedge_cut_generator.cpp b/onerow/library/src/wedge_cut_generator.cpp index 2f5f59a..b45a6af 100644 --- a/onerow/library/src/wedge_cut_generator.cpp +++ b/onerow/library/src/wedge_cut_generator.cpp @@ -284,7 +284,8 @@ void WedgeCutGenerator::eval_next() { while (true) { - if (0 <= cur_facet && cur_facet < (int) knapsack.list.size() && cur_facet <= MAX_CUT_DEPTH) + if (0 <= cur_facet && cur_facet < (int) knapsack.list.size() && + cur_facet <= MAX_CUT_DEPTH) break; r1_offset++; @@ -296,7 +297,7 @@ void WedgeCutGenerator::eval_next() } int r1_index = row.c.pi.index(r1_offset); - if(row.reduced_costs[r1_index] < row.cost_cutoff) + if (row.reduced_costs && row.reduced_costs[r1_index] < row.cost_cutoff) continue; r1[0] = -row.c.pi.value(r1_offset).reduce(REDUCE_FACTOR_R1); diff --git a/onerow/library/tests/wedge_cut_generator_test.cpp b/onerow/library/tests/wedge_cut_generator_test.cpp index 05453ba..3d6962c 100644 --- a/onerow/library/tests/wedge_cut_generator_test.cpp +++ b/onerow/library/tests/wedge_cut_generator_test.cpp @@ -125,6 +125,7 @@ TEST(WedgeCutGenerator, generate_test_1) r.c.pi.push(1, rational(-1)); r.c.pi.push(2, rational(1)); r.c.pi_zero = rational(5,7); + r.reduced_costs = 0; std::set expected_cuts; rational cut_matrix[] = { @@ -176,6 +177,7 @@ TEST(WedgeCutGenerator, generate_test_2) r.c.pi.push(1, rational(-1)); r.c.pi.push(2, rational(1)); r.c.pi_zero = rational(1,2); + r.reduced_costs = 0; set expected_cuts; rational cut_matrix[] = { @@ -236,6 +238,7 @@ TEST(WedgeCutGenerator, generate_test_3) r.c.pi.push(12, rational(237478,39665)); r.c.pi.push(13, rational(237478,39665)); r.c.pi_zero = rational(631975,707651); + r.reduced_costs = 0; rational solution[14]; solution[0] = rational(0);