Skip to content

Commit c2f2df0

Browse files
authored
Update VariablePrimalStart between solves (#4)
1 parent 94046ea commit c2f2df0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/MathOptLazy.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,17 @@ end
400400

401401
### MOI.optimize!
402402

403+
function _get_start(model, x)
404+
if !MOI.supports(model, MOI.VariablePrimalStart(), MOI.VariableIndex)
405+
return nothing
406+
end
407+
return Dict(xi => MOI.get(model, MOI.VariablePrimalStart(), xi) for xi in x)
408+
end
409+
403410
function MOI.optimize!(model::Optimizer)
404411
needs_solve = true
405412
x = MOI.get(model, MOI.ListOfVariableIndices())
413+
start = _get_start(model, x)
406414
while needs_solve
407415
needs_solve = false
408416
MOI.optimize!(model.inner)
@@ -413,6 +421,16 @@ function MOI.optimize!(model::Optimizer)
413421
constraints_added += _add_if_necessary(model, v, X)
414422
end
415423
needs_solve = constraints_added > 0
424+
if start !== nothing
425+
for (xi, v) in X
426+
MOI.set(model, MOI.VariablePrimalStart(), xi, v)
427+
end
428+
end
429+
end
430+
end
431+
if start !== nothing
432+
for (xi, v) in start
433+
MOI.set(model, MOI.VariablePrimalStart(), xi, v)
416434
end
417435
end
418436
return

0 commit comments

Comments
 (0)