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

use multi-line @info where possible

This commit is contained in:
kalmarek 2019-02-21 14:52:20 +01:00
parent a2f8e3dc17
commit fb8ec1578a
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 74 additions and 42 deletions

View File

@ -140,49 +140,57 @@ end
###############################################################################
function distance_to_positive_cone(Δ::GroupRingElem, λ, Q; R::Int=2)
@info("------------------------------------------------------------")
@info("Checking in floating-point arithmetic...")
@info("λ = ")
separator = "-"^76
info_strs = [separator,
"Checking in floating-point arithmetic...",
"λ = "]
@info(join(info_strs, "\n"))
eoi = Δ^2-λ*Δ
@info("Computing sum of squares decomposition...")
@time residual = eoi - compute_SOS(parent(eoi), augIdproj(Q))
@info("ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ≈ $(@sprintf("%.10f", aug(residual)))")
L1_norm = norm(residual,1)
@info("‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ≈ $(@sprintf("%.10f", L1_norm))")
L1_norm = norm(residual,1)
distance = λ - 2.0^(2ceil(log2(R)))*L1_norm
@info("Floating point distance (to positive cone) ≈")
@info("$(@sprintf("%.10f", distance))")
info_strs = ["Numerical metrics:",
"ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ≈ $(@sprintf("%.10f", aug(residual)))",
"‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ≈ $(@sprintf("%.10f", L1_norm))",
"Floating point distance (to positive cone) ≈",
"$(@sprintf("%.10f", distance))"]
@info(join(info_strs, "\n"))
if distance 0
return distance
end
@info("-"^76)
@info("Checking in interval arithmetic...")
λ = @interval(λ)
@info("λ ∈ ")
info_strs = [separator,
"Checking in interval arithmetic...",
"λ ∈ "]
@info(join(info_strs, "\n"))
eoi = Δ^2 - λ*Δ
@info("Projecting columns of Q to the augmentation ideal...")
@time Q, check = augIdproj(Interval, Q)
@info("Checking that sum of every column contains 0.0... ")
@info((check ? "They do." : "FAILED!"))
info_strs = ["Checking that sum of every column contains 0.0...",
(check ? "DONE!" : "FAILED!")]
@info(join(info_strs, "\n"))
check || @warn("The following numbers are meaningless!")
@info("Computing sum of squares decomposition...")
@time residual = eoi - compute_SOS(parent(eoi), Q)
@info("ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ∈ $(aug(residual))")
L1_norm = norm(residual,1)
@info("‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ∈ $(L1_norm)")
L1_norm = norm(residual,1)
distance = λ - 2.0^(2ceil(log2(R)))*L1_norm
@info("Interval distance (to positive cone) ∈")
@info("$(distance)")
@info("-"^76)
info_strs = ["Numerical metrics:",
"ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ∈ $(aug(residual))",
"‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ∈ $(L1_norm)",
"Interval distance (to positive cone) ∈",
"$(distance)",
separator]
@info(join(info_strs, "\n"))
return distance.lo
end
@ -195,8 +203,27 @@ end
Kazhdan(λ::Number, N::Integer) = sqrt(2*λ/N)
function interpret_results(sett::Settings, sgap::Number)
function check_property_T(sett::Settings)
print_summary(sett)
certified_sgap = spectral_gap(sett)
return interpret_results(sett, certified_sgap)
end
function print_summary(sett::Settings)
separator = "="^76
info_strs = [separator,
"Running tests for $(sett.name):",
"Upper bound for λ: $(sett.upper_bound), on radius $(sett.radius).",
"Warmstart: $(sett.warmstart)",
"Results will be stored in ./$(PropertyT.prepath(sett))",
"Solver: $(typeof(sett.solver()))",
"Solvers options: "]
append!(info_strs, [rpad(" $k", 30)* "\t$v" for (k,v) in sett.solver().options])
push!(info_strs, separator)
@info(join(info_strs, "\n"))
end
function interpret_results(sett::Settings, sgap::Number)
if sgap > 0
Kazhdan_κ = Kazhdan(sgap, length(sett.S))
if Kazhdan_κ > 0
@ -204,19 +231,18 @@ function interpret_results(sett::Settings, sgap::Number)
return true
end
end
@info("λ($(sett.name), S) ≥ $sgap < 0: Tells us nothing about property (T)")
info_strs = ["The certified lower bound on the spectral gap is negative:",
"λ($(sett.name), S) ≥ 0.0 > $sgap",
"This tells us nothing about property (T)"]
@info(join(info_strs, "\n"))
return false
end
function check_property_T(sett::Settings)
function spectral_gap(sett::Settings)
fp = PropertyT.fullpath(sett)
isdir(fp) || mkpath(fp)
@info("="^76)
@info("Running tests for $(sett.name):")
@info("Upper bound for λ: $(sett.upper_bound), on radius $(sett.radius).")
@info("Solver is $(sett.solver)")
@info("Warmstart: $(sett.warmstart)")
@info("="^76)
if isfile(filename(sett,))
# cached
@ -241,16 +267,17 @@ function check_property_T(sett::Settings)
end
end
@info("λ = ")
@info("sum(P) = $(sum(P))")
@info("maximum(P) = $(maximum(P))")
@info("minimum(P) = $(minimum(P))")
info_strs = ["λ = ",
"sum(P) = $(sum(P))",
"maximum(P) = $(maximum(P))",
"minimum(P) = $(minimum(P))"]
@info(join(info_strs, "\n"))
isapprox(eigvals(P), abs.(eigvals(P))) ||
@warn("The solution matrix doesn't seem to be positive definite!")
@time Q = real(sqrt( (P.+ P')./2 ))
sgap = distance_to_positive_cone(Δ, λ, Q, R=sett.radius)
certified_sgap = distance_to_positive_cone(Δ, λ, Q, R=sett.radius)
return interpret_results(sett, sgap)
return certified_sgap
end

View File

@ -17,20 +17,25 @@ function OrbitData(RG::GroupRing, autS::Group, verbose=true)
@assert sum(length(o) for o in orbs) == length(RG.basis)
verbose && @info("The action has $(length(orbs)) orbits")
verbose && @info("Projections in the Group Ring of AutS = $autS")
verbose && @info("Finding projections in the Group Ring of $(autS)")
@time autS_mps = Projections.rankOne_projections(GroupRing(autS, collect(autS)))
verbose && @info("AutS-action matrix representatives")
verbose && @info("Finding AutS-action matrix representation")
@time preps = perm_reps(autS, RG.basis[1:size(RG.pm,1)], RG.basis_dict)
@time mreps = matrix_reps(preps)
verbose && @info("Projection matrices Uπs")
verbose && @info("Computing the projection matrices Uπs")
@time Uπs = [orthSVD(matrix_repr(p, mreps)) for p in autS_mps]
multiplicities = size.(Uπs,2)
verbose && @info("multiplicities = $multiplicities")
dimensions = [Int(p[autS()]*Int(order(autS))) for p in autS_mps]
verbose && @info("dimensions = $dimensions")
if verbose
info_strs = ["",
lpad("multiplicities", 14) * " =" * join(lpad.(multiplicities, 4), ""),
lpad("dimensions", 14) * " =" * join(lpad.(dimensions, 4), "")
]
@info(join(info_strs, "\n"))
end
@assert dot(multiplicities, dimensions) == size(RG.pm,1)
return OrbitData(orbs, preps, Uπs, dimensions)