Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 4b42d4a

Browse files
author
Matthias Koeppe
committed
get_solver: Take base_ring's fraction field
This is so one does not accidentally get the InteractiveLP solver by passing base_ring=ZZ.
1 parent 20d6c5a commit 4b42d4a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/sage/numerical/backends/generic_backend.pyx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,13 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba
12961296
or ``None``. If ``solver=None`` (default),
12971297
the default solver is used (see ``default_mip_solver`` method).
12981298
1299-
- ``base_ring`` -- Request a solver that works over this field.
1299+
- ``base_ring`` -- If not ``None``, request a solver that works over this
1300+
(ordered) field. If ``base_ring`` is not a field, its fraction field
1301+
is used.
1302+
1303+
For example, is ``base_ring=ZZ`` is provided, the solver will work over
1304+
the rational numbers. This is unrelated to whether variables are
1305+
constrained to be integers or not.
13001306
13011307
- ``constraint_generation`` -- Only used when ``solver=None``.
13021308
@@ -1320,6 +1326,8 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba
13201326
Real Double Field
13211327
sage: p = get_solver(base_ring=QQ); p
13221328
<sage.numerical.backends.ppl_backend.PPLBackend object at ...>
1329+
sage: p = get_solver(base_ring=ZZ); p
1330+
<sage.numerical.backends.ppl_backend.PPLBackend object at ...>
13231331
sage: p.base_ring()
13241332
Rational Field
13251333
sage: p = get_solver(base_ring=AA); p
@@ -1341,6 +1349,7 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba
13411349
solver = default_mip_solver()
13421350

13431351
if base_ring is not None:
1352+
base_ring = base_ring.fraction_field()
13441353
from sage.rings.all import QQ, RDF
13451354
if base_ring is QQ:
13461355
solver = "Ppl"

0 commit comments

Comments
 (0)