From 723faa1f336a1ea06c7d2eee34d9b5af3c95c9b9 Mon Sep 17 00:00:00 2001 From: Henri Lefebvre Date: Tue, 31 Oct 2023 09:17:07 +0100 Subject: [PATCH] fixes scaling in MinKnap --- examples/assignment.example.cpp | 2 +- .../optimizers/wrappers/MinKnap/Optimizers_MinKnap.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/assignment.example.cpp b/examples/assignment.example.cpp index d1aff2f1..c458bb20 100644 --- a/examples/assignment.example.cpp +++ b/examples/assignment.example.cpp @@ -58,7 +58,7 @@ int main(int t_argc, const char** t_argv) { .with_log_level(Info, Yellow) .with_farkas_pricing(true) .with_artificial_variables_cost(1e+4) - .with_branching_on_master(false) + .with_branching_on_master(true) .with_dual_price_smoothing_stabilization(.3) .with_column_pool_clean_up(1e+8, .75) ) diff --git a/lib/src/optimizers/wrappers/MinKnap/Optimizers_MinKnap.cpp b/lib/src/optimizers/wrappers/MinKnap/Optimizers_MinKnap.cpp index 05ee9798..608c58a0 100644 --- a/lib/src/optimizers/wrappers/MinKnap/Optimizers_MinKnap.cpp +++ b/lib/src/optimizers/wrappers/MinKnap/Optimizers_MinKnap.cpp @@ -94,15 +94,14 @@ void idol::Optimizers::MinKnap::hook_optimize() { const auto& column = model.get_var_column(var); const double weight = as_numeric(column.linear().get(ctr)); + const double profit = as_numeric(column.obj()); - if (ub < 1 - Tolerance::Integer || weight < -Tolerance::Feasibility) { + if (ub < 1. - 2 * Tolerance::Integer) { lazy(var).impl() = 0.; // fixed to 0 continue; } - const double profit = as_numeric(column.obj()); - - if (lb > Tolerance::Integer) { + if (lb > 2 * Tolerance::Integer) { lazy(var).impl() = 1.; // fixed to 1 unscaled_capacity -= weight; fixed_profit += profit; @@ -118,7 +117,7 @@ void idol::Optimizers::MinKnap::hook_optimize() { auto* profits = new int[n]; auto* weights = new int[n]; auto* values = new int[n]; - auto scaling_factor = (double) Tolerance::Digits; + auto scaling_factor = (double) 1000; auto capacity = (int) (scaling_factor * unscaled_capacity); unsigned int i = 0;