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

Error using MiniZinc.jl on WSL2 #88

Closed
svaniksharma opened this issue Sep 23, 2024 · 4 comments
Closed

Error using MiniZinc.jl on WSL2 #88

svaniksharma opened this issue Sep 23, 2024 · 4 comments

Comments

@svaniksharma
Copy link

Hi, I installed MiniZinc.jl following the instructions on the README and I got an error while trying to run my script in WSL2 using Ubuntu. I reproduced my steps below.

1. Install package

(@v1.10) pkg> ] add MiniZinc

2. Create and Run Script

Then, I created the following script in a file called matrix.jl:

using JuMP
using MiniZinc

# Only need this for Windows.
# ENV["JULIA_LIBMINIZINC_DIR"] = "C:\\Program Files\\MiniZinc"

function find_matrix(mat_sum)
    n = length(mat_sum[1, :])
    model = Model(() -> MiniZinc.Optimizer{Float64}("highs"))
    @variable(model, 1  x[1:n, 1:n]  n^2, Int)
    @constraint(model, vec(x) in MOI.AllDifferent(n^2))
    for i in 1:n
        @constraint(model, sum(x[i, :]) == mat_sum[1, i])
        @constraint(model, sum(x[:, i]) == mat_sum[2, i])
    end
    optimize!(model)
    display(value.(x))
end


find_matrix([12 18 15; 9 18 18])
find_matrix([33 21 43 39; 24 36 41 35])
find_matrix([43 79 58 60 85; 76 66 44 70 69])

3. Output

And I got the following output after running julia matrix.jl:

Config exception: no solver with tag highs found
minizinc: MiniZinc driver.
Usage: minizinc  [<options>] [-I <include path>] <model>.mzn [<data>.dzn ...] or just <flat>.fzn
More info with "/home/svanik/.julia/artifacts/0a92a5f3d4d8e6995368215f66510c82887bbf6e/bin/minizinc --help"
ERROR: LoadError: failed process: Process(`/home/svanik/.julia/artifacts/0a92a5f3d4d8e6995368215f66510c82887bbf6e/bin/minizinc --solver highs -o /tmp/jl_CcHOLe/model.ozn /tmp/jl_CcHOLe/model.mzn`, ProcessExited(1)) [1]

Stacktrace:
  [1] pipeline_error
    @ ./process.jl:565 [inlined]
  [2] run(::Cmd; wait::Bool)
    @ Base ./process.jl:480
  [3] run
    @ ./process.jl:477 [inlined]
  [4] (::MiniZinc.var"#20#22"{MiniZinc.Optimizer{Float64}, String})(exe::String)
    @ MiniZinc ~/.julia/packages/MiniZinc/HCYTT/src/optimize.jl:76
  [5] (::JLLWrappers.var"#2#3"{MiniZinc.var"#20#22"{MiniZinc.Optimizer{Float64}, String}, String})()
    @ JLLWrappers ~/.julia/packages/JLLWrappers/pG9bm/src/runtime.jl:49
  [6] withenv(::JLLWrappers.var"#2#3"{MiniZinc.var"#20#22"{MiniZinc.Optimizer{Float64}, String}, String}, ::Pair{String, String}, ::Vararg{Pair{String, String}})
    @ Base ./env.jl:257
  [7] withenv_executable_wrapper(f::Function, executable_path::String, PATH::String, LIBPATH::String, adjust_PATH::Bool, adjust_LIBPATH::Bool)
    @ JLLWrappers ~/.julia/packages/JLLWrappers/pG9bm/src/runtime.jl:48
  [8] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:892
  [9] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:889
 [10] minizinc(f::Function; adjust_PATH::Bool, adjust_LIBPATH::Bool)
    @ MiniZinc_jll ~/.julia/packages/JLLWrappers/pG9bm/src/products/executable_generators.jl:22
 [11] minizinc(f::Function)
    @ MiniZinc_jll ~/.julia/packages/JLLWrappers/pG9bm/src/products/executable_generators.jl:19
 [12] _minizinc_exe(f::MiniZinc.var"#20#22"{MiniZinc.Optimizer{Float64}, String})
    @ MiniZinc ~/.julia/packages/MiniZinc/HCYTT/src/optimize.jl:54
 [13] _run_minizinc(dest::MiniZinc.Optimizer{Float64})
    @ MiniZinc ~/.julia/packages/MiniZinc/HCYTT/src/optimize.jl:75
 [14] optimize!(dest::MiniZinc.Optimizer{Float64}, src::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}})
    @ MiniZinc ~/.julia/packages/MiniZinc/HCYTT/src/optimize.jl:137
 [15] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MiniZinc.Optimizer{Float64}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/1fRdT/src/Utilities/cachingoptimizer.jl:321
 [16] optimize!
    @ ~/.julia/packages/MathOptInterface/1fRdT/src/Bridges/bridge_optimizer.jl:367 [inlined]
 [17] optimize!
    @ ~/.julia/packages/MathOptInterface/1fRdT/src/MathOptInterface.jl:122 [inlined]
 [18] optimize!(m::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{MiniZinc.Optimizer{Float64}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}}, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}})
    @ MathOptInterface.Utilities ~/.julia/packages/MathOptInterface/1fRdT/src/Utilities/cachingoptimizer.jl:321
 [19] optimize!(model::Model; ignore_optimize_hook::Bool, _differentiation_backend::MathOptInterface.Nonlinear.SparseReverseMode, kwargs::@Kwargs{})
    @ JuMP ~/.julia/packages/JuMP/6RAQ9/src/optimizer_interface.jl:595
 [20] optimize!
    @ ~/.julia/packages/JuMP/6RAQ9/src/optimizer_interface.jl:546 [inlined]
 [21] find_matrix(mat_sum::Matrix{Int64})
    @ Main ~/devbox/golf/matrix.jl:18
 [22] top-level scope
    @ ~/devbox/golf/matrix.jl:23

When I run this script on Windows using julia matrix.jl in PowerShell after following the instructions in the README, it works just fine. Maybe I'm missing something obvious, but it says that the highs solver is not installed, even though it should have been when the MiniZinc package was installed. I have also installed HiGHS in Julia along with JuMP, so I don't think that's the problem. Any help would be appreciated.

System information:

WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22631.4169
@odow
Copy link
Member

odow commented Sep 24, 2024

What is the result of

julia> import Pkg; Pkg.status()

@svaniksharma
Copy link
Author

This is what I get:

Status `~/.julia/environments/v1.10/Project.toml`
  [a93c6f00] DataFrames v1.6.1
⌃ [31c24e10] Distributions v0.25.109
  [38e38edf] GLM v1.9.0
  [87dc4568] HiGHS v1.9.3
  [0e44f5e4] Hwloc v3.3.0
⌃ [7073ff75] IJulia v1.24.2
  [41ab1584] InvertedIndices v1.3.0
  [4076af6c] JuMP v1.23.2
  [b8f27783] MathOptInterface v1.31.2
⌃ [a7f392d2] MiniZinc v0.2.1
⌃ [6fe1bfb0] OffsetArrays v1.14.0
  [14b8a8f1] PkgTemplates v0.7.52
⌃ [91a5bcdd] Plots v1.40.4
⌃ [c3e4b0f8] Pluto v0.19.42
⌃ [295af30f] Revise v3.5.14
⌃ [90137ffa] StaticArrays v1.9.4
  [2913bbd2] StatsBase v0.34.3
  [bd369af6] Tables v1.12.0
Info Packages marked with ⌃ have new versions available and may be upgradable.

@odow
Copy link
Member

odow commented Sep 24, 2024

⌃ [a7f392d2] MiniZinc v0.2.1

Please update your packages with import Pkg; Pkg.update(). You have an old version of MiniZinc.jl installed.

@svaniksharma
Copy link
Author

After updating, it worked! It's strange it installed an older version. Thank you for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants