Skip to content

Commit 2373bbe

Browse files
authored
Use Highs_setSparseSolution for primal starts (#300)
1 parent a346160 commit 2373bbe

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/MOI_wrapper.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,18 +2178,17 @@ function _compute_farkas_variable_dual(model::Optimizer, dual::Vector{Cdouble})
21782178
end
21792179

21802180
function _set_variable_primal_start(model::Optimizer)
2181-
if all(info -> info.start === nothing, values(model.variable_info))
2182-
return
2183-
end
2184-
start = zeros(Cdouble, length(model.variable_info))
2181+
index, value = Cint[], Cdouble[]
21852182
for (x, info) in model.variable_info
2186-
# For the default start, pick the lower bound if it exists, otherwise
2187-
# the minimum of the upper bound and zero.
2188-
default = isfinite(info.lower) ? info.lower : min(info.upper, 0.0)
2189-
start[info.column+1] = something(info.start, default)
2183+
if info.start !== nothing
2184+
push!(index, info.column)
2185+
push!(value, info.start)
2186+
end
2187+
end
2188+
if !isempty(index)
2189+
ret = Highs_setSparseSolution(model, length(index), index, value)
2190+
_check_ret(ret)
21902191
end
2191-
ret = Highs_setSolution(model, start, C_NULL, C_NULL, C_NULL)
2192-
_check_ret(ret)
21932192
return
21942193
end
21952194

0 commit comments

Comments
 (0)