Skip to content

Commit

Permalink
Remove calls to src/api.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 13, 2024
1 parent 52875fd commit 4cb7306
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/MOI/MOI_callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function MOI.submit(
if ilength == MOI.get(model, MOI.NumberOfVariables())
mipsolcol = C_NULL
end
addmipsol(model_cb, ilength, mipsolval, mipsolcol, C_NULL)
@checked Lib.XPRSaddmipsol(model_cb, ilength, mipsolval, mipsolcol, C_NULL)
return MOI.HEURISTIC_SOLUTION_UNKNOWN
end
MOI.supports(::Optimizer, ::MOI.HeuristicSolution{CallbackData}) = true
Expand Down
2 changes: 1 addition & 1 deletion src/Xpress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const XPRS_ATTRIBUTES = Dict{String,Any}(
function initialize()
Libdl.dlopen(libxprs)
userlic()
init()
Lib.XPRSinit(C_NULL)
# Calling free is not necessary since destroyprob is called
# in the finalizer.
return
Expand Down
2 changes: 1 addition & 1 deletion src/helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mutable struct XpressProblem <: CWrapper
)
model = new(ptr, logfile)
if finalize_env
finalizer(destroyprob, model)
finalizer(Lib.XPRSdestroyprob, model)
end
return model
end
Expand Down
4 changes: 2 additions & 2 deletions src/license.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function userlic(;
slicmsg = path_lic #xpauth_path == "dh" ? Array{Cchar}(undef, 1024*8) :

# FIRST call do xprslicense to get BASE LIC
license(lic, slicmsg)
Lib.XPRSlicense(lic, slicmsg)

# convert BASE LIC to GIVEN LIC
lic = liccheck(lic)
Expand All @@ -90,7 +90,7 @@ function userlic(;
buffer = Array{Cchar}(undef, 1024 * 8)
buffer_p = pointer(buffer)
ierr = GC.@preserve buffer begin
license(lic, Cstring(buffer_p))
Lib.XPRSlicense(lic, Cstring(buffer_p))
end

# check LIC TYPE
Expand Down
10 changes: 8 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ end
file_extension = ifelse(vXpress_major <= 38, ".mps", "")
msg = "Xpress internal error:\n\n85 Error: File not found: $(file_extension).\n"
if Xpress.get_version() >= v"41.0.0"
@test_throws Xpress.XpressError(85, msg) Xpress.readprob(prob, "", "")
@test_throws(
Xpress.XpressError(85, msg)
Xpress.Lib.XPRSreadprob(prob, "", ""),
)
else
@test_throws Xpress.XpressError(32, msg) Xpress.readprob(prob, "", "")
@test_throws(
Xpress.XpressError(32, msg),
Xpress.Lib.XPRSreadprob(prob, "", ""),
)
end
end

0 comments on commit 4cb7306

Please sign in to comment.