From 9279e235138a1f63ae21458ee6ce15f93a15b5d4 Mon Sep 17 00:00:00 2001 From: dance858 Date: Tue, 17 Nov 2026 10:29:32 -0800 Subject: [PATCH] Undo the distance test of #130 in retrieve_bound_change Always move the dual of an implied bound back to the row that implied it. Co-Authored-By: Claude Fable 5.2 --- include/core/Numerics.h | 1 - src/core/Postsolver.c | 16 ++++------------ tests/test_postsolve.h | 18 +++++++++--------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/include/core/Numerics.h b/include/core/Numerics.h index ac05afcb..1fde0c79 100644 --- a/include/core/Numerics.h +++ b/include/core/Numerics.h @@ -31,7 +31,6 @@ #define ZERO_TOL_DUAL_POSTSOLVE 1e-6 #define HUGE_VAL_PS 1e7 #define ACT_RECOMPUTE_RATIO 100.0 -#define ACTIVE_BOUND_TOL_REL 1e-3 // used for model clean up according to Gurobi paper #define CLEAN1 1e-3 diff --git a/src/core/Postsolver.c b/src/core/Postsolver.c index 0e0aaa39..8f31d8c8 100644 --- a/src/core/Postsolver.c +++ b/src/core/Postsolver.c @@ -325,7 +325,7 @@ void retrieve_added_rows(Solution *sol, int i, const int *rows, const double *va static void retrieve_bound_change(Solution *sol, int i, int j, const int *cols, const double *vals, int len, - bool implied_bound_is_upper, double implied_bound) + bool implied_bound_is_upper) { int k, ii; double aij = 1.0; @@ -339,14 +339,6 @@ static void retrieve_bound_change(Solution *sol, int i, int j, const int *cols, return; } - // only transfer z_j to the row if the implied bound is (nearly) active - double dist = implied_bound_is_upper ? implied_bound - sol->x[j] - : sol->x[j] - implied_bound; - if (dist > ACTIVE_BOUND_TOL_REL * (1.0 + ABS(implied_bound))) - { - return; - } - // find aij for (ii = 0; ii < len; ++ii) { @@ -560,9 +552,9 @@ void postsolver_run(const PostsolveInfo *info, Solution *sol, const double *x, bound_changes_processed += 1; // the implied bound is the upper one iff the other bound // is the lower one - retrieve_bound_change( - sol, row.i, r.j, row.cols, row.vals, row.len, - r.is_original_other_bound_lower_bound, r.implied_bound); + retrieve_bound_change(sol, row.i, r.j, row.cols, row.vals, + row.len, + r.is_original_other_bound_lower_bound); } j -= 1; diff --git a/tests/test_postsolve.h b/tests/test_postsolve.h index 92e90328..c1763128 100644 --- a/tests/test_postsolve.h +++ b/tests/test_postsolve.h @@ -1550,11 +1550,12 @@ static char *test_ston_row_bound_dual_approximate_solution() [1 1] x >= 6e4 x0 free, 0 <= x1 <= 1e5 The singleton row becomes the bound x0 <= 5e4 and is deleted. The reduced - point has x0 = 1e4, far from that bound, and z0 = -1e-3: noise of a - first-order solver, not a multiplier of the bound. Postsolve must not hand - z0 to the deleted row: y0 = -5e-4 on a row with slack 8e4 would add 40 to - the duality gap. z0 stays as a dual residual of the size it had on the - reduced problem. */ + point has x0 = 1e4, far from that bound, and z0 = -1e-3, as an inexact + solver may return. x0 is free in the original problem, so z0 cannot stay + on the column: postsolve hands it to the deleted row whatever the distance + to the bound, y0 = z0 / 2 = -5e-4 and z0 = 0. The postsolved point is then + dual feasible, and the complementarity error |z0| * 4e4 of the reduced + point is carried over as it is. */ static char *test_ston_row_bound_dual_inactive_bound() { double Ax[] = {2, 1, 1}; @@ -1585,10 +1586,9 @@ static char *test_ston_row_bound_dual_inactive_bound() double z[] = {-1e-3, 0}; postsolve(presolver, x, y, z); - mu_assert("inactive bound dual handed to the singleton row", - presolver->sol->y[0] == 0.0); - mu_assert("bound dual of an inactive bound not kept", - presolver->sol->z[0] == -1e-3); + mu_assert("inactive bound dual not handed to the singleton row", + presolver->sol->y[0] == -5e-4); + mu_assert("bound dual kept on a free column", presolver->sol->z[0] == 0.0); PS_FREE(stgs); free_presolver(presolver);