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

Commit

Permalink
HybridBackend: first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Aug 10, 2016
1 parent b630b41 commit 26dad94
Show file tree
Hide file tree
Showing 3 changed files with 1,047 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/module_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,9 @@ def uname_specific(name, value, alternative):
Extension("sage.numerical.backends.interactivelp_backend",
["sage/numerical/backends/interactivelp_backend.pyx"]),

Extension("sage.numerical.backends.hybrid_backend",
["sage/numerical/backends/hybrid_backend.pyx"]),

OptionalExtension("sage.numerical.backends.gurobi_backend",
["sage/numerical/backends/gurobi_backend.pyx"],
libraries = ["stdc++", "gurobi"],
Expand Down
11 changes: 11 additions & 0 deletions src/sage/numerical/backends/generic_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,17 @@ cpdef GenericBackend get_solver(constraint_generation = False, solver = None, ba
kwds['base_ring']=base_ring
return solver(**kwds)

elif type(solver) is tuple:
# Handle tuples as designators for HybridBackend. Not sure if we shouldn't
# just use a factory instead now that we have callables.
from sage.rings.all import RDF
from sage.numerical.backends.hybrid_backend import HybridBackend
if base_ring is not tuple:
base_ring = [RDF] * (len(solver) - 1) + [base_ring]
backends = [ get_solver(constraint_generation=constraint_generation, solver=b, base_ring=r)
for b, r in zip(solver, base_ring) ]
return HybridBackend(backends=backends)

else:
solver = solver.capitalize()

Expand Down
Loading

0 comments on commit 26dad94

Please sign in to comment.