[Solver] HiGHS Installation

1,014 views
Skip to first unread message

Matthew Dumlao

unread,
Oct 5, 2022, 10:27:21 PM10/5/22
to pypsa
Dear All, 

Given the motivation behind HiGHS, I wanted to test it as an alternative to Gurobi. However, I find it difficult to install. I was wondering if  someone was able to install it in a linux system? I am using Ubuntu. Could you please share your installation approach?

I assumed that I have to build the binaries using CMAKE, but when I attempted to do this, I encountered " 'strdup' was not declared in this scope" error. The same issue was raised by another user but the solution is not straight forward and has a caveat.

Is there an easier way to install it? 

Thank you very much!

Matthew

Jack Simpson

unread,
Oct 6, 2022, 7:07:31 PM10/6/22
to pypsa
I think there is a pip installable Python package in the works but I'm not sure when it will be ready.

Fabian Hofmann

unread,
Oct 7, 2022, 5:53:57 AM10/7/22
to py...@googlegroups.com

Hey Matthew,


although this is not a issue directly related to pypsa, happy to help. In the linopy readthedocs there is small section for installing the highs solver on Linux, let me know if you encounter problems:


https://linopy.readthedocs.io/en/latest/solvers.html#highs


Best

Fabian Hofmann

--
You received this message because you are subscribed to the Google Groups "pypsa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pypsa+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pypsa/bae72284-d9dd-438d-b29f-2c687f9a7339n%40googlegroups.com.
-- 
Fabian Hofmann 

Postdoctoral Researcher
Institute of Energy Technology
Technische Universität Berlin
http://fabianhofmann.org/

Group website: https://tub-ensys.github.io/

Peter Klein

unread,
Oct 8, 2022, 6:18:01 AM10/8/22
to pypsa
Hi Matthew

I managed to get HiHJS working by downloading the pre-compiled binaries that HiGHS provided and then pointing PATH and LD_LIBRARY to the relevant folders.

export PATH="${PATH}:/foo/HiGHS/build/bin" 
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/foo/HiGHS/build/lib"

Regards
Peter

Matthew Dumlao

unread,
Oct 10, 2022, 8:50:02 PM10/10/22
to pypsa
Dear Jack,

Yes, I also read that there is an initiative to make it installable via pip.


Dear Fabian,

Thank you! My apologies if this is a bit of topic, but I thought this is a good way to make PyPSA fully open source.

Thank you for sending the readthedocs of linopy. I think the guide is the same. I am just having issues in the compile part.


Dear Peter,

I was also looking into how to use the pre-compiled binaries. I will check your approach.
 

Thank you very much to everyone for the help!

Matthew

Max Parzen

unread,
Oct 14, 2022, 11:57:20 AM10/14/22
to pypsa
Hi Matthew,

I just remember that I also faced an issue in the past during the HiGHS installation.
In my case, the conda base environment was "dirty" and led to compiling conflicts.
Maybe you try to clean your base environment/ or reinstall conda and try to keep
in future the base environment clean (meaning don't install anything there besides e.g. mamba - which is good practice).
Maybe this solves your issue.


Best wishes,

Max Parzen

Toni Vayá Soler

unread,
Nov 13, 2022, 3:53:06 AM11/13/22
to Max Parzen, pypsa
Dear colleagues,

This discussion is very insightful, however I do not succeed in installing HiGHS solver in Windows environment and make it run for Pypsa. I found the pre-compiled binaries for Windows here, but then what?

Any advice/feedback of this community to install HiGHS in Windows for Pypsa would be extremely helpful!

Have a nice sunday,
Antonio

Max Parzen

unread,
Nov 13, 2022, 4:13:44 AM11/13/22
to Toni Vayá Soler, pypsa
Hi Toni,

- Did these instructions not work for you?

- A pip installation is available now for Linux & Mac. Hopefully soon for Windows.

- Regarding binaries, I googled "install pre-compiled binaries" where this article might be helpful:

Best wishes,

Max

--

Maximilian Parzen
PhD Candidate in Energy System Modelling | Energy Storage

Director of PyPSA meets Earth – A Gloabel Open Energy System Model Initiative

School of Engineering | University of Edinburgh

Tel: +49 (0)176 70889068Add me on LinkedIn | Skype: max.parzen

Image preview

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

Toni Vayá Soler

unread,
Nov 13, 2022, 8:25:47 AM11/13/22
to Max Parzen, pypsa
Thanks a lot Max for this information. 

After playing around, it is not obvious to me how to run the Linux instructions in the linopt.py file in a Windows environment. Maybe waiting until having a pip installation process for Windows is the best option.

In the meantime, any advice is most welcome :)

Best regards,
Antonio

Jonas Blomberg Ghini

unread,
Nov 13, 2022, 1:37:51 PM11/13/22
to pypsa
Hi,

I'm not affiliated with the PyPSA team, and follow my instructions at your own peril :-P

There are a few steps necessary to get HiGHS to work with PyPSA in Windows. My memory is a little hazy about the steps here, and I'm not on my work computer to check properly, but this should be the gist of it.

First you need the binaries found on the Julia project linked to from the HiGHS github page. Put the highs.exe file in some known directory and add this directory path to the PATH environment variables in Windows. Once that is done you should be able to just run "highs" in your terminal. The first time I did this, I ran into several messages that said I was missing some different lib-files. I think what sorted that out was to follow the instructions on the HiGHS github about shared libraries.

Once you have gathered all the missing files in the same directory where you put the highs.exe file, you're good to go. I think there are a total of six additional files, and I think they are all in the shared library tarball you find from the HiGHS github link. I seem to remember finding at least one of the missing dll's through some basic googling.

To get HiGHS to actually play nice with PyPSA, a few tweaks are necessary. If you are using the most recent versions of PyPSA, where linopy is integrated (I think mostly the newly released 0.21 version, though I had it working on 0.20.3 as well), you have to use linopy==0.0.13, NOT 0.0.14. The 14 version relies on the highspy package which does not work on Windows at all. The drawback to this is that in order to use HiGHS in the linopy==0.0.13 version, you have to modify the function that runs the "highs" command through subprocess from PyPSA. If you are using an older version of PyPSA, you're on your own, as I never worked with it before 0.20.3.

In the linopy subdirectory you will find a file called solvers.py, and in it a function called "run_highs". There are two typos in this function that prevent highs from working. I've attached my fixed version of the function (which I still need to find time to notify the PyPSA team about, including a PR). Comparing it to the original function in the linopy directory you will see some more differences than just two typos, as I had to modify the function to work properly with unit commitment highs output too.

Anyway, I hope this sets you up!

All the best,
Jonas
fixed_run_highs.py
Reply all
Reply to author
Forward
0 new messages