1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-26 17:05:27 +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,6 +173,24 @@ 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) function solve(m::JuMP.Model, with_optimizer::JuMP.OptimizerFactory, warmstart=nothing)
@ -180,15 +198,13 @@ function solve(m::JuMP.Model, with_optimizer::JuMP.OptimizerFactory, warmstart=n
MOIU.attach_optimizer(m) MOIU.attach_optimizer(m)
if warmstart != nothing if warmstart != nothing
p_sol, d_sol, s = warmstart warmstart_scs!(m, warmstart)
MathProgBase.SolverInterface.setwarmstart!(m.internalModel, p_sol;
dual_sol=d_sol, slack=s);
end end
optimize!(m) optimize!(m)
status = termination_status(m) status = termination_status(m)
return status, (λ, P, warmstart) return status, getwarmstart_scs(m)
end end
function solve(solverlog::String, m::JuMP.Model, with_optimizer::JuMP.OptimizerFactory, warmstart=nothing) function solve(solverlog::String, m::JuMP.Model, with_optimizer::JuMP.OptimizerFactory, warmstart=nothing)