GuidedLocalSearch.next_solution() in set_covering hangs when element belongs to more than one subset
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
Research direction
The repro is self-contained: run the Python snippet against ortools/set_cover and confirm GuidedLocalSearch.next_solution() spins forever when an element appears in two subsets (disjoint case returns fine). Then read the GLS implementation in ortools/set_cover/guided_local_search.cc alongside SetCoverInvariant, focusing on the perturbation loop and the heap of candidate subsets the reporter suspects never empties. Done means next_solution() returns with cost 2.0 under the default budget, with a regression test in the set_cover Python/C++ tests.
Written by the indexing model from the issue text.
Description
What version of OR-Tools and what language are you using?
Version: 9..15.6755
Language: Python
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
set_cover https://github.com/google/or-tools/tree/stable/ortools/set_cover
What operating system (Linux, Windows, ...) and version?
Debian:
PRETTY_NAME="Debian GNU/Linux forky/sid"
VERSION_CODENAME=forky
Kernel : Linux 7.2.15+deb14-amd64
Same on MacOs
What did you do?
Steps to reproduce the behavior:
from ortools.set_cover.python import set_cover as sc
disjoint = True # False is ok..
bounded = False
model = sc.SetCoverModel()
for subset in ([[0], [1]] if disjoint else [[0], [0]]):
model.add_empty_subset(1.0)
for element in subset:
model.add_element_to_last_subset(element)
model.create_sparse_row_view()
inv = sc.SetCoverInvariant(model)
assert sc.GreedySolutionGenerator(inv).next_solution()
print(f"greedy cost: {inv.cost()}, selected: {inv.is_selected()}")
print("GLS...", flush=True)
gls = sc.GuidedLocalSearch(inv)
gls.initialize()
if bounded:
gls.set_max_iterations(10**6) # the workaround: it will end eventually
print("This will hang", flush=True)
gls.next_solution() # default budget is int64 max it is a very long time...
print(f"GLS returned, cost: {inv.cost()}")
What did you expect to see
GLS returned, cost: 2.0
What did you see instead?
100% CPU and seems it hangs
Make sure you include information that can help us debug (full error message, model Proto).
Had a quick read of c++ code looks like heap never gets empty when not disjoint or default run time is just too long? Not sure exactly, have not tried to debug.
Thanks!
- Dominant language
- C++
- Stars
- 14.5k
- Forks
- 2.6k
- Avg merge
- 9h 43m
- Merged PRs (30d)
- 53
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/or-tools
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
Maintainers usually reply within 1 day
-
CP-SAT: TimeTableEdgeFinding can report false INFEASIBLE for large cumulative scheduling modelsPossibly taken @lperron claimed this today. OpenBug Solver: CP-SAT Solver
google/or-tools#5672 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Python (v10.0-rc.1): Model.restore_assignment() and Assignment.objective() take ownership of C++-owned objects (segfault)Possibly taken @Mizux claimed this today. OpenLang: Python Solver: Routing & CP Solver
google/or-tools#5670 · 1 assignee ·
Maintainers usually reply within 1 day
-
[CP-SAT] Duplicate timer registration in StartDirectSolver when UserTimer aliases WallTimerPossibly taken @lperron claimed this 1 day ago. OpenSolver: CP-SAT Solver
Difficulty 3/5 Half a day Newbie friendliness 85/100
google/or-tools#5659 · 5 comments · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ionut-mihalache/aqua#31 · 1 comment ·
-
LWG
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
needs-kind
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
villagesql/villagesql-server#1702 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/vcpkg-tool#2191 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
harfbuzz/harfbuzz#6966 · 1 comment ·
Maintainers usually reply within 1 day