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:
parent
b509f3686d
commit
d2f6682a39
@ -83,17 +83,15 @@ function loadλandP(name::String)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function computeλandP(Δ::GroupRingElem, upper_bound::AbstractFloat, solver, ws=nothing; solverlog=tempname()*".log")
|
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()
|
@time λ, P, ws = solve_SDP(SDP_problem, varλ, varP, ws, solverlog=solverlog)
|
||||||
Base.Libc.flush_cstdio()
|
|
||||||
λ, P, w = solve_SDP(SDP, varλ, varP, warmstart=ws)
|
|
||||||
Base.Libc.flush_cstdio()
|
|
||||||
return λ, P, w
|
|
||||||
end
|
|
||||||
|
|
||||||
solverlog = open(filename(name, :solverlog),"a+")
|
return λ, P, ws
|
||||||
λ, P, warmstart = redirect_stdout(f, solverlog)
|
end
|
||||||
close(solverlog)
|
|
||||||
|
|
||||||
function saveλandP(name, λ, P, ws)
|
function saveλandP(name, λ, P, ws)
|
||||||
save(filename(name, :λ), "λ", λ)
|
save(filename(name, :λ), "λ", λ)
|
||||||
|
18
src/SDPs.jl
18
src/SDPs.jl
@ -55,7 +55,23 @@ function create_SDP_problem(Δ::GroupRingElem, matrix_constraints; upper_bound=I
|
|||||||
return m, λ, P
|
return m, λ, P
|
||||||
end
|
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)
|
traits = JuMP.ProblemTraits(m, relaxation=false)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user