Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HiGHS solver appears but does not work, HiGHS_CMD does not appear at all #727

Open
5 of 15 tasks
RobLeib opened this issue Jan 24, 2024 · 8 comments
Open
5 of 15 tasks

Comments

@RobLeib
Copy link

RobLeib commented Jan 24, 2024

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:

Did you also

@pchtsp
Copy link
Collaborator

pchtsp commented Jan 29, 2024

Hello, thanks for reporting.

I have a few questions:

  1. 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 only HiGHS_CMD has a warmStart option and you seem to be using HiGHS.
  2. You say you cannot use the HiGHS_CMD solve. Do you have highs accessible in your PATH? I.e., if you write highs.exe in your command line, does it execute anything? Or fails to find it?
  3. Are you using msg=True when solving? There's a known issue with the HiGHS API (in Linux, but maybe also in Windows now) that relates to this. But only happens with the msg=True flag is on.

@RobLeib
Copy link
Author

RobLeib commented Jan 29, 2024

Hi, Thanks for responding,

  1. 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.
  2. I cannot find highs.exe, you are right. I'll have a look if I can add to my path
  3. It seems that removing msg = True did not change anything

@yahyamert
Copy link

yahyamert commented Feb 17, 2024

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'

@pchtsp
Copy link
Collaborator

pchtsp commented Feb 17, 2024

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.

@yahyamert
Copy link

yahyamert commented Feb 17, 2024

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.

@pchtsp
Copy link
Collaborator

pchtsp commented Feb 18, 2024

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

@yahyamert
Copy link

yahyamert commented Feb 19, 2024

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!

@pchtsp
Copy link
Collaborator

pchtsp commented Mar 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants