Skip to content

Commit 8f46a63

Browse files
author
Release Manager
committed
gh-35773: Document that GLPK/exact can be inexact <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description The GLPK/exact linear programming (LP) backend isn't exact because rationals are converted to doubles to be passed to the backend. This means that, despite solving LPs exactly over the rationals, the solver can silently solve a rounded version of your LP. For example, coefficients of 1/3 are handled incorrectly as they are rounded to some 0.3333333ish number that fits in a double-precision float. This PR simply expands the relevant documentation to explain more carefully that this can lead to problems. Fixes #35727. The modified files lie in the ```src/``` subdirectory, are changes required to files with the same relative path under such as ```/build/pkgs/sagemath_environment/...```, ```build/pkgs/sagemath_repl/...```, and ```pkgs/sagemath-repl/...```? <!-- Describe your changes here in detail. --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35773 Reported by: Ewan Davies Reviewer(s): Ewan Davies, Matthias Köppe
2 parents 5272959 + 7b4046c commit 8f46a63

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/sage/numerical/backends/glpk_backend.pyx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,14 @@ cdef class GLPKBackend(GenericBackend):
10121012
(`get_col_dual` etc.) or tableau data (`get_row_stat` etc.),
10131013
one needs to switch to "simplex_only" before solving.
10141014
1015-
GLPK also has an exact rational simplex solver. The only
1016-
access to data is via double-precision floats, however. It
1017-
reconstructs rationals from doubles and also provides results
1018-
as doubles.
1015+
GLPK also has an exact rational simplex solver. The only access
1016+
to data is via double-precision floats, which means that
1017+
rationals in the input data may be rounded before the exact
1018+
solver sees them. Thus, it is unreasonable to expect that
1019+
arbitrary LPs with rational coefficients are solved exactly.
1020+
Once the LP has been read into the backend, it reconstructs
1021+
rationals from doubles and does solve exactly over the rationals,
1022+
but results are returned as as doubles.
10191023
10201024
EXAMPLES::
10211025

src/sage/numerical/backends/glpk_exact_backend.pyx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ cdef class GLPKExactBackend(GLPKBackend):
1919
"""
2020
MIP Backend that runs the GLPK solver in exact rational simplex mode.
2121
22-
The only access to data is via double-precision floats, however. It
23-
reconstructs rationals from doubles and also provides results
24-
as doubles.
22+
The only access to data is via double-precision floats, which
23+
means that rationals in the input data may be rounded before
24+
the exact solver sees them. Thus, it is unreasonable to expect
25+
that arbitrary LPs with rational coefficients are solved exactly.
26+
Once the LP has been read into the backend, it reconstructs
27+
rationals from doubles and does solve exactly over the rationals,
28+
but results are returned as as doubles.
2529
2630
There is no support for integer variables.
2731
"""

0 commit comments

Comments
 (0)