From f5920874b2a252d28e7a093fbbbc3827cc7dd072 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 24 Oct 2024 17:27:45 -0400 Subject: [PATCH] src/sage/graphs/generic_graph.py: work around doctest hang 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 https://github.com/sagemath/sage/issues/34575 Closes https://github.com/sagemath/sage/issues/38831 --- src/sage/graphs/generic_graph.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 3ae14de7877..b0045f80d07 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -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 + + from sage.numerical.backends.glpk_backend import GLPKBackend + if isinstance(p.get_backend(), GLPKBackend): + # 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) + try: p.solve(log=verbose) except MIPSolverException: