Skip to content

Commit

Permalink
fixes scaling in MinKnap
Browse files Browse the repository at this point in the history
  • Loading branch information
hlefebvr committed Oct 31, 2023
1 parent 6022e30 commit 723faa1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/assignment.example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
9 changes: 4 additions & 5 deletions lib/src/optimizers/wrappers/MinKnap/Optimizers_MinKnap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 723faa1

Please sign in to comment.