From ab1693ee4563d081cad08c2ec6c4655bf45f5f64 Mon Sep 17 00:00:00 2001 From: Abdoulbari Zaher <32519851+a-zakir@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:42:17 +0200 Subject: [PATCH] refactor benders factory (#874) --- src/cpp/benders/factories/BendersFactory.cpp | 29 +++++++------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/cpp/benders/factories/BendersFactory.cpp b/src/cpp/benders/factories/BendersFactory.cpp index f636e9d99..8247df49d 100644 --- a/src/cpp/benders/factories/BendersFactory.cpp +++ b/src/cpp/benders/factories/BendersFactory.cpp @@ -16,27 +16,18 @@ BENDERSMETHOD DeduceBendersMethod(size_t coupling_map_size, size_t batch_size, bool external_loop) { - /* - classical benders: 0*100 + 0*10 = 0 - classical benders + external loop: 0*100 + 1*10 = 10 - benders by batch: 1*100 + 0*10 = 100 - benders by batch + external loop: 1*100 + 1*10 = 110 - */ - - auto benders_algo_score = - (batch_size == 0 || batch_size == coupling_map_size - 1) ? 0 : 1; - auto external_loop_score = external_loop ? 1 : 0; - auto total_score = 100 * benders_algo_score + 10 * external_loop_score; - switch (total_score) { - case 0: - default: - return BENDERSMETHOD::BENDERS; - case 10: + if (batch_size == 0 || batch_size == coupling_map_size - 1) { + if (external_loop) { return BENDERSMETHOD::BENDERS_EXTERNAL_LOOP; - case 100: - return BENDERSMETHOD::BENDERS_BY_BATCH; - case 110: + } else { + return BENDERSMETHOD::BENDERS; + } + } else { + if (external_loop) { return BENDERSMETHOD::BENDERS_BY_BATCH_EXTERNAL_LOOP; + } else { + return BENDERSMETHOD::BENDERS_BY_BATCH; + } } }