mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-26 17:05:27 +01:00
rename: add load or compute prefixes to function names
to clarify their meaning
This commit is contained in:
parent
2ef67b5195
commit
ebe9490465
@ -34,8 +34,9 @@ filename(prefix, s::Symbol) = filename(prefix, Val{s})
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Laplacian(name::String, G::Group)
|
function loadLaplacian(name::String, G::Group)
|
||||||
if exists(filename(name, :Δ)) && exists(filename(name, :pm))
|
if exists(filename(name, :Δ)) && exists(filename(name, :pm))
|
||||||
|
info("Loading precomputed Δ...")
|
||||||
RG = GroupRing(G, load(filename(name, :pm), "pm"))
|
RG = GroupRing(G, load(filename(name, :pm), "pm"))
|
||||||
Δ = GroupRingElem(load(filename(name, :Δ), "Δ")[:, 1], RG)
|
Δ = GroupRingElem(load(filename(name, :Δ), "Δ")[:, 1], RG)
|
||||||
else
|
else
|
||||||
@ -63,16 +64,16 @@ function computeLaplacian(S, Id, radius)
|
|||||||
@time pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
@time pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
||||||
|
|
||||||
RG = GroupRing(parent(Id), E_R, pm)
|
RG = GroupRing(parent(Id), E_R, pm)
|
||||||
|
|
||||||
Δ = spLaplacian(RG, S)
|
Δ = spLaplacian(RG, S)
|
||||||
return Δ
|
return Δ
|
||||||
end
|
end
|
||||||
|
|
||||||
function λandP(name::String)
|
function loadλandP(name::String)
|
||||||
λ_fname = filename(name, :λ)
|
λ_fname = filename(name, :λ)
|
||||||
P_fname = filename(name, :P)
|
P_fname = filename(name, :P)
|
||||||
|
|
||||||
if exists(λ_fname) && exists(P_fname)
|
if exists(λ_fname) && exists(P_fname)
|
||||||
|
info("Loading precomputed λ, P...")
|
||||||
λ = load(λ_fname, "λ")
|
λ = load(λ_fname, "λ")
|
||||||
P = load(P_fname, "P")
|
P = load(P_fname, "P")
|
||||||
else
|
else
|
||||||
@ -81,13 +82,13 @@ function λandP(name::String)
|
|||||||
return λ, P
|
return λ, P
|
||||||
end
|
end
|
||||||
|
|
||||||
function λandP(name::String, SDP::JuMP.Model, varλ, varP, warmstart=true)
|
|
||||||
|
|
||||||
if warmstart && isfile(filename(name, :warm))
|
if warmstart && isfile(filename(name, :warm))
|
||||||
ws = load(filename(name, :warm), "warmstart")
|
ws = load(filename(name, :warm), "warmstart")
|
||||||
else
|
else
|
||||||
ws = nothing
|
ws = nothing
|
||||||
end
|
end
|
||||||
|
function computeλandP(Δ::GroupRingElem, upper_bound::AbstractFloat, solver, ws=nothing; solverlog=tempname()*".log")
|
||||||
|
|
||||||
function f()
|
function f()
|
||||||
Base.Libc.flush_cstdio()
|
Base.Libc.flush_cstdio()
|
||||||
@ -118,11 +119,10 @@ function check_property_T(name::String, S, Id, solver, upper_bound, tol, radius,
|
|||||||
|
|
||||||
if exists(filename(name, :pm)) && exists(filename(name, :Δ))
|
if exists(filename(name, :pm)) && exists(filename(name, :Δ))
|
||||||
# cached
|
# cached
|
||||||
info("Loading precomputed Δ...")
|
Δ = loadLaplacian(name, parent(S[1]))
|
||||||
Δ = Laplacian(name, parent(S[1]))
|
|
||||||
else
|
else
|
||||||
# compute
|
# compute
|
||||||
Δ = Laplacian(S, Id, radius=radius)
|
Δ = computeLaplacian(S, radius)
|
||||||
save(filename(name, :pm), "pm", parent(Δ).pm)
|
save(filename(name, :pm), "pm", parent(Δ).pm)
|
||||||
save(filename(name, :Δ), "Δ", Δ.coeffs)
|
save(filename(name, :Δ), "Δ", Δ.coeffs)
|
||||||
end
|
end
|
||||||
@ -133,8 +133,7 @@ function check_property_T(name::String, S, Id, solver, upper_bound, tol, radius,
|
|||||||
files_exist = exists(filename(fullpath, :λ)) && exists(filename(fullpath, :P))
|
files_exist = exists(filename(fullpath, :λ)) && exists(filename(fullpath, :P))
|
||||||
|
|
||||||
if !(warm) && files_exist
|
if !(warm) && files_exist
|
||||||
info("Loading precomputed λ, P...")
|
λ, P = loadλandP(fullpath)
|
||||||
λ, P = λandP(fullpath)
|
|
||||||
else
|
else
|
||||||
info("Creating SDP problem...")
|
info("Creating SDP problem...")
|
||||||
SDP_problem, varλ, varP = create_SDP_problem(Δ, constraints(parent(Δ).pm), upper_bound=upper_bound)
|
SDP_problem, varλ, varP = create_SDP_problem(Δ, constraints(parent(Δ).pm), upper_bound=upper_bound)
|
||||||
@ -147,7 +146,6 @@ function check_property_T(name::String, S, Id, solver, upper_bound, tol, radius,
|
|||||||
ws = nothing
|
ws = nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
@time λ, P, ws = λandP(SDP_problem, varλ, varP, warmstart=ws, solverlog=filename(name, :solverlog))
|
|
||||||
|
|
||||||
if λ > 0
|
if λ > 0
|
||||||
save(filename(name, :λ), "λ", λ)
|
save(filename(name, :λ), "λ", λ)
|
||||||
@ -155,6 +153,7 @@ function check_property_T(name::String, S, Id, solver, upper_bound, tol, radius,
|
|||||||
save(filename(name, :warm), "warmstart", ws)
|
save(filename(name, :warm), "warmstart", ws)
|
||||||
else
|
else
|
||||||
throw(ErrorException("Solver did not produce a valid solution: λ = $λ"))
|
throw(ErrorException("Solver did not produce a valid solution: λ = $λ"))
|
||||||
|
λ, P, ws = computeλandP(Δ, upper_bound, solver, ws,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user