1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-14 14:15:28 +01:00

warmstarting is limited to SCS specific hacks

until https://github.com/JuliaOpt/SCS.jl/pull/138 is merged
This commit is contained in:
kalmarek 2019-02-21 14:47:39 +01:00
parent 689bae035e
commit 49c8ffa900
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -173,22 +173,38 @@ end
#
###############################################################################
function warmstart_scs!(m::JuMP.Model, warmstart)
solver_name(m) == "SCS" || throw("warmstarting defined only for SCS!")
primal, dual, slack = warmstart
m.moi_backend.optimizer.model.optimizer.sol.primal = primal
m.moi_backend.optimizer.model.optimizer.sol.dual = dual
m.moi_backend.optimizer.model.optimizer.sol.slack = slack
return m
end
function getwarmstart_scs(m::JuMP.Model)
solver_name(m) == "SCS" || return (primal=Float64[], dual=Float64[], slack=Float64[])
warmstart = (
primal = m.moi_backend.optimizer.model.optimizer.sol.primal,
dual = m.moi_backend.optimizer.model.optimizer.sol.dual,
slack = m.moi_backend.optimizer.model.optimizer.sol.slack
)
return warmstart
end
function solve(m::JuMP.Model, with_optimizer::JuMP.OptimizerFactory, warmstart=nothing)
set_optimizer(m, with_optimizer)
MOIU.attach_optimizer(m)
if warmstart != nothing
p_sol, d_sol, s = warmstart
MathProgBase.SolverInterface.setwarmstart!(m.internalModel, p_sol;
dual_sol=d_sol, slack=s);
warmstart_scs!(m, warmstart)
end
optimize!(m)
status = termination_status(m)
return status, (λ, P, warmstart)
return status, getwarmstart_scs(m)
end
function solve(solverlog::String, m::JuMP.Model, with_optimizer::JuMP.OptimizerFactory, warmstart=nothing)