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

add logger field to sett

This commit is contained in:
kalmarek 2018-01-02 03:17:44 +01:00
parent 35615c34cf
commit a87b587c1a

View File

@ -14,6 +14,7 @@ immutable Settings{T<:AbstractMathProgSolver}
upper_bound::Float64 upper_bound::Float64
tol::Float64 tol::Float64
warmstart::Bool warmstart::Bool
logger
end end
prefix(s::Settings) = s.name prefix(s::Settings) = s.name
@ -178,8 +179,8 @@ function init_model(n, sizes)
end end
function create_SDP_problem(sett::Settings) function create_SDP_problem(sett::Settings)
info(LOGGER, "Loading orbit data....") info(sett.logger, "Loading orbit data....")
@logtime LOGGER SDP_problem, orb_data = OrbitData(sett); @logtime sett.logger SDP_problem, orb_data = OrbitData(sett);
if sett.upper_bound < Inf if sett.upper_bound < Inf
λ = JuMP.getvariable(SDP_problem, ) λ = JuMP.getvariable(SDP_problem, )
@ -187,8 +188,8 @@ function create_SDP_problem(sett::Settings)
end end
t = length(orb_data.laplacian) t = length(orb_data.laplacian)
info(LOGGER, "Adding $t constraints ... ") info(sett.logger, "Adding $t constraints ... ")
@logtime LOGGER addconstraints!(SDP_problem, orb_data) @logtime sett.logger addconstraints!(SDP_problem, orb_data)
return SDP_problem, orb_data return SDP_problem, orb_data
end end
@ -201,14 +202,14 @@ function λandP(m::JuMP.Model, data::OrbitData, warmstart=true)
end end
function λandP(m::JuMP.Model, data::OrbitData, sett::Settings) function λandP(m::JuMP.Model, data::OrbitData, sett::Settings)
info(LOGGER, "Solving SDP problem...") info(sett.logger, "Solving SDP problem...")
λ, Ps = λandP(m, data, sett.warmstart) λ, Ps = λandP(m, data, sett.warmstart)
info(LOGGER, "Reconstructing P...") info(sett.logger, "Reconstructing P...")
preps = load_preps(filename(prepath(sett), :preps), sett.autS) preps = load_preps(filename(prepath(sett), :preps), sett.autS)
@logtime LOGGER recP = reconstruct_sol(preps, data.Us, Ps, data.dims) @logtime sett.logger recP = reconstruct_sol(preps, data.Us, Ps, data.dims)
fname = filename(fullpath(sett), :P) fname = filename(fullpath(sett), :P)
save(fname, "origP", Ps, "P", recP) save(fname, "origP", Ps, "P", recP)
@ -237,17 +238,17 @@ function check_property_T(sett::Settings)
if !sett.warmstart && cond1 && cond2 if !sett.warmstart && cond1 && cond2
λ, P = PropertyT.λandP(fullpath(sett)) λ, P = PropertyT.λandP(fullpath(sett))
else else
info(LOGGER, "Creating SDP problem...") info(sett.logger, "Creating SDP problem...")
SDP_problem, orb_data = create_SDP_problem(sett) SDP_problem, orb_data = create_SDP_problem(sett)
JuMP.setsolver(SDP_problem, sett.solver) JuMP.setsolver(SDP_problem, sett.solver)
λ, P = λandP(SDP_problem, orb_data, sett) λ, P = λandP(SDP_problem, orb_data, sett)
end end
info(LOGGER, "λ = ") info(sett.logger, "λ = ")
info(LOGGER, "sum(P) = $(sum(P))") info(sett.logger, "sum(P) = $(sum(P))")
info(LOGGER, "maximum(P) = $(maximum(P))") info(sett.logger, "maximum(P) = $(maximum(P))")
info(LOGGER, "minimum(P) = $(minimum(P))") info(sett.logger, "minimum(P) = $(minimum(P))")
if λ > 0 if λ > 0
pm_fname = filename(prepath(sett), :pm) pm_fname = filename(prepath(sett), :pm)
@ -276,6 +277,6 @@ function check_property_T(sett::Settings)
return false return false
end end
end end
info(LOGGER, "κ($(sett.name), S) ≥ < 0: Tells us nothing about property (T)") info(sett.logger, "κ($(sett.name), S) ≥ < 0: Tells us nothing about property (T)")
return false return false
end end