1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-08-08 15:58:52 +02:00

rework filename(...)

This commit is contained in:
kalmarek 2018-09-16 18:01:04 +02:00
parent afe845e911
commit 2def63c980

View File

@ -55,28 +55,22 @@ suffix(s::Settings) = "$(s.upper_bound)"
prepath(s::Settings) = prefix(s) prepath(s::Settings) = prefix(s)
fullpath(s::Settings) = joinpath(prefix(s), suffix(s)) fullpath(s::Settings) = joinpath(prefix(s), suffix(s))
exists(fname::String) = isfile(fname) || islink(fname) filename(sett::Settings, s::Symbol) = filename(sett, Val{s})
filename(prefix, s::Symbol) = filename(prefix, Val{s}) filename(sett::Settings, ::Type{Val{:fulllog}}) =
joinpath(fullpath(sett), "full_$(string(now())).log")
filename(sett::Settings, ::Type{Val{:solverlog}}) =
joinpath(fullpath(sett), "solver_$(string(now())).log")
@eval begin filename(sett::Settings, ::Type{Val{}}) =
for (s,n) in [ joinpath(prepath(sett), "delta.jld")
[:fulllog, "full_$(string(now())).log"], filename(sett::Settings, ::Type{Val{:OrbitData}}) =
[:solverlog, "solver_$(string(now())).log"], joinpath(prepath(sett), "OrbitData.jld")
[:pm, "pm.jld"],
[, "delta.jld"],
[, "lambda.jld"],
[:P, "SDPmatrix.jld"],
[:warm, "warmstart.jld"],
[:Uπs, "U_pis.jld"],
[:orbits, "orbits.jld"],
[:preps, "preps.jld"],
]
filename(prefix::String, ::Type{Val{$:(s)}}) = joinpath(prefix, :($n))
end
end
filename(sett::Settings, ::Type{Val{:warmstart}}) =
joinpath(fullpath(sett), "warmstart.jld")
filename(sett::Settings, ::Type{Val{:solution}}) =
joinpath(fullpath(sett), "solution.jld")
function check_property_T(sett::Settings) function check_property_T(sett::Settings)
fp = PropertyT.fullpath(sett) fp = PropertyT.fullpath(sett)
@ -84,30 +78,20 @@ function check_property_T(sett::Settings)
if isfile(filename(sett,)) if isfile(filename(sett,))
# cached # cached
Δ = loadLaplacian(prepath(sett), parent(sett.S[1])) Δ = loadLaplacian(filename(sett,), sett.G)
else else
# compute # compute
Δ = computeLaplacian(sett.S, sett.radius) Δ = Laplacian(sett.S, sett.radius)
save(filename(prepath(sett), :pm), "pm", parent(Δ).pm) saveLaplacian(filename(sett, ), Δ)
save(filename(prepath(sett), ), "Δ", Δ.coeffs)
end end
files_exist = exists(filename(fullpath(sett), )) && if !sett.warmstart && isfile(filename(sett, :solution))
exists(filename(fullpath(sett), :P)) λ, P = load(filename(sett, :solution), "λ", "P")
if !sett.warmstart && files_exist
λ, P = loadλandP(fullpath(sett))
else else
warmfile = filename(fullpath(sett), :warm) λ, P = computeλandP(sett, Δ,
if sett.warmstart && exists(warmfile) solverlog=filename(sett, :solverlog))
ws = load(warmfile, "warmstart")
else
ws = nothing
end
λ, P, ws = computeλandP(sett, Δ, save(filename(sett, :solution), "λ", λ, "P", P)
solverlog=filename(fullpath(sett), :solverlog))
saveλandP(fullpath(sett), λ, P, ws)
if λ < 0 if λ < 0
warn("Solver did not produce a valid solution!") warn("Solver did not produce a valid solution!")