Skip to content

Commit

Permalink
src/sage/graphs/generic_graph.py: work around doctest hang
Browse files Browse the repository at this point in the history
One doctest in this file is "hanging" on ARM64 and RISC-V as GLPK
tries courageously to solve a MIP. A tweak to the solver options
allows this problem to be solved on those two architectures without
affecting any others. This is unlikely to solve the general problem,
but it may buy us some time.

Closes sagemath#34575
Closes sagemath#38831
  • Loading branch information
orlitzky committed Oct 24, 2024
1 parent 7726cd9 commit d106141
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7358,6 +7358,22 @@ def edge_disjoint_spanning_trees(self, k, algorithm=None, root=None, solver=None
p.add_constraint(pos[root, c] + BFS[u] <= pos[u, c])

# We now solve this program and extract the solution
try:
# The MIP approach with GLPK is prone to compiler and
# optimization-level weirdness on some hardware:
#
# * https://github.com/sagemath/sage/issues/34575
# * https://github.com/sagemath/sage/issues/38831
#
# Disabling the presolver manages to perturb reality just
# enough in the one scenario that we doctest explicitly to
# "fix" the problem. It's also limited enough in scope
# that it probably hasn't badly broken some other use
# case.
p.solver_parameter("presolve_intopt", False)
except KeyError:
# Must not be using GLPK...
pass
try:
p.solve(log=verbose)
except MIPSolverException:
Expand Down

0 comments on commit d106141

Please sign in to comment.