Error on using highs as solver
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the Model initialization in mip/model.py and the HiGHS loading and cleanup paths in mip/highs.py, which are named in the traceback. Reproduce the Python 3.11/3.12 Windows failures with highspy installed and inspect the expected library path and exported symbols. Done means the documented HiGHS setup works or the documentation clearly states the supported installation and configuration.
Written by the indexing model from the issue text.
Description
I have this code with python 3.11 and python 3.12:
import sys
print(sys.version_info)
from mip import Model, xsum, BINARY
# Create a model
model = Model(solver="highs")
# Add variables
x = [model.add_var(var_type=BINARY) for i in range(5)]
# Add constraints
model += xsum(x) <= 3
model += xsum(x) >= 1
# Set the objective
model.objective = xsum(x)
# Solve the model
model.optimize()
print("Objective:",model.objective_value)
# Check which solver was used
print(f"Solver used: {model.solver_name}")
I additionally installed highspy to be sure highs is available. Highs claims to be fastest open solver ;-) so I wanted to check this. On running I get error:
Traceback (most recent call last):
File "C:\Users\...\Python\xlsb-test\solver_check.py", line 7, in <module>
model = Model(solver="highs")
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\mip\model.py", line 111, in __init__
self.constrs = mip.ConstrList(self)
^^^
UnboundLocalError: cannot access local variable 'mip' where it is not associated with a value
Using
...
model = Model(solver_name=HIGHS)
...
results in
An error occurred while loading the HiGHS library:
not enough values to unpack (expected 1, got 0)
Traceback (most recent call last):
File "C:\Users\...\Python\xlsb-test\solver_check.py", line 13, in <module>
model = Model(solver_name=HIGHS)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\di29394\AppData\Roaming\Python\Python312\site-packages\mip\model.py", line 97, in __init__
self.solver = mip.highs.SolverHighs(self, name, sense)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\di29394\AppData\Roaming\Python\Python312\site-packages\mip\highs.py", line 690, in __init__
raise FileNotFoundError(
FileNotFoundError: HiGHS not found.Please install the `highspy` package, orset the `PMIP_HIGHS_LIBRARY` environment variable.
Exception ignored in: <function SolverHighs.__del__ at 0x000001E57F5DE160>
Traceback (most recent call last):
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\mip\highs.py", line 728, in __del__
self._lib.Highs_destroy(self._model)
^^^^^^^^^
AttributeError: 'SolverHighs' object has no attribute '_lib'
As I said, highspy is installed. Setting PMIP_HIGHS_LIBRARY to the highs.exe path results in
Traceback (most recent call last):
File "C:\Users\...\Python\xlsb-test\solver_check.py", line 13, in <module>
model = Model(solver_name=HIGHS)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\mip\model.py", line 97, in __init__
self.solver = mip.highs.SolverHighs(self, name, sense)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\mip\highs.py", line 703, in __init__
self._model = highslib.Highs_create()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\cffi\api.py", line 914, in __getattr__
make_accessor(name)
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\cffi\api.py", line 910, in make_accessor
accessors[name](name)
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\cffi\api.py", line 840, in accessor_function
value = backendlib.load_function(BType, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: function/symbol 'Highs_create' not found in library 'C:\ProgramData\SOLVERS\highs.exe': error 0x7f. Did you mean: 'Highs_clear'?
Exception ignored in: <function SolverHighs.__del__ at 0x000001B6481C6700>
Traceback (most recent call last):
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\mip\highs.py", line 728, in __del__
self._lib.Highs_destroy(self._model)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\cffi\api.py", line 914, in __getattr__
make_accessor(name)
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\cffi\api.py", line 910, in make_accessor
accessors[name](name)
File "C:\Users\...\AppData\Roaming\Python\Python312\site-packages\cffi\api.py", line 840, in accessor_function
value = backendlib.load_function(BType, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: function/symbol 'Highs_destroy' not found in library 'C:\ProgramData\SOLVERS\highs.exe': error 0x7f
So there seems to exist no way for activating highs. Maybe the docs should be updated with a highs example.
- Dominant language
- Linear Programming
- Stars
- 601
- Forks
- 108
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from coin-or/python-mip
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
coin-or/python-mip#426 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
coin-or/python-mip#425 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
coin-or/python-mip#423 · 4 comments · 3 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
coin-or/python-mip#422 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
coin-or/python-mip#420 · 4 comments ·
All issues in coin-or/python-mip
Similar issues
-
bug CLI custom-model
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
danielmiessler/LifeOS#2234 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100