Ask Your Question
1

solver parameter not available in Mixed Integer Linear Programming [closed]

asked 2021-02-28 23:20:12 +0100

Max Alekseyev gravatar image

I'm getting the following error, while trying to set up IntegralityFocus for Gurobi backend in Sage 9.2:

sage: from sage_numerical_backends_gurobi.gurobi_backend import GurobiBackend as mysolver                                                                                                                                                               
sage: milp = MixedIntegerLinearProgram(solver=mysolver)                                                                                                                                                                                                 
sage: milp.solver_parameter("IntegralityFocus", 1)                                                                                                                                                                                                      
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
sage_numerical_backends_gurobi/gurobi_backend.pyx in sage_numerical_backends_gurobi.gurobi_backend.GurobiBackend.solver_parameter()

KeyError: 'IntegralityFocus'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-3-65373ae60dc1> in <module>
----> 1 milp.solver_parameter("IntegralityFocus", Integer(1))

/usr/local/SageMath.92/local/lib/python3.8/site-packages/sage/numerical/mip.pyx in sage.numerical.mip.MixedIntegerLinearProgram.solver_parameter (build/cythonized/sage/numerical/mip.c:16597)()
   2470             return self._backend.solver_parameter(name)
   2471         else:
-> 2472             self._backend.solver_parameter(name, value)
   2473 
   2474     cpdef sum(self, L):

sage_numerical_backends_gurobi/gurobi_backend.pyx in sage_numerical_backends_gurobi.gurobi_backend.GurobiBackend.solver_parameter()

ValueError: This parameter is not available. Enabling it may not be so hard, though.

Ok, it says "Enabling it may not be so hard, though." but HOW?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Max Alekseyev
close date 2021-11-10 17:25:14.581705

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-03-01 02:04:46 +0100

Max Alekseyev gravatar image

I've figured it out. I cannot say it was hard, but it was not that easy either. Here are the steps:

  1. Download sage_numerical_backends_gurobi-9.0.0.tar.gz frrom the project page and unpack it.

  2. Since we are going to modify the package content, it's worth to change the version number to 9.0.1 in the package directory name and files VERSION and PKG-INFO.

  3. In file gurobi_backend.pyx add "IntegralityFocus" : "int" to the content of parameters_type, which is essentially a dict with allowed parameters mapped to their types.

  4. Pack everything into sage_numerical_backends_gurobi-9.0.1.tar.gz

  5. Follow this answer on how to install a package custom version in Sage.

edit flag offensive delete link more

Comments

Would you care to open a ticket on this issue and propose your patch ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-03-01 10:13:58 +0100 )edit

@Max Alekseyev -- congratulations on figuring this out!

You can accept your own answer to mark the question as solved.

slelievre gravatar imageslelievre ( 2021-03-01 11:28:34 +0100 )edit

I still hope for a better "not so hard" answer, so I'll keep this my "not so easy" answer unaccepted for a while. As for the ticket, I've already sent a pull request with my patch to the sage_numerical_backends_gurobi github in hope that it will be propagated to the next release of Sage naturally. Do you think I still need to create a Sage ticket?

Max Alekseyev gravatar imageMax Alekseyev ( 2021-03-01 15:39:43 +0100 )edit

@Emmanuel Charpentier I submitted a ticket https://trac.sagemath.org/ticket/31782 but nobody seems to care.

Max Alekseyev gravatar imageMax Alekseyev ( 2021-05-12 23:29:48 +0100 )edit

Question Tools

1 follower

Stats

Asked: 2021-02-28 23:20:12 +0100

Seen: 369 times

Last updated: Mar 01 '21