HiGHS solver appears but does not work, HiGHS_CMD does not appear at all
RobLeib opened this issue · comments
Details for the issue
What did you do?
Having just updated PuLP to use the HiGHS_CMD warmstart option, I am now unable to use HiGHS (but it appears when calling pl.listSolvers(onlyAvailable=True)) and I cannot see the HiGHS_CMD solver anymore when listing all solvers. As far as I understand the issue (which is not that much) it does not make sense that the API version of a solver appears without the CMD version appearing. Before updating, there was no problem with using HiGHS.
I'm currently using the version 1.5.3 from HiGHS which was installed using pip.
What did you expect to see?
I was hoping to use the warmstart features that were mentioned in the changelog of 2.8.0
What did you see instead?
When trying to use HiGHS I get the following error messages:
line 1883, in solve ... status = solver.actualSolve(self, **kwargs)
line 481, in actualSolve ... self.createAndConfigureSolver(lp)
line 329, in createAndConfigureSolver ... lp.solverModel.setLogCallback(*callbackTuple)
AttributeError: 'Highs' object has no attribute 'setLogCallback'
Useful extra information
The info below often helps, please fill it out if you're able to. :)
What operating system are you using?
- Windows: ( version: Windows 10 )
- Linux: ( distro: ___ )
- Mac OS: ( version: ___ )
- Other: ___
I'm using python version:
- 3.7
- 3.8
- 3.9
- 3.10
- 3.11
- Other: ___
I installed PuLP via:
- pypi (python -m pip install pulp)
- github (python -m pip install -U git+https://github.com/coin-or/pulp)
- Other: ___ (conda?)
Did you also
- Tried out the latest github version: https://github.com/coin-or/pulp
- Searched for an existing similar issue: https://github.com/coin-or/pulp/issues?utf8=%E2%9C%93&q=is%3Aissue%20
Hello, thanks for reporting.
I have a few questions:
- You mention the
HiGHS_CMD
solver API not working, but then you mention an error (AttributeError: 'Highs' object has no attribute 'setLogCallback'
) that relates to another solver API (HiGHS
). Which one were you using before? Because onlyHiGHS_CMD
has a warmStart option and you seem to be usingHiGHS
. - You say you cannot use the
HiGHS_CMD
solve. Do you havehighs
accessible in your PATH? I.e., if you writehighs.exe
in your command line, does it execute anything? Or fails to find it? - Are you using
msg=True
when solving? There's a known issue with theHiGHS
API (in Linux, but maybe also in Windows now) that relates to this. But only happens with themsg=True
flag is on.
Hi, Thanks for responding,
- I think I might have misunderstood what the HiGHS_CMD solver is. I thought that a _CMD solver should always be available if the "non _CMD" solver is. So if I see "HiGHS" in my solver list, "HiGHS_CMD" should also be there as I thought the difference was just the way PuLP communicates with the solver.
- I cannot find highs.exe, you are right. I'll have a look if I can add to my path
- It seems that removing msg = True did not change anything
I have the same issue going on now. I had to delete and reinstall Anaconda and now I can't use HiGHS. As my friend case, I was also using HiGHS_CMD solver which I have installed through: conda install -c conda-forge highs
I have tried in several different laptops: windows and mac. I have installed anaconda, installed PuLP's latest version. And installed HiGHS. I can also see it in available solvers list but I get same errors trying to run.
In my case I can see both HiGHS and HiGHS_CMD. I receive different errors when I try to use them:
In HiGHS_CMD:
File ~/Desktop/yagmurdangelenler/loopui3.py:191 in run_optimization
result = model.solve(solver)
File ~/anaconda3/lib/python3.11/site-packages/pulp/pulp.py:1872 in solve
status = solver.actualSolve(self, **kwargs)
File ~/anaconda3/lib/python3.11/site-packages/pulp/apis/highs_api.py:152 in actualSolve
process = subprocess.run(command, stdout=sys.stdout, stderr=sys.stderr)
File ~/anaconda3/lib/python3.11/subprocess.py:548 in run
with Popen(*popenargs, **kwargs) as process:
File ~/anaconda3/lib/python3.11/subprocess.py:992 in init
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File ~/anaconda3/lib/python3.11/subprocess.py:1723 in _get_handles
c2pwrite = stdout.fileno()
File ~/anaconda3/lib/python3.11/site-packages/ipykernel/iostream.py:356 in fileno
raise io.UnsupportedOperation(msg)
UnsupportedOperation: fileno
In HiGHS:
result = model.solve(solver)
File ~/anaconda3/lib/python3.11/site-packages/pulp/pulp.py:1872 in solve
status = solver.actualSolve(self, **kwargs)
File ~/anaconda3/lib/python3.11/site-packages/pulp/apis/highs_api.py:481 in actualSolve
self.createAndConfigureSolver(lp)
File ~/anaconda3/lib/python3.11/site-packages/pulp/apis/highs_api.py:329 in createAndConfigureSolver
lp.solverModel.setLogCallback(*callbackTuple)
AttributeError: 'Highs' object has no attribute 'setLogCallback'
Sorry to hear. Do you have a reproducible example that I can test?
As well as python version and, library version and Operating System?
Thanks.
Hello,
I don't know how to supply reproducible example but I would be happy to share details.
Python version: Python 3.11.5
Library version: I'm not sure which version of PuLP I'm using however I have installed latest version lately so I guess it should be 2.8.0
Operating System: I use M2 Macbook Air, Sonoma 14.3.1 I will share the code snippet that I'm trying to run, it might help.
model = LpProblem("The_Production_Maximization_Problem", LpMaximize)
#decision variables
x = pulp.LpVariable.dicts("x", ((i, j, k) for i in range(I + 1) for j in range(J + 1) for k in range(K + 1)), cat="Binary")
y = pulp.LpVariable.dicts("y", ((i, j, k) for i in range(I + 1) for j in range(J + 1) for k in range(K + 1)), cat="Integer")
z = pulp.LpVariable.dicts("z", ((i, j, k) for i in range(I + 1) for j in range(J + 1) for k in range(K + 1)), cat="Binary")
solver = HiGHS_CMD()
result = model.solve(solver)
I have taken out intermediate steps but basically this is what I try to run. Thank you again for your interest.
Can you export your model following some of these instructions? https://coin-or.github.io/pulp/guides/how_to_export_models.html#example-1-json
Can you tell me how (I.e. Which steps) did you install highs? And how do you know it's correctly installed?
Thanks
Hello,
I have tried to export .json file I wish it would work. I'm using excel to import data, if .json doesn't work for this reason I can supply some other files.
I'm also not sure whether I have installed HiGHS correctly because I remember when HiGHS was working for me I was able to locate HiGHS.exe file and run it. Now I try to find it inside Anaconda3 folder and I can't find it. I might have made mistake while installing HiGHS.
The step I have done to install highs is to run below code in terminal:
conda install -c conda-forge highs
MaximizationModel-guncel-github2.json
I really appreciate your help!
It may be an issue with Anaconda. Running in my windows laptop (and in github's CI) it works correctly. Which version of HiGHS is installing in anaconda? in the CI it's using 1.5.3 with python 3.10 and the latest pulp version.