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 support to the HiGHS solver MathOpt #3116

Closed
7 of 9 tasks
SanPen opened this issue Feb 5, 2022 · 25 comments
Closed
7 of 9 tasks

Add support to the HiGHS solver MathOpt #3116

SanPen opened this issue Feb 5, 2022 · 25 comments
Assignees
Labels
Feature Request Missing Feature/Wrapper Lang: C++ Native implementation issue Solver: HiGHS Issue specific to EDU HiGHS Solver: MathOpt MathOpt related issue
Milestone

Comments

@SanPen
Copy link

SanPen commented Feb 5, 2022

Hi,

HiGHS is a magnificent open-source solver that's able to run in parallel, clearly beating CBC in some of the tests I've done in python.

Is there any plan to integrate it into or-tools? (C++)

If not, I'd like to do it myself since the interface looks similar to CBC's. What would be the right way to start?

thanks,
Santiago

Mizux's EDIT(to have task list need to edit the first message...):

  • Create github issue label
  • Incorporate it to CMake build (see below)
  • Incorporate it to bazel build
    • Build HIGHS using bazel
  • Integrate to MathOpt

note: my dev will be in [mizux/highs] (to create) branch and regularly rebased on top of [master]

@SanPen SanPen changed the title Include linking to the HiGHS solver Include interface to the HiGHS solver Feb 5, 2022
@lperron
Copy link
Collaborator

lperron commented Feb 5, 2022

Yes, but we do not have the time to write the interface for it. So we will wait from some contribution for it.

@lperron
Copy link
Collaborator

lperron commented Feb 5, 2022

You can copy the cbc_inteface.cc file

@Mizux Mizux self-assigned this Feb 6, 2022
@Mizux Mizux added this to the Backlog milestone Feb 6, 2022
@Mizux Mizux added Feature Request Missing Feature/Wrapper Lang: C++ Native implementation issue Solver: Linear Solver Related to all Linear Solver (GLOP, BOP, CBC etc...) labels Feb 6, 2022
@Mizux Mizux changed the title Include interface to the HiGHS solver MPSolver: Add support to the HiGHS solver Feb 6, 2022
@Mizux
Copy link
Collaborator

Mizux commented Feb 7, 2022

Todo list:

  • Add option in CMake to enable support (OFF by default maybe ON later)
    e.g.

    or-tools/CMakeLists.txt

    Lines 146 to 153 in 2cb85b4

    # Optional third party solvers (enabled by default)
    CMAKE_DEPENDENT_OPTION(USE_SCIP "Use the Scip solver" ON "BUILD_CXX" OFF)
    message(STATUS "SCIP support: ${USE_SCIP}")
    if(USE_SCIP)
    CMAKE_DEPENDENT_OPTION(BUILD_SCIP "Build the SCIP dependency Library" OFF
    "NOT BUILD_DEPS" ON)
    message(STATUS "Build SCIP: ${BUILD_SCIP}")
    endif()
  • Add FetchContent() section tot build it
    e.g.
    # ##############################################################################
    # GLPK
    # ##############################################################################
    if(BUILD_GLPK)
    message(CHECK_START "Fetching GLPK")
    list(APPEND CMAKE_MESSAGE_INDENT " ")
    set(BUILD_EXAMPLES OFF)
    set(WITH_GMP OFF)
    set(WITH_ODBC OFF)
    set(WITH_MYSQL OFF)
    FetchContent_Declare(
    glpk
    GIT_REPOSITORY https://github.com/Mizux/GLPK.git
    GIT_TAG 5.0
    )
    FetchContent_MakeAvailable(glpk)
    list(POP_BACK CMAKE_MESSAGE_INDENT)
    message(CHECK_PASS "fetched")
    endif()

    ref: https://github.com/ERGO-Code/HiGHS/blob/master/CMakeLists.txt
    note: need to patch their CMake (no CMake config and install rule, no CTest use etc...)
  • Add A FindHIGHS.cmake to find a system-wide installed version
    e.g. https://github.com/google/or-tools/blob/stable/cmake/FindGLPK.cmake
  • Add section in deps.cmake
    e.g.
    if(USE_SCIP)
    if(NOT BUILD_SCIP)
    find_package(SCIP REQUIRED)
    endif()
    endif()
  • Add a define USE_HIGHS in cpp.cmake
    e.g.

    or-tools/cmake/cpp.cmake

    Lines 26 to 28 in 2cb85b4

    if(USE_GLPK)
    list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_GLPK")
    endif()
  • Link MPSovler build to it
    e.g.
    $<$<BOOL:${USE_SCIP}>:libscip>

@gregy4
Copy link

gregy4 commented Apr 28, 2022

Any news about support of highs solver ? Do you work on it, SanPen ?
Latest version 1.2.2 solved one of my unsolvable mip problems by any open source solver (I maybe tried them all) including scip. Since optimal solution was found under 3 seconds, I was very satisfied and maybe there’s time to think about usage of mip solver in some cases for me.

@SanPen
Copy link
Author

SanPen commented Apr 28, 2022

My process was the following:

  • I went through ortools code and discovered that ortools modelling in C++was not as simple as ortools in python (a + b <= 3, etc) which disappointed me.
  • I thought that making my own ortools exactly the way I wanted was less hassle, so I did it. It took me about a week.
  • I integrated Highs rather easily.

So, essentially I thought that fighting a code that I don't understand would be far more complicated than building everything from scratch, so I made my own solver interface with matrix-variable operations embedded.

If we find time to do a gathering with the authors and get dummy-proof guide, I might write the Highs interface, otherwise it is too much for me.

@jajhall
Copy link

jajhall commented Apr 28, 2022

Having first got in touch with @lperron in August of last year, the HiGHS team is now in a position to contribute to writing an OR-Tools interface to HiGHS. Not only will this get around the "not open-source to industry" issue of SCIP, but it will give OR-Tools a better MIP solver than SCIP - see http://plato.asu.edu/ftp/milp.html

That said, I'm interested to read about the experiences of @SanPen and @Mizux on this page, and it would be great if you were able to feed your knowledge into the process.

@lperron
Copy link
Collaborator

lperron commented Apr 28, 2022 via email

@jajhall
Copy link

jajhall commented Apr 28, 2022

I've flagged up this exchange with @galabovaa and she will have a look at what's involved to implement the proto solver.

With your help, I'm sure that we'll make this happen

@Mizux Mizux modified the milestones: Backlog, v10.0 Apr 28, 2022
@Mizux Mizux added the Solver: HiGHS Issue specific to EDU HiGHS label Apr 28, 2022
@Mizux Mizux changed the title MPSolver: Add support to the HiGHS solver Add support to the HiGHS solver [MPSolver, MathOpt, ModelBuilder] Apr 28, 2022
@Mizux
Copy link
Collaborator

Mizux commented May 4, 2022

Dev Note:

current state

see https://github.com/google/or-tools/tree/mizux/highs

To Fix/Patch

  • highs_interface.cc (currently only a copy/paste from scip_interface.cc)
  • HiGHS CMake fix:
    • Use of include(CTEST) and get rid of enable_testing() etc...
    • Why using SHARED_BUILD option then set the CMake orignal one BUILD_SHARED_LIB ...
    • fast build/regular build code refactoring (add_subdirectory(src) x2 !!!)
    • Add install rules for config files and Target.cmake
    • Should use GNUInstallDir than reinventing a borked wheel
    • Check for target ALIAS and namespace
  • Bazelify HiGHS build...

@jajhall
Copy link

jajhall commented May 4, 2022

Thanks. @galabovaa got Bazel to build HiGHS before, so can contribute. She's busy for the next couple of weeks, though

@frederikgeth
Copy link

This is a post to say hi and to confirm interest in this feature! We currently use CLP and GLOP through Java OR tools. We are grateful to everyone for all the existing contributions and excited about the opportunity to start using HiGHS soon. Let me know if there is an opportunity to help in testing.

@jajhall
Copy link

jajhall commented Sep 7, 2022

@galabovaa is now in a position to start work on an OR-Tools <-> HiGHS interface. Can't say how long it will take, but it's definitely happening!

@igrqb
Copy link

igrqb commented Sep 9, 2022

Awesome! Kudos for the great work :)

lperron added a commit that referenced this issue Oct 3, 2022
@wxinix
Copy link

wxinix commented Dec 7, 2022

any updates about ORTools + Highs?

@jajhall
Copy link

jajhall commented Dec 7, 2022

any updates about ORTools + Highs?

Progress has been made, and @galabovaa will continue now that highspy is available from PyPI

@lperron lperron changed the title Add support to the HiGHS solver [MPSolver, MathOpt, ModelBuilder] Add support to the HiGHS solver MathOpt Aug 10, 2023
@FernandoMotkraft
Copy link

@Mizux Hello, I wonder if you folks are still working on this. I would like to move away from SCIP, due to speed on MIP, also due to potential memory leaks on SCIP. Do you folks still have plans to enable HiGHs within or-tools? Is there an approximate timing you could share?

@lperron
Copy link
Collaborator

lperron commented Oct 24, 2023 via email

@FernandoMotkraft
Copy link

Thanks for the info @lperron

@Mizux
Copy link
Collaborator

Mizux commented Oct 25, 2023

It seems we already have Highs support for mathopt internally (i.e. blaze only), I need to export and clean it asap.
But as Laurent say we want to release the incoming v9.8 this week first so we won't integrate it before v9.9 (ETA around Christmas)

@FernandoMotkraft
Copy link

That would be a nice Xmas present @Mizux :)

@individ2016
Copy link

Hello! Any news about HiGHS integration? :)

@Mizux
Copy link
Collaborator

Mizux commented Apr 2, 2024

Currently cleaning HiGHs build system, the objective is to have HiGHS support working for 9.10 this week or next (finger crossed):

@Mizux Mizux modified the milestones: v10.0, v9.10 Apr 26, 2024
@Mizux Mizux added Solver: MathOpt MathOpt related issue and removed Solver: Linear Solver Related to all Linear Solver (GLOP, BOP, CBC etc...) labels Apr 26, 2024
@Mizux
Copy link
Collaborator

Mizux commented Apr 26, 2024

Currently some math_opt tests fail when using HiGHs 1.7.0 (internally we still use 1.4.1) trying to understand what happen

@jajhall
Copy link

jajhall commented Apr 26, 2024

Currently some math_opt tests fail when using HiGHs 1.7.0 (internally we still use 1.4.1) trying to understand what happen

Happy to help you understand why, if you'll share HiGHS output

@Mizux
Copy link
Collaborator

Mizux commented Apr 26, 2024

Currently some math_opt tests fail when using HiGHs 1.7.0 (internally we still use 1.4.1) trying to understand what happen

Happy to help you understand why, if you'll share HiGHS output

@jajhall Thanks, I've create this issue with all information I have (i.e. the potential HiGHs commit), I'm trying to investigate...

@Mizux Mizux closed this as completed Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Missing Feature/Wrapper Lang: C++ Native implementation issue Solver: HiGHS Issue specific to EDU HiGHS Solver: MathOpt MathOpt related issue
Projects
None yet
Development

No branches or pull requests

10 participants