coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
516 stars 90 forks source link

Switch to CBC from Gurobi #240

Closed bohong0528 closed 2 years ago

bohong0528 commented 2 years ago

Describe the bug Hi all, I tried to inspect the execution time of project with Gurobi and CBC, but on the Installation page of python mip and my practical experience, I found out if I installed the Gurobi, the mip will automatically choose Gurobi as solver, even I change the solver name to CBC:

Screenshot 2022-01-17 at 11 46 16

Eventually I need to uninstall Gurobi to use CBC.

Expected behavior switching the solver with changing the name of "solver_name"

Desktop (please complete the following information):

Operating System, version: macOS 11.5.2 Python version: 3.9.0 Python-MIP version (we recommend you to test with the latest version): 1.13.0

tuliotoffolo commented 2 years ago

Hello @bohonghellofresh, I wasn't able to reproduce the bug. Would you mind including your code?

bohong0528 commented 2 years ago

Hi @tuliotoffolo, sorry for the late reply: in model.py, there's a desciption said:

nowadays gurobi and cbc are supported. This solver is automatically selected, but you can force the selection of a specific solver with the parameter solver_name.

and I have Gurobi installed, and provide solver_name='CBC' , it does not take effect and still uses Gurobi, although by looking at lines 82 and 86 it seems that it should use CBC in that case.

tuliotoffolo commented 2 years ago

Hi @bohonghellofresh, Well, I've tried but could not reproduce the error here.

bohong0528 commented 2 years ago

@tuliotoffolo Thank you for trying to help! I think it's my mistake that I forget to put solver_name attribute in the Model() it's fixed after doing so. Thanks again!