Opened 2 years ago
Closed 2 years ago
#28914 closed enhancement (fixed)
default_mip_solver: Allow solver = a callable
Reported by: | mkoeppe | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-9.1 |
Component: | numerical | Keywords: | |
Cc: | dimpase, dcoudert, tmonteil, vbraun | Merged in: | |
Authors: | Matthias Koeppe | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | 0a70975 (Commits, GitHub, GitLab) | Commit: | 0a7097544f8a6fd8eb9037df37269f475f1fb01e |
Dependencies: | Stopgaps: |
Description
sage.numerical.backends.generic_backend.get_solver
and MixedIntegerLinearProgram(solver=...)
already accept a callable (such as a class inheriting from GenericBackend
) instead of strings such as 'glpk'
:
sage: from sage.numerical.backends.glpk_backend import GLPKBackend sage: MixedIntegerLinearProgram(solver=GLPKBackend)
But default_mip_solver
only accepts strings.
sage: from sage.numerical.backends.glpk_backend import GLPKBackend sage: default_mip_solver(GLPKBackend) AttributeError: type object 'sage.numerical.backends.glpk_backend.GLPKBackend' has no attribute 'capitalize'
Directly changing the module variable containing the setting also does not work; get_solver
breaks in that case:
sage: from sage.numerical.backends.glpk_backend import GLPKBackend sage: import sage.numerical.backends.generic_backend as gb sage: gb.default_solver = GLPKBackend sage: MixedIntegerLinearProgram() ... generic_backend.pyx in sage.numerical.backends.generic_backend.get_solver 1798 1799 else: -> 1800 raise ValueError("'solver' should be set to 'GLPK', 'GLPK/exact', 'Coin', 'CPLEX', 'CVXOPT', 'Gurobi', 'PPL', 'InteractiveLP', None (in which case the default one is used), or a callable.") ValueError: 'solver' should be set to 'GLPK', 'GLPK/exact', 'Coin', 'CPLEX', 'CVXOPT', 'Gurobi', 'PPL', 'InteractiveLP', None (in which case the default one is used), or a callable.
Change History (7)
comment:1 Changed 2 years ago by
- Branch set to u/mkoeppe/default_mip_solver__allow_solver___a_callable
comment:2 Changed 2 years ago by
- Cc dimpase dcoudert tmonteil added
- Commit set to 0a7097544f8a6fd8eb9037df37269f475f1fb01e
- Status changed from new to needs_review
comment:3 Changed 2 years ago by
- Reviewers set to Travis Scrimshaw
- Status changed from needs_review to positive_review
LGTM.
comment:4 Changed 2 years ago by
Thank you! Hoping that we can still get this into 9.0.
comment:5 Changed 2 years ago by
- Cc vbraun added
comment:7 Changed 2 years ago by
- Branch changed from u/mkoeppe/default_mip_solver__allow_solver___a_callable to 0a7097544f8a6fd8eb9037df37269f475f1fb01e
- Resolution set to fixed
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
New commits:
default_mip_solver, get_solver: Handle default solver = a callable