Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 18, 2024
1 parent 0275e6e commit 75cef38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,15 @@ function check_cb_exception(model::Optimizer)
return
end

is_mip(model) = is_mixedinteger(model.inner) && !model.solve_relaxation
function is_mip(model::Optimizer)
n = @_invoke(
Lib.XPRSgetintattrib(model.inner, Lib.XPRS_ORIGINALMIPENTS, _)::Int,
)
nsos = @_invoke(
Lib.XPRSgetintattrib(model.inner, Lib.XPRS_ORIGINALSETS, _)::Int,
)
return !model.solve_relaxation && n + nsos > 0
end

function _set_MIP_start(model)
colind, solval = Cint[], Cdouble[]
Expand Down
12 changes: 3 additions & 9 deletions src/helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function getcontrol(prob::XpressProblem, name::String)
elseif p_type[] == Lib.XPRS_TYPE_STRING
return @_invoke Lib.XPRSgetstrcontrol(prob, p_id[], _)::String
end
return error("Unrecognized control: $control")
return error("Unrecognized control: $name")
end

function get_control_or_attribute(prob::XpressProblem, name::String)
Expand All @@ -120,20 +120,14 @@ function setcontrol!(prob::XpressProblem, name::String, val)
elseif p_type[] == Lib.XPRS_TYPE_STRING
Lib.XPRSsetstrcontrol(prob, p_id[], String(val))
else
return error("Unrecognized control: $control")
return error("Unrecognized control: $name")
end
end

get_banner() = @_invoke Lib.XPRSgetbanner(_)::String

get_version() = VersionNumber(@_invoke Lib.XPRSgetversion(_)::String)

function is_mixedinteger(prob::XpressProblem)
n = @_invoke Lib.XPRSgetintattrib(prob, Lib.XPRS_ORIGINALMIPENTS, _)::Int
nsos = @_invoke Lib.XPRSgetintattrib(prob, Lib.XPRS_ORIGINALSETS, _)::Int
return n + nsos > 0
end

function get_xpress_error_message(prob::XpressProblem)
last_error = @_invoke Lib.XPRSgetlasterror(prob, _)::String
return lstrip(last_error, ['?'])
Expand All @@ -160,10 +154,10 @@ function Base.show(io::IO, prob::XpressProblem)
@_invoke Lib.XPRSgetintattrib(prob, Lib.XPRS_ORIGINALQELEMS, _)::Int
nnz = @_invoke Lib.XPRSgetintattrib(prob, Lib.XPRS_ELEMS, _)::Int
problem_type = ifelse(qcons > 0, "QCP", ifelse(qelems > 0, "QP", "LP"))
suffix = is_mixedinteger(prob) ? " (MIP)" : ""
nsos = @_invoke Lib.XPRSgetintattrib(prob, Lib.XPRS_ORIGINALSETS, _)::Int
mipents =
@_invoke Lib.XPRSgetintattrib(prob, Lib.XPRS_ORIGINALMIPENTS, _)::Int
suffix = ifelse(mipents + nsos > 0, " (MIP)", "")
print(
io,
"""
Expand Down

0 comments on commit 75cef38

Please sign in to comment.