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

lp_solve on linux #4

Open
LudoInSpace opened this issue Oct 31, 2023 · 12 comments
Open

lp_solve on linux #4

LudoInSpace opened this issue Oct 31, 2023 · 12 comments

Comments

@LudoInSpace
Copy link
Collaborator

LudoInSpace commented Oct 31, 2023

Hey,
an issue we discussed with Stéphan a while ago:

The repo provides a copy of the lp_solve executable.
But when trying to launch on Linux for the first time I had the following error:

Analyzing "/home/thomas/Documents/1-research/2-temp-saihu/Saihu-TSN-Analysis-Tool-Integration/src/temp/tempnet.json" using Panco-TFA,SFA,PLP,ELP...
Cannot execute Panco analysis. Could be the problem with lpsolve or panco itself not installed properly

Digging a bit (printing the exception that you catch), I see:

ELP...[Errno 8] Exec format error: '/home/.../src/saihu/panco/lp_solve'

And indeed executables don't have the same format depending on OS.
On linux/debian, lp_solve is provided by lp-solve apt package, so sudo apt install lp-solve

Then which lp_solve returns on my machine /usr/bin/lp_solve.
So I replaced the saihu/panco/lpSolvePath.py file by commenting-out everything and writing LPSOLVEPATH = ["/usr/bin/lp_solve"].

But of course it's a debian-specific solution. Maybe you can edit panco's file and your installation procedure to solve the installation issue on Linux/Debian while maintaining compatibility with other OSs ?

Ludovic

@adfeel220
Copy link
Owner

Sorry for the late reply.

Since the dependency is not only OS-dependent but machine-dependent, and I don't think the program should automatically download an external program either. A fix I would propose is a quick checker on the availability of lp_solve and show a warning suggesting people to download lp_solve for their system if they want to use panco.

Feel free to propose another solution, otherwise, I will remove the existing lp_solve executable and let the user put in their executable path instead. Then implement a small test to show a warning if the program cannot find any solver. Scheduled to be done in the following days.

@LudoInSpace
Copy link
Collaborator Author

I believe this is the way to go.
Is it possible to check if "lp_solve" is already recognized as a command on the computer, and if so, then overwrite saihu/panco/lpSolvePath.p 's LPSOLVEPATH to equal the result of which lp_solve ? That would be great.

@sbondorf
Copy link

The lp_solve path is hard-coded into the code base, right?

We use macOS 14, on some systems the bundled lp_solveworks, on some it doesn't (after telling the system to trust and execute this binary). Thus, we'd also appreciate using the a system-wide or the user's already installed binary.

@adfeel220
Copy link
Owner

Thank you all for pointing out the issue and I apologize for delaying this issue for quite a long time.
PR #7 should solve the issue based on my proposal above.

I removed the built-in executable to get rid of any confusion. The program now tries to resolve the path of lp_solve in the following manner.

  1. Use the path written in saihu/resources/lpsolve
  2. Try to run which lp_solve and which lpsolve, and apply the result if any of them succeed.
  3. Look for the file in the program entry directory, i.e. ./lp_solve

When none of the above steps finds a valid lp_solve executable, it shows a warning, and a suggestion of how to install lp_solve is printed at the end of the warning according to the user's OS.

I will still keep this issue open for a while in case there's still a problem with some people's machines because I don't have machines of all platforms to test. If everyone is OK with the current solution, I may close this issue afterwards.

@LudoInSpace
Copy link
Collaborator Author

Tested a fresh clone, seems to work on debian on my side.
Thanks a lot!

@kuetebbg
Copy link

I still have problems with lp_solve. I tried the updated version and to set path.json directly to the binary.
I also tried it with the lp_solve from source forge.
Saihu only generates the error message that lpsolve or panco may not be properly installed.

@LudoInSpace
Copy link
Collaborator Author

Which OS are you on ?

@kuetebbg
Copy link

kuetebbg commented Jan 5, 2024

macOS Sonoma 14.2.1

@adfeel220
Copy link
Owner

Some quick test you may try:

  1. Try to execute lpSolvePath.py. If a warning is generated, then it means Saihu does not catch any available lp_solve. That means probably the path you write in paths.json is incorrect or lp_solve is not executable.
  2. Try to test-run your lp_solve binary. You can use the test.lp in the panco folder to see if your machine can execute lp_solve correctly.
  3. If you are sure your binary can execute and executing lpSolvePath.py does not generate any warning. We will try to debug the exact cause.

@kuetebbg
Copy link

kuetebbg commented Mar 9, 2024

Sorry for not answering sooner.
I have tried both: executing lpSolvePath and testing lp_solve with test.lp.
They work both and do not generate any errors.

@adfeel220
Copy link
Owner

@kuetebbg In this case, it probably is not the problem directly from lp_solve. If it's ok for you, please provide the network file you tested and briefly state what happened on your machine so I can reproduce the issue.

@kuetebbg
Copy link

I use the demo file under src/exampe/demo.json.
When I try to run 'python main.py example/demo.json -t panco'
I get the error:
Analyzing "demo.json" using Panco-TFA,SFA,PLP,ELP...Cannot execute Panco analysis. Could be the problem with lpsolve or panco itself not installed properly
Skip. No analysis tool/method is specified
This also happens when I try to run python 'main.py example/demo.json -a '. All tools except Panco execute successfully.

demo.json

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

4 participants