adfeel220 / Saihu-TSN-Analysis-Tool-Integration

A common interface to easily use multiple TSN analysis tools with simple Python commands
MIT License
15 stars 4 forks source link

lp_solve on linux #4

Open LudoInSpace opened 1 year ago

LudoInSpace commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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

kuetebbg commented 11 months ago

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 commented 10 months ago

Which OS are you on ?

kuetebbg commented 10 months ago

macOS Sonoma 14.2.1

adfeel220 commented 10 months ago

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 commented 8 months ago

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 commented 8 months ago

@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 commented 8 months ago

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