CP-SAT: default gap can report OPTIMAL with a nonzero integer gap above 2^53

Open
#5,599 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, python
Domain
backend

Research direction

Start by reading SharedResponseManager::TestGapLimitsIfNeeded() and the attached reproducer and patch. Compare how the objective and bound are rounded before their gap is computed, then run the component regression results and exact endpoint comparisons included with the attachment. Done means the default absolute gap no longer reports OPTIMAL when the integer gap is one, including with a large objective offset.

Written by the indexing model from the issue text.

Description

What version of OR-Tools and what language are you using?

Version: Python wheel 9.15.6755 (also the latest published release checked), and C++ main 0ea2bb6cf25b3dcef6ba723e8fc0d9db0d664e8b.
Language: Python 3.14 and C++.

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)

CP-SAT.

What operating system (Linux, Windows, ...) and version?

Windows 11 Home x64, version 10.0.26300; source build with MSVC 14.44 and Windows SDK 10.0.26100.

What did you do?

  1. Install ortools==9.15.6755 and extract the attachment.
  2. Run python repro/repro.py --gap default --output release.response.txt.
  3. Compare python repro/repro.py --gap 0 --output zero.response.txt --expect-exact.

The model has one variable with domain [2^54, 2^54+1], objective minimize that variable, and a complete hint at 2^54+1. Parameters: num_search_workers:1 cp_model_presolve:false linearization_level:0 cp_model_probing_level:0 symmetry_level:0 relative_gap_limit:0. The first command leaves absolute_gap_limit at its default 1e-4.

What did you expect to see

OPTIMAL with integer value and integer lower bound both 18014398509481984. This is the exact minimum of the original variable domain. An absolute gap below one should not accept an integer gap of one.

What did you see instead?

With the default gap: OPTIMAL, integer solution 18014398509481985, integer lower bound 18014398509481984. The actual gap is one. The exposed double objective and double bound both round to 18014398509481984.

With zero gaps: OPTIMAL, integer solution and lower bound both 18014398509481984. Base main reproduces the same distinction. The proposed fix returns this exact optimum under both settings.

Anything else we should know about your project / environment

This standalone model contains no application data. The issue is reproduced with one worker and no time limit. SharedResponseManager::TestGapLimitsIfNeeded() subtracts separately rounded double objective values. Subtracting integer bounds before converting the difference avoids the cancellation, including when the objective offset is large. The attachment includes an upstream patch, component-regression results, and exact endpoint comparisons.

attach-D7.zip

Dominant language
C++
Stars
14.5k
Forks
2.6k
Avg merge
9h 43m
Merged PRs (30d)
53

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/or-tools

All issues in google/or-tools

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.