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

Latest Cbc build doesn't work with python-mip from pip #239

Open si14 opened 2 years ago

si14 commented 2 years ago

Describe the bug

python-mip doesn't come with aarch64 libs (eg for an M1 mac) (also see #199), so the only way to run it is by building cbc manually. Unfortunately, the documented way of doing that just grabs master, which currently fails the build, but Cbc@a1f4dd2dd02e5739b400de62a0c460b264311809 build successfully and can be used as a dylib. The main issue is it doesn't work with the latest pip version of python-mip (and, as far as I can tell, won't work with master either):

Welcome to the CBC MILP Solver 
Version: devel 
Build Date: Jan 12 2022
Starting solution of the Linear programming relaxation problem using Primal Simplex

Coin0506I Presolve 58925 (-8413) rows, 52054 (-98143) columns and 207325 (-34239) elements
Clp0030I 11 infeas 23.346334, obj 9337.4902 - mu 0.020680678, its 105, 39503 interior
Clp0030I 22 infeas 2.0744055, obj 9410.1855 - mu 0.00025521491, its 105, 41072 interior
Clp0030I 33 infeas 0.045116952, obj 9410.9402 - mu 9.4495685e-06, its 105, 42120 interior
Clp0030I 45 infeas 0.00054603362, obj 9410.9704 - mu 1.1661468e-07, its 105, 42140 interior
Clp1000I sum of infeasibilities 3.75798e-05 - average 6.37757e-10, 9915 fixed columns
Coin0506I Presolve 18479 (-40446) rows, 20478 (-31576) columns and 59541 (-147784) elements
Clp0006I 0  Obj 9410.9708 Dual inf 2141846.9 (20478)
Clp0029I End of values pass after 20478 iterations
Clp0014I Perturbing problem by 0.001% of 1.3997147 - largest nonzero change 2.9996244e-05 ( 0.0026276029%) - largest zero change 2.9984169e-05
Clp0000I Optimal - objective value 9794.4
Clp0000I Optimal - objective value 9794.4
Coin0511I After Postsolve, objective 9794.4, infeasibilities - dual 0 (0), primal 0 (0)
Clp0006I 0  Obj 9794.4
Clp0000I Optimal - objective value 9794.4
Clp0000I Optimal - objective value 9794.4
Clp0000I Optimal - objective value 9794.4
Coin0511I After Postsolve, objective 9794.4, infeasibilities - dual 0 (0), primal 0 (0)
Clp0032I Optimal objective 9794.4 - 0 iterations time 3.662, Presolve 0.11, Idiot 3.53

Starting MIP optimization
Unrecognized parameter - maxSavedSolutions=10, exiting...
Total time (CPU seconds):       3e-05   (Wallclock seconds):       0.000328064
no feasible solution found, lower bound is: -1.7976931348623157e+308

This line https://github.com/coin-or/python-mip/blob/a95310fd9f86bdfd4386a7cb500a38a25c5096ae/mip/cbc.py#L1186 tries to set maxSavedSolutions, which seems to not be recognised by the latest version of cbc.

The problem is solved to completion if I comment that line out manually.

To Reproduce

I believe the description above should qualify.

Expected behavior

I'd expect it to not fail with an error. It would be perfect to have macos aarch64 builds in the wheel, but I understand that's a bit complex. A possible alternative solution would be explicitly pinning the version of cbc that python-mip definitely works with.

Desktop (please complete the following information):

Additional context

None

si14 commented 2 years ago

hey @tuliotoffolo , I'd really appreciate if you can take a look at this. I'm not sure if just commenting that out is a good idea, but this issue makes installing the project significantly more difficult. I might be missing something trivial though!

sebheger commented 2 years ago

@si14. We are working on that topic. But it will take some more time...

aaronsl-hku commented 1 year ago

@sebheger All is understood. As temporary workaround, can we get to know the actual version of pre-compiled Cbc in the python-mip version 1.13.0?

@si14. We are working on that topic. But it will take some more time...

sebheger commented 1 year ago

@aaronsl-hku I actually don't know, since i am supporting the project not from the beginning. I just can inform you that It's not an official release, but can't name you the commit from CBC master. You might look at the commits where cbc lib was lastly replaced in python-mip to identify a close commit number to use. Maybe @h-g-s knows more.

jurasofish commented 1 year ago

can we get to know the actual version of pre-compiled Cbc in the python-mip version 1.13.0?

165 might help

aaronsl-hku commented 1 year ago

Thanks @sebheger and @jurasofish for the information and the prompt replies.

I am in fact building a Docker application and trying to get it working on different devices. As a suggestion it would be a great idea to list out the versions of dependencies on future releases.

h-g-s commented 1 year ago

Hi, we're having some problems in using recent master after the refactor branch was incorporated into Cbc. While this problems aren't solved the latest Cbc commit which would probably be compatible would be this: https://github.com/coin-or/Cbc/commit/96cd94b0400e0012885c64ef1f9a3e7c3459014f

tkralphs commented 1 year ago

This should be easy to fix. Rather than workarounds, why don't we just fix the problem so we can move further towards getting Cbc master out into release? If someone on the python-mip side could be precise about what is going wrong and perhaps identify a fix, I will do whatever is required on the Cbc side.

aberres commented 1 year ago

@h-g-s @tkralphs A bit late to the party, but as the devs in our shop will be provided with new Macs soonish, I wonder if the problems mentioned above have been identified/fixed?

tkralphs commented 1 year ago

I'm still happy to do whatever is needed on the Cbc side, but it would be helpful if someone could verify that this is still an issue and help debug it on the python-mip side. Or at least provide a script that replicates the issue with current master.

Python MIP does work with Cbc 2.10 and @h-g-s pointed out above a commit in the master branch that should work. The coinbrew script supports fetching and building a particular SHA with, e.g., coinbrew fetch@96cd94b.