1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-12-25 02:15:29 +01: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)
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
for (s,n) in [
[:fulllog, "full_$(string(now())).log"],
[:solverlog, "solver_$(string(now())).log"],
[: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{}}) =
joinpath(prepath(sett), "delta.jld")
filename(sett::Settings, ::Type{Val{:OrbitData}}) =
joinpath(prepath(sett), "OrbitData.jld")
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)
fp = PropertyT.fullpath(sett)
@ -84,30 +78,20 @@ function check_property_T(sett::Settings)
if isfile(filename(sett,))
# cached
Δ = loadLaplacian(prepath(sett), parent(sett.S[1]))
Δ = loadLaplacian(filename(sett,), sett.G)
else
# compute
Δ = computeLaplacian(sett.S, sett.radius)
save(filename(prepath(sett), :pm), "pm", parent(Δ).pm)
save(filename(prepath(sett), ), "Δ", Δ.coeffs)
Δ = Laplacian(sett.S, sett.radius)
saveLaplacian(filename(sett, ), Δ)
end
files_exist = exists(filename(fullpath(sett), )) &&
exists(filename(fullpath(sett), :P))
if !sett.warmstart && files_exist
λ, P = loadλandP(fullpath(sett))
if !sett.warmstart && isfile(filename(sett, :solution))
λ, P = load(filename(sett, :solution), "λ", "P")
else
warmfile = filename(fullpath(sett), :warm)
if sett.warmstart && exists(warmfile)
ws = load(warmfile, "warmstart")
else
ws = nothing
end
λ, P = computeλandP(sett, Δ,
solverlog=filename(sett, :solverlog))
λ, P, ws = computeλandP(sett, Δ,
solverlog=filename(fullpath(sett), :solverlog))
saveλandP(fullpath(sett), λ, P, ws)
save(filename(sett, :solution), "λ", λ, "P", P)
if λ < 0
warn("Solver did not produce a valid solution!")