From ba0b33e1a3eefdff0f4997aac7fa6f379b3be57b Mon Sep 17 00:00:00 2001 From: dance858 Date: Mon, 16 Nov 2026 15:15:39 -0800 Subject: [PATCH] Relative tolerance for parallel equality sides Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_012aJMgrh6FhS6Yt3prnvJgj --- src/explorers/Parallel_rows.c | 3 ++- tests/test_Parallel_rows.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/explorers/Parallel_rows.c b/src/explorers/Parallel_rows.c index 9e308610..ae511c09 100644 --- a/src/explorers/Parallel_rows.c +++ b/src/explorers/Parallel_rows.c @@ -475,7 +475,8 @@ static inline PresolveStatus process_single_bin(const Constraints *constraints, // ----------------------------------------------------------------------- if (is_remaining_row_eq && is_other_row_eq) { - if (!IS_EQUAL_FEAS_TOL(remaining_row_new_rhs, other_row_rhs_scaled)) + if (IS_INFEAS_GT(remaining_row_new_rhs, other_row_rhs_scaled) || + IS_INFEAS_LT(remaining_row_new_rhs, other_row_rhs_scaled)) { return INFEASIBLE; } diff --git a/tests/test_Parallel_rows.h b/tests/test_Parallel_rows.h index 2e6b7ca4..29d897f1 100644 --- a/tests/test_Parallel_rows.h +++ b/tests/test_Parallel_rows.h @@ -1432,6 +1432,35 @@ static char *test_20_parallel_rows_eq_ineq_rounding_swapped() return 0; } +/* Two parallel equalities with large sides that agree up to rounding: + x + y + z = 1e9 + 3x + 3y + 3z = 3e9 + 3e-5 x, y, z >= 0 + The scaled sides differ by 1e-5, which is 1e-14 relative to the sides, so + the pair is not infeasible. The costs differ so that the fold does not merge + the columns first. */ +static char *test_21_parallel_rows_eq_eq_large_sides() +{ + double Ax[] = {1, 1, 1, 3, 3, 3}; + int Ai[] = {0, 1, 2, 0, 1, 2}; + int Ap[] = {0, 3, 6}; + double lhs[] = {1e9, 3e9 + 3e-5}; + double rhs[] = {1e9, 3e9 + 3e-5}; + double lbs[] = {0, 0, 0}; + double ubs[] = {INF, INF, INF}; + double c[] = {1, 2, 3}; /* distinct, or the fold merges the three columns */ + + Settings *stgs = default_settings(); + stgs->verbose = false; + Presolver *presolver = + new_presolver(Ax, Ai, Ap, 2, 3, 6, lhs, rhs, lbs, ubs, c, stgs); + PresolveStatus status = run_presolver(presolver); + mu_assert("feasible", (status & INFEASIBLE) == 0); + + PS_FREE(stgs); + free_presolver(presolver); + return 0; +} + static const char *all_tests_parallel_rows() { mu_run_test(test_1_parallel_rows, counter_parallel_rows); @@ -1455,6 +1484,7 @@ static const char *all_tests_parallel_rows() mu_run_test(test_19_parallel_rows_eq_ineq_rounding, counter_parallel_rows); mu_run_test(test_20_parallel_rows_eq_ineq_rounding_swapped, counter_parallel_rows); + mu_run_test(test_21_parallel_rows_eq_eq_large_sides, counter_parallel_rows); return 0; }