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 25, 2024
1 parent 7726cd9 commit 842ad09
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7358,6 +7358,24 @@ 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, NotImplementedError, ValueError:
# Must not be using GLPK. The specific exception raised
# depends on the backend; note that several of them live
# outside of the main sagelib repository.
pass
try:
p.solve(log=verbose)
except MIPSolverException:
Expand Down

0 comments on commit 842ad09

Please sign in to comment.