Skip to content

Commit

Permalink
refactor benders factory (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir authored Jul 15, 2024
1 parent b72feb6 commit ab1693e
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/cpp/benders/factories/BendersFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit ab1693e

Please sign in to comment.