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

Add HiGHS as a solver #224

Merged
merged 11 commits into from
Sep 30, 2024
Merged

Add HiGHS as a solver #224

merged 11 commits into from
Sep 30, 2024

Conversation

trevorb1
Copy link
Member

@trevorb1 trevorb1 commented May 3, 2024

Description

In this PR I add functionality to process HiGHS solution files. Specifically, I have:

  • Added a new ReadHighs class as a read strategy
  • Added tests for the ReadHighs class
  • Documented how to use HiGHS (both from the command line and python)

A couple other notes:

  • As described in the original issue, there are a few solution formats to choose from. I went with the one I called HiGHS Format in the ticket (solution style 1 in HiGHS docs). Motivation is that it only requires one file as an argument and has dual values in this file for if we eventually want to extract out these values.
  • Going with solution style 1 requires us to pass in an option file to the solver from the command line. A little cumbersome, but not a big deal (and this is documented!)
  • For processing a HiGHS solution into a wide format dataframe for otoole, I believe we can do most of the processing through highspy, but I chose not to. It is probably a little more efficient to use their package for bulk processing, but then that adds a dependency to otoole
  • Getting the CLI of HiGHS cant be done through a package manager - instead requires installing a binary and setting up environment variables. Therefore, I also provide an example on how to just use highspy and otoole's python API to process a solution file.
  • I strip out zeros from the solution file to be consistent with how we process CPLEX files; however, this is also an open issue! (see issue [Bug]: CPLEX results processing does not return zero values #214)

Issue Ticket Number

Closes #218

Documentation

I have updated the following pages:

  • Core Functionality with notes on otoole being able to process HiGHS now
  • Examples:
    • Provide instructions on how to install HiGHS CLI
    • Provide instructions on how to install highspy
    • Provide example on how to process HiGHS from command line
    • Provide example on how to process HiGHS from python

Instructions for setting up HiGHS to use from the command line may need to be improved a bit. For example, I had to add HiGHS executable to my .bashrc via the following command, that I did not include:

alias highs="/opt/highs/bin/./highs"
export PATH=$PATH:"/opt/highs/bin/"

I don't think the instructions should necessarily turn into a "how to setup solvers" guide; as there are better resources than otoole for that. However, it can be kinda tedious getting everything working. Additionally, I kinda glossed over install for Windows as I havent done that!

@trevorb1 trevorb1 requested a review from willu47 May 3, 2024 03:50
Copy link
Member

@willu47 willu47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've read through the code, but haven't run it (or followed the instructions in the documents to test implementation - which I'd ideally like to do).

Looks great!

Could you fix the conflicts @trevorb1, and then I'll try to follow through the instructions to test the functionality as you've written it, just to sense check on my own laptop before we merge and release!

@trevorb1 trevorb1 changed the base branch from master to develop September 28, 2024 18:42
@trevorb1
Copy link
Member Author

trevorb1 commented Sep 28, 2024

Thanks for reviewing, @willu47! :)

I updated this PR to address conflicts. I updated the docs to (hopefully) make them clearer.

Also, I was doing a bit of testing with HiGHS and I guess consistent reported columns are not guaranteed. For example, the Type column only seems to get written out if different types of result variables are present (see here). I couldn't find docs on what columns to expect, so we may run into issues in the future when a column name is added or removed. This conditional should catch most of these issues though, I believe.

If anything is unclear in this PR, please just let me know!

@willu47 willu47 merged commit 7dce87e into OSeMOSYS:develop Sep 30, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

[FEATURE]: Add support for HiGHS
2 participants