jump-dev / HiGHS.jl

A Julia interface to the HiGHS solver
https://highs.dev
MIT License
103 stars 14 forks source link

Cannot load HiGHS through JuMP #96

Closed mkyl closed 2 years ago

mkyl commented 2 years ago

I'm unable to access HiGHS in JuMP. I'm running Julia 1.7.0 on macOS 12.2.1. Minimal example:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0 (2021-11-30)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using JuMP, HiGHS

julia> model = Model(HiGHS.Optimizer)
ERROR: UndefVarError: libhighs not defined
Stacktrace:
 [1] Highs_create
   @ ~/.julia/packages/HiGHS/YP79q/src/gen/libhighs_api.jl:28 [inlined]
 [2] empty!(model::HiGHS.Optimizer)
   @ HiGHS ~/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:376
 [3] HiGHS.Optimizer()
   @ HiGHS ~/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:345
 [4] _instantiate_and_check(optimizer_constructor::Type{HiGHS.Optimizer})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:62
 [5] instantiate(optimizer_constructor::Type; with_bridge_type::Type{Float64}, with_names::Bool)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:120
 [6] set_optimizer(model::Model, optimizer_constructor::Type; bridge_constraints::Bool)
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/optimizer_interface.jl:109
 [7] Model(optimizer_factory::Type; bridge_constraints::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/JuMP.jl:287
 [8] Model(optimizer_factory::Type)
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/JuMP.jl:286
 [9] top-level scope
   @ REPL[1]:1
odow commented 2 years ago

What is import Pkg; Pkg.status()?

odow commented 2 years ago

And versioninfo()

odow commented 2 years ago

The fact you've had these two failures, https://github.com/jump-dev/Clp.jl/issues/131, makes me suspicious of your Julia installation.

What happens if you go:

julia> using HiGHS_jll

julia> HiGHS_jll.is_available()
odow commented 2 years ago

Any update on this?

dvaish commented 2 years ago

I am having a similar issue. I installed HiGHS and it was working on my model earlier, but then stopped working seemingly spontaneously. When I run HiGHS_jll.is_available() I get false. I am using an M1 Mac and I have looked around a bit to find that BinaryProvider seems to be causing issues on M1. BinaryProvider is failing to compile. I am unsure of why the model was working before, though.

odow commented 2 years ago

HiGHS does not use BinaryProvider. What is import Pkg; Pkg.status()? and versioninfo()?

dvaish commented 2 years ago

Pkg.status()

Status `~/.julia/environments/v1.7/Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.1
  [b99e7846] BinaryProvider v0.5.10
  [336ed68f] CSV v0.10.3
  [a93c6f00] DataFrames v1.3.2
  [31c24e10] Distributions v0.25.49
  [87dc4568] HiGHS v0.2.3
  [7073ff75] IJulia v1.23.2
  [c601a237] Interact v0.10.4
  [b6b21f68] Ipopt v0.7.0
  [4076af6c] JuMP v0.21.10
  [429524aa] Optim v1.6.2
  [14b8a8f1] PkgTemplates v0.7.26
  [f0f68f2c] PlotlyJS v0.18.8
  [91a5bcdd] Plots v1.26.0
  [f27b6e38] Polynomials v2.0.17
  [2bebaaf1] PopPKBase v0.1.0 `https://github.com/dvaish/PopPKBase.jl#main`
  [d330b81b] PyPlot v2.10.0
  [2913bbd2] StatsBase v0.33.16
  [f3b207a7] StatsPlots v0.14.33
  [0c5d862f] Symbolics v4.3.0
  [dcd9ba68] UncertainData v0.16.0
  [8fd58aa0] HiGHS_jll v0.3.2+0
  [9a3f8284] Random
  [10745b16] Statistics

versioninfo()

Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.2.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 

Julia installed via homebrew for M1 Mac in \opt\homebrew

When I run using JuMP, HiGHS; model = Model(HiGHS.Optimizer)

ERROR: UndefVarError: libhighs not defined
Stacktrace:
 [1] Highs_create
   @ ~/.julia/packages/HiGHS/YP79q/src/gen/libhighs_api.jl:28 [inlined]
 [2] empty!(model::HiGHS.Optimizer)
   @ HiGHS ~/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:376
 [3] HiGHS.Optimizer()
   @ HiGHS ~/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:345
 [4] _instantiate_and_check(optimizer_constructor::Type{HiGHS.Optimizer})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:62
 [5] instantiate(optimizer_constructor::Type; with_bridge_type::Type{Float64}, with_names::Bool)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:120
 [6] set_optimizer(model::Model, optimizer_constructor::Type; bridge_constraints::Bool)
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/optimizer_interface.jl:109
 [7] Model(optimizer_factory::Type; bridge_constraints::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/JuMP.jl:287
 [8] Model(optimizer_factory::Type)
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/JuMP.jl:286
 [9] top-level scope
   @ REPL[27]:1
odow commented 2 years ago

[87dc4568] HiGHS v0.2.3

You have an old version of HiGHS installed that does not support M1. The current version of HiGHS.jl is v1.1.1.

You need to update your packages. You need JuMP 0.22 or 0.23, HiGHS v1.1, and Ipopt v1

If import Pkg; Pkg.update() doesn't work, then run import Pkg; Pkg.pkg"add HiGHS@1" to see which package is preventing you from updating.

Julia installed via homebrew for M1 Mac in \opt\homebrew

Download an official binary from https://julialang.org/downloads/

dvaish commented 2 years ago

Resolved, thank you! For some reason it was downloading old versions of the package. Did not have to change the Julia binary.

odow commented 2 years ago

If you can confirm that the latest version of HiGHS works on the M1, I'll close this issue. It's likely that @mkyl had the same problem of installing an old version.

Similarly to https://github.com/jump-dev/Clp.jl/issues/131#issuecomment-1057625839, I'll note that the M1 is not officially supported by Julia, so you can expect to encounter issues like this.

dvaish commented 2 years ago

On my model, HiGHS does seem to work on the M1. I think there was just an issue where is was consistently downloading the old version (even after removing the package and redownloading it).

odow commented 2 years ago

You probably have a conflict with other packages. In general, you should use a new environment for each project to avoid these compatibility issues.

odow commented 2 years ago

Closing because HiGHS does work on the M1. It's likely that @mkyl had an out-dated version.

@mkyl, if you still have trouble after updating your packages to the latest version, please re-open this issue, or post on the community forum: https://discourse.julialang.org/c/domain/opt/13