1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-23 00:10:28 +01:00

formatting

This commit is contained in:
kalmarek 2020-04-19 21:37:09 +02:00
parent daa29f5223
commit b9a30f02c7
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 17 additions and 18 deletions

View File

@ -1,8 +1,5 @@
############################################################################### ###############################################################################
#
# Settings and filenames # Settings and filenames
#
###############################################################################
abstract type Settings end abstract type Settings end
@ -71,10 +68,7 @@ function filename(path::String, name, extension; prefix=nothing, suffix=nothing)
end end
############################################################################### ###############################################################################
#
# Approximation by SOS (logged & warmstarted) # Approximation by SOS (logged & warmstarted)
#
###############################################################################
function warmstart(sett::Settings) function warmstart(sett::Settings)
warmstart_fname = filename(sett, :warmstart) warmstart_fname = filename(sett, :warmstart)
@ -110,11 +104,16 @@ function approximate_by_SOS(sett::Naive,
if any(isnan, P) if any(isnan, P)
@warn "The solution seems to contain NaNs. Not overriding warmstart.jld" @warn "The solution seems to contain NaNs. Not overriding warmstart.jld"
else else
save(filename(sett, :warmstart), "warmstart", (ws.primal, ws.dual, ws.slack), "P", P, "λ", λ) save(filename(sett, :warmstart),
"warmstart", (ws.primal, ws.dual, ws.slack),
"P", P,
"λ", λ)
end end
save(filename(sett, :warmstart, suffix=Dates.now()), save(filename(sett, :warmstart, suffix=Dates.now()),
"warmstart", (ws.primal, ws.dual, ws.slack), "P", P, "λ", λ) "warmstart", (ws.primal, ws.dual, ws.slack),
"P", P,
"λ", λ)
return λ, P return λ, P
end end
@ -131,7 +130,8 @@ function approximate_by_SOS(sett::Symmetrized,
orbit_data orbit_data
catch ex catch ex
@warn ex.msg @warn ex.msg
isdefined(parent(orderunit), :basis) || throw("You need to define basis of Group Ring to compute orbit decomposition!") Grouprings.hasbasis(parent(orderunit)) ||
throw("You need to define basis of Group Ring to compute orbit decomposition!")
@info "Computing orbit and Wedderburn decomposition..." @info "Computing orbit and Wedderburn 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)
@ -156,11 +156,16 @@ function approximate_by_SOS(sett::Symmetrized,
if any(any(isnan, P) for P in Ps) if any(any(isnan, P) for P in Ps)
@warn "The solution seems to contain NaNs. Not overriding warmstart.jld" @warn "The solution seems to contain NaNs. Not overriding warmstart.jld"
else else
save(filename(sett, :warmstart), "warmstart", (ws.primal, ws.dual, ws.slack), "Ps", Ps, "λ", λ) save(filename(sett, :warmstart),
"warmstart", (ws.primal, ws.dual, ws.slack),
"Ps", Ps,
"λ", λ)
end end
save(filename(sett, :warmstart, suffix=Dates.now()), save(filename(sett, :warmstart, suffix=Dates.now()),
"warmstart", (ws.primal, ws.dual, ws.slack), "Ps", Ps, "λ", λ) "warmstart", (ws.primal, ws.dual, ws.slack),
"Ps", Ps,
"λ", λ)
@info "Reconstructing P..." @info "Reconstructing P..."
@time P = reconstruct(Ps, orbit_data) @time P = reconstruct(Ps, orbit_data)
@ -169,10 +174,7 @@ function approximate_by_SOS(sett::Symmetrized,
end end
############################################################################### ###############################################################################
#
# Checking solution # Checking solution
#
###############################################################################
function certify_SOS_decomposition(elt::GroupRingElem, orderunit::GroupRingElem, function certify_SOS_decomposition(elt::GroupRingElem, orderunit::GroupRingElem,
λ::Number, Q::AbstractMatrix; R::Int=2) λ::Number, Q::AbstractMatrix; R::Int=2)
@ -229,10 +231,7 @@ function spectral_gap(Δ::GroupRingElem, λ::Number, Q::AbstractMatrix; R::Int=2
end end
############################################################################### ###############################################################################
#
# Interpreting the numerical results # Interpreting the numerical results
#
###############################################################################
Kazhdan_constant(λ::Number, N::Integer) = sqrt(2*λ/N) Kazhdan_constant(λ::Number, N::Integer) = sqrt(2*λ/N)
Kazhdan_constant(λ::Interval, N::Integer) = IntervalArithmetic.inf(sqrt(2*λ/N)) Kazhdan_constant(λ::Interval, N::Integer) = IntervalArithmetic.inf(sqrt(2*λ/N))

View File

@ -4,7 +4,7 @@ isopposite(σ::Generic.Perm, τ::Generic.Perm, i=1, j=2) =
isadjacent(σ::Generic.Perm, τ::Generic.Perm, i=1, j=2) = isadjacent(σ::Generic.Perm, τ::Generic.Perm, i=1, j=2) =
(σ[i] == τ[i] && σ[j] τ[j]) || # first equal, second differ (σ[i] == τ[i] && σ[j] τ[j]) || # first equal, second differ
(σ[j] == τ[j] && σ[i] τ[i]) || # sedond equal, first differ (σ[j] == τ[j] && σ[i] τ[i]) || # second equal, first differ
(σ[i] == τ[j] && σ[j] τ[i]) || # first σ equal to second τ (σ[i] == τ[j] && σ[j] τ[i]) || # first σ equal to second τ
(σ[j] == τ[i] && σ[i] τ[j]) # second σ equal to first τ (σ[j] == τ[i] && σ[i] τ[j]) # second σ equal to first τ