mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-19 07:20:28 +01:00
try/catch file loading
This commit is contained in:
parent
2a84d04edc
commit
b5f12501f9
@ -79,12 +79,14 @@ end
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function warmstart(sett::Settings)
|
function warmstart(sett::Settings)
|
||||||
if sett.warmstart && isfile(filename(sett, :warmstart))
|
try
|
||||||
ws = load(filename(sett, :warmstart), "warmstart")
|
ws = load(filename(sett, :warmstart), "warmstart")
|
||||||
else
|
@info "Loaded $(filename(sett, :warmstart))."
|
||||||
ws = nothing
|
return ws
|
||||||
|
catch
|
||||||
|
@info "Couldn't load $(filename(sett, :warmstart))."
|
||||||
|
return nothing
|
||||||
end
|
end
|
||||||
return ws
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function approximate_by_SOS(sett::Naive,
|
function approximate_by_SOS(sett::Naive,
|
||||||
@ -124,12 +126,17 @@ function approximate_by_SOS(sett::Symmetrized,
|
|||||||
|
|
||||||
isdir(fullpath(sett)) || mkpath(fullpath(sett))
|
isdir(fullpath(sett)) || mkpath(fullpath(sett))
|
||||||
|
|
||||||
if !isfile(filename(sett, :OrbitData))
|
orbit_data = try
|
||||||
|
orbit_data = load(filename(sett, :OrbitData), "OrbitData")
|
||||||
|
@info "Loaded Orbit Data"
|
||||||
|
orbit_data
|
||||||
|
catch
|
||||||
isdefined(parent(orderunit), :basis) || throw("You need to define basis of Group Ring to compute orbit decomposition!")
|
isdefined(parent(orderunit), :basis) || throw("You need to define basis of Group Ring to compute orbit decomposition!")
|
||||||
orbit_data = OrbitData(parent(orderunit), sett.autS)
|
orbit_data = OrbitData(parent(orderunit), sett.autS)
|
||||||
save(filename(sett, :OrbitData), "OrbitData", orbit_data)
|
save(filename(sett, :OrbitData), "OrbitData", orbit_data)
|
||||||
|
orbit_data
|
||||||
end
|
end
|
||||||
orbit_data = load(filename(sett, :OrbitData), "OrbitData")
|
|
||||||
orbit_data = decimate(orbit_data)
|
orbit_data = decimate(orbit_data)
|
||||||
|
|
||||||
@info "Creating SDP problem..."
|
@info "Creating SDP problem..."
|
||||||
@ -267,25 +274,27 @@ function spectral_gap(sett::Settings)
|
|||||||
fp = PropertyT.fullpath(sett)
|
fp = PropertyT.fullpath(sett)
|
||||||
isdir(fp) || mkpath(fp)
|
isdir(fp) || mkpath(fp)
|
||||||
|
|
||||||
if isfile(filename(sett,:Δ))
|
Δ = try
|
||||||
# cached
|
|
||||||
@info "Loading precomputed Δ..."
|
@info "Loading precomputed Δ..."
|
||||||
Δ = loadGRElem(filename(sett,:Δ), sett.G)
|
loadGRElem(filename(sett,:Δ), sett.G)
|
||||||
else
|
catch
|
||||||
# compute
|
# compute
|
||||||
Δ = Laplacian(sett.S, sett.radius)
|
Δ = Laplacian(sett.S, sett.radius)
|
||||||
saveGRElem(filename(sett, :Δ), Δ)
|
saveGRElem(filename(sett, :Δ), Δ)
|
||||||
|
Δ
|
||||||
end
|
end
|
||||||
|
|
||||||
if !sett.warmstart && isfile(filename(sett, :solution))
|
λ, P = try
|
||||||
λ, P = load(filename(sett, :solution), "λ", "P")
|
sett.warmstart && error()
|
||||||
else
|
load(filename(sett, :solution), "λ", "P")
|
||||||
|
catch
|
||||||
λ, P = approximate_by_SOS(sett, Δ^2, Δ;
|
λ, P = approximate_by_SOS(sett, Δ^2, Δ;
|
||||||
solverlog=filename(sett, :solverlog))
|
solverlog=filename(sett, :solverlog))
|
||||||
|
|
||||||
save(filename(sett, :solution), "λ", λ, "P", P)
|
save(filename(sett, :solution), "λ", λ, "P", P)
|
||||||
|
|
||||||
λ < 0 && @warn "Solver did not produce a valid solution!"
|
λ < 0 && @warn "Solver did not produce a valid solution!"
|
||||||
|
λ, P
|
||||||
end
|
end
|
||||||
|
|
||||||
info_strs = ["Numerical metrics of matrix solution:",
|
info_strs = ["Numerical metrics of matrix solution:",
|
||||||
|
Loading…
Reference in New Issue
Block a user