Skip to content

Commit

Permalink
Trac #20832: Add a doctest for GLPK error handling and verbose output
Browse files Browse the repository at this point in the history
The interaction between GLPK error handling and verbose output should be
doctested. This would break without the custom `have_error.patch` for
GLPK in Sage.

URL: https://trac.sagemath.org/20832
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Matthias Koeppe
  • Loading branch information
Release Manager authored and vbraun committed Jun 25, 2016
2 parents 5097e5f + 75e8fe2 commit 45ec27e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/sage/libs/glpk/error.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ def setup_glpk_error_handler():
...
GLPKError: glp_term_out: flag = 12345; invalid parameter
Error detected in file env/stdout.c at line ...
Check that normal terminal output still works, see :trac:`20832`::
sage: def verbose_GLPK():
....: from sage.numerical.backends.generic_backend import get_solver
....: s = get_solver(solver = "GLPK")
....: s.set_verbosity(2)
....: return s
sage: p = MixedIntegerLinearProgram(solver=verbose_GLPK)
sage: x, y = p['x'], p['y']
sage: p.add_constraint(2*x + 3*y <= 6)
sage: p.add_constraint(3*x + 2*y <= 6)
sage: p.add_constraint(x >= 0)
sage: p.set_objective(x + y)
sage: res = p.solve()
0: obj = ...
sage: res # rel tol 1e-15
2.4
"""
glp_term_hook(sage_glpk_term_hook, NULL)
glp_error_hook(sage_glpk_error_hook, NULL)
Expand Down

0 comments on commit 45ec27e

Please sign in to comment.