Hi everyone, I want to directly call into libhighs
in HiGHS_jll.jl, bypassing JuMP.jl and HiGHS.jl.
First was to come up with a simple toy MILP-problem, to test if it basically works. The idea is to minimize 0.3x + 0.5y
, whereas both variables are binary (0 or 1) and the constraint x + y = 1
has to hold.
Loading the library and getting its version works fine:
using HiGHS_jll
highs_ver = @ccall libhighs.Highs_version()::Cstring
println("HiGHS version: $(unsafe_string(highs_ver))")
This prints
HiGHS version: 1.11.0
So, next I try to formulate and solve the toy problem, using Highs_mipCall
for convenience:
HighsInt = Cint
col_value = zeros(2)
row_value = zeros(1)
model_status_ref = Ref{HighsInt}(0)
mipcall_ret = @ccall libhighs.Highs_mipCall(
2::HighsInt, # num_col
1::HighsInt, # num_row
2::HighsInt, # num_nz
1::HighsInt, # a_format = kHighsMatrixFormatColwise = 1
1::HighsInt, # sense = kHighsObjSenseMinimize = 1
0.0::Cdouble, # offset
[0.2, 0.5]::Ptr{Cdouble}, # col_cost
[-Inf, -Inf]::Ptr{Cdouble}, # col_lower
[Inf, Inf]::Ptr{Cdouble}, # col_upper
[1.0]::Ptr{Cdouble}, # row_lower
[1.0]::Ptr{Cdouble}, # row_upper
[1,2,3]::Ptr{HighsInt}, # a_start
[1, 1]::Ptr{HighsInt}, # a_index
[1.0, 1.0]::Ptr{Cdouble}, # a_value
[1, 1]::Ptr{HighsInt}, # integrality, kHighsVarTypeInteger = 1
col_value::Ptr{Cdouble}, # output: col_value
row_value::Ptr{Cdouble}, # output: row_value
model_status_ref::Ptr{HighsInt} # output: model_status
)::HighsInt
I just get the return value -1, which indicates an error by HiGHS. But no other output to the console, so it’s really hard to debug anything.
Is the problem formulation wrong? (Although I checked on a slightly more complex problem, formulating it in JuMP as well, and then looking at lp_matrix_data(model)
, which looks exactly the same as my manual formulation.)
Is there something wrong about my @ccall
, the arguments, how I hand over the pointers to be filled by the call (last three arguments)?
BTW, there is no difference if I explicitly set col_lower
to [0, 0] and col_upper
to [1, 1].
Any pointers on what I’m doing wrong very welcome .