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
538 stars 95 forks source link

Highs not working #394

Closed andreaswiese closed 1 week ago

andreaswiese commented 3 weeks ago

Describe the bug

When I try to use the solver HiGHS in Python-MIP, I get the error message

FileNotFoundError: HiGHS not found.Please install the highspy package, orset the PMIP_HIGHS_LIBRARY environment variable.

To Reproduce

Small example:

from mip import *

p = [10, 13, 18, 31, 7, 15] w = [11, 15, 20, 35, 10, 33] c, I = 47, range(len(w))

m = Model("knapsack", sense=MAXIMIZE, solver_name="highs")

x = [m.add_var(var_type=BINARY) for i in I]

m.objective = maximize(xsum(p[i] * x[i] for i in I))

m += xsum(w[i] * x[i] for i in I) <= c

m.optimize()

Expected behavior Python-MIP solves the MIP

Desktop (please complete the following information):

Workaround I noticed that model.py executes the command

import mip.highs

Then, highs.py searches for a HiGHS library with the pattern

pattern = "highs_bindings.*.so"

In my folder /lib/python3.12/site-packages/highspy there is no library following this pattern and I believe that this causes this error. However, there is a library called "_core.cpython-312-x86_64-linux-gnu.so" and I believe that this is the library that highs.py is looking for. Therefore, I created a copy of this library called "highs_bindings._core.cpython-312-x86_64-linux-gnu.so" and then Python-MIP correctly solves the MIP with HiGHS.

Maybe highs.py just needs to search for a different file pattern when it searches for the HiGHS library.

rschwarz commented 1 week ago

This is maybe related (and/or fixed) by #377.

andreaswiese commented 1 week ago

I agree that this is the same problem. I believe that the fix for #377 solves this problem as well. It seems that I simply need to use the latest version in the repository instead of 1.6.0rc0. Thank you!