Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default_mip_solver: Allow solver = a callable #28914

Closed
mkoeppe opened this issue Dec 27, 2019 · 8 comments
Closed

default_mip_solver: Allow solver = a callable #28914

mkoeppe opened this issue Dec 27, 2019 · 8 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 27, 2019

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.

CC: @dimpase @dcoudert @sagetrac-tmonteil @vbraun

Component: numerical

Author: Matthias Koeppe

Branch/Commit: 0a70975

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/28914

@mkoeppe mkoeppe added this to the sage-9.0 milestone Dec 27, 2019
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Dec 27, 2019

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Dec 27, 2019

New commits:

0a70975default_mip_solver, get_solver: Handle default solver = a callable

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Dec 27, 2019

Commit: 0a70975

@tscrim
Copy link
Collaborator

tscrim commented Dec 27, 2019

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Dec 27, 2019

comment:3

LGTM.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Dec 27, 2019

comment:4

Thank you! Hoping that we can still get this into 9.0.

@fchapoton
Copy link
Contributor

comment:6

9.0 is out

@fchapoton fchapoton modified the milestones: sage-9.0, sage-9.1 Jan 1, 2020
@vbraun
Copy link
Member

vbraun commented Jan 5, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants