1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-12-26 02:30:29 +01:00

mv logging to solve_SDP function

This commit is contained in:
kalmarek 2018-08-20 03:45:50 +02:00
parent b509f3686d
commit d2f6682a39
2 changed files with 24 additions and 10 deletions

View File

@ -83,17 +83,15 @@ function loadλandP(name::String)
end
function computeλandP(Δ::GroupRingElem, upper_bound::AbstractFloat, solver, ws=nothing; solverlog=tempname()*".log")
info("Creating SDP problem...")
SDP_problem, varλ, varP = SOS_problem(Δ^2, Δ, upper_bound=upper_bound)
JuMP.setsolver(SDP_problem, solver)
info(Base.repr(SDP_problem))
function f()
Base.Libc.flush_cstdio()
λ, P, w = solve_SDP(SDP, varλ, varP, warmstart=ws)
Base.Libc.flush_cstdio()
return λ, P, w
end
@time λ, P, ws = solve_SDP(SDP_problem, varλ, varP, ws, solverlog=solverlog)
solverlog = open(filename(name, :solverlog),"a+")
λ, P, warmstart = redirect_stdout(f, solverlog)
close(solverlog)
return λ, P, ws
end
function saveλandP(name, λ, P, ws)
save(filename(name, ), "λ", λ)

View File

@ -55,7 +55,23 @@ function create_SDP_problem(Δ::GroupRingElem, matrix_constraints; upper_bound=I
return m, λ, P
end
function solve_SDP(m, varλ, varP; warmstart=nothing)
function solve_SDP(model::JuMP.Model, varλ, varP, ws=nothing; solverlog=tempname()*".log")
function f()
Base.Libc.flush_cstdio()
λ, P, ws = PropertyT.solve(model, varλ, varP, warmstart=ws)
Base.Libc.flush_cstdio()
return λ, P, ws
end
log = open(solverlog, "a+")
λ, P, ws = redirect_stdout(f, log)
close(log)
return λ, P, ws
end
function solve(m::JuMP.Model, varλ, varP; warmstart=nothing)
traits = JuMP.ProblemTraits(m, relaxation=false)