Skip to content

No longer fixing variables by rounding in checkColBounds and logging objective bound and MIP rel gap in writeSolution whenever a primal solution is available - #3772

Open
jajhall wants to merge 10 commits into
latestfrom
fix-3768
Open

jajhall wants to merge 10 commits into
latestfrom
fix-3768

Conversation

@jajhall

@jajhall jajhall commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Description

  • No longer fixing variables by rounding in HPresolve::checkColBounds, (fixing MIP presolve declares a feasible model infeasible #3768)
  • Logging objective bound and MIP rel gap in writeSolution whenever a primal solution is available (fixing Write the objective bound and MIP gap when a MIP stops at a limit #3742)
  • Now using %12.12g rather than %12g to write out double values in writeModelBoundSolution to avoid hiding small perturbations of integers.
  • Now using highsFprintfString(file, options_.log_options, "\n# Basis\n"); rather than fprintf(file, "\n# Basis\n"); to silence logging of # Basis when output_flag is false. Ditto # Ranging.

Change to HPresolve::checkColBounds may be controversial but, for me, what was being done before was akin to rounding optimal values of integer variables that have fractional part within the mip_feasibility_tolerance: normally it's OK, but sometimes the corresponding LP (after fixing discrete variables at pure integer values) is infeasible. The change is fail-safe, with the downside that less fixing is performed. NB Observation by @hodangkhoinguyen that "exact SCIP: 158999841/1250000; SCIP 10.0.2, CPLEX 22.2 and Gurobi 14.0.0 agree [on Optimal, objective 127.1998728]".

Checklist

  • I have read the contributing guidelines
  • This PR targets the latest branch
  • Tests are passing
  • Documentation was updated where relevant
  • This PR is not primarily AI-generated (per the AI contributions policy in CONTRIBUTING.md)

Related issue

Closes #3742 and #3768

jajhall and others added 3 commits November 22, 2026 11:49
@jajhall
jajhall requested a review from fwesselm November 22, 2026 12:30
@jajhall jajhall self-assigned this Nov 22, 2026
@jajhall jajhall changed the title Fix 3768 No longer fixing variables by rounding in checkColBounds and logging objective bound and MIP rel gap in writeSolution whenever a primal solution is available Nov 22, 2026
@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.98%. Comparing base (a63cfeb) to head (e83739a).
⚠️ Report is 1 commits behind head on latest.

Files with missing lines Patch % Lines
highs/lp_data/Highs.cpp 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           latest    #3772   +/-   ##
=======================================
  Coverage   75.98%   75.98%           
=======================================
  Files         467      467           
  Lines      116544   116570   +26     
  Branches    18165    18166    +1     
=======================================
+ Hits        88551    88580   +29     
+ Misses      27753    27750    -3     
  Partials      240      240           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jajhall

jajhall commented Nov 22, 2026 •

Copy link
Copy Markdown
Member Author

@DoumarCharles Having modified HPresolve::checkColBounds, HPresolveInitialSweep::checkColBounds, and computeSingletonRowBounds so that variables are no longer fixed by rounding, please find out how many of your outstanding issues are closed by this PR (#3772) and close them, thanks. I know that one of use "should" do it, but you're obviously much more on top of the issues (and fixes) that you've suggested.

@jajhall
jajhall requested a review from Opt-Mucca November 22, 2026 13:38
@jajhall

jajhall commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Added issue-3618 using

Minimize
obj: x0 + x1
Subject To
c1: x0 + x1 >= 2.00000011
Bounds
1 <= x0 <= 1.00000007
1 <= x1 <= 1.00000005
End

as very simple illustration why fixing by rounding in presolve is wrong

…ColBounds or passing it into computeSingletonRowBounds
@DoumarCharles

Copy link
Copy Markdown
Contributor

Thanks. I tested the models from my open issues on this PR (f592c92) and its base (0eb18f9): 78 runs, using default options and the options specified in each issue.

This PR fixes #3618. Both models now return Optimal at the expected objectives (2.00000011 and 1).

However, the PR also needs the diff from my follow-up comment on #3618 (#3618 (comment)). When narrow columns are no longer fixed, relaxing a column bound can leave stale implied bounds on the other columns of its rows. On the model in that comment, this PR returns "Primal infeasible or unbounded" with presolve on, with the log error:

ERROR:   returnFromHighs: HighsModelStatus::kUnboundedOrInfeasible is not permitted

Latest returns Optimal 0.1. With the follow-up diff applied on top of this PR, the model returns Optimal 0.099999905 (0.1 with presolve off). The 78-run results and unit tests are unchanged from this PR alone.

One interaction with #3646: on its first model with default options, the result changes from 3.625 on the base to 3.6264999 on this PR. That is the incorrect result latest gives on that model with presolve off, as described in #3646. I previously observed the same interaction when testing my diff for #3618. Apart from this, I found no changed results on my other open-issue models.

With both presolve changes included, #3618 looks ready to close:

  1. This PR: checkColBounds (in HPresolve and HPresolveInitialSweep) and computeSingletonRowBounds no longer fix a column whose bounds are only within the tolerance of each other.
  2. The diff from my follow-up comment on Presolve: narrow columns treated as fixed make a feasible model infeasible #3618: when changeColLower or changeColUpper relaxes a column bound, the implied bounds derived from the column's rows are reset.

#3646 remains a separate issue.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants