1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-22 16:05:27 +01:00

use @info, @warn without ()

This commit is contained in:
kalmarek 2019-02-24 00:17:20 +01:00
parent 715d4bf7ab
commit 0b92aebb2f
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
4 changed files with 35 additions and 45 deletions

View File

@ -84,13 +84,13 @@ end
function computeλandP(sett::Naive, Δ::GroupRingElem;
solverlog=tempname()*".log")
@info("Creating SDP problem...")
@info "Creating SDP problem..."
SDP_problem = SOS_problem(Δ^2, Δ, upper_bound=sett.upper_bound)
@info(Base.repr(SDP_problem))
ws = warmstart(sett)
@time status, ws = PropertyT.solve(solverlog, SDP_problem, sett.solver, ws)
@info("Solver's status: $status")
@info "Optimization has finished:" status
P = value.(SDP_problem[:P])
λ = value(SDP_problem[])
@ -112,14 +112,13 @@ function computeλandP(sett::Symmetrized, Δ::GroupRingElem;
orbit_data = load(filename(sett, :OrbitData), "OrbitData")
orbit_data = decimate(orbit_data)
@info("Creating SDP problem...")
@info "Creating SDP problem..."
SDP_problem, varP = SOS_problem(Δ^2, Δ, orbit_data, upper_bound=sett.upper_bound)
@info(Base.repr(SDP_problem))
ws = warmstart(sett)
@time status, ws = PropertyT.solve(solverlog, SDP_problem, sett.solver, ws)
@info("Solver's status: $status")
@info "Optimization has finished:" status
λ = value(SDP_problem[])
Ps = [value.(P) for P in varP]
@ -127,7 +126,7 @@ function computeλandP(sett::Symmetrized, Δ::GroupRingElem;
save(filename(sett, :warmstart),
"warmstart", (ws.primal, ws.dual, ws.slack), "Ps", Ps, "λ", λ)
@info("Reconstructing P...")
@info "Reconstructing P..."
@time P = reconstruct(Ps, orbit_data)
return λ, P
@ -141,10 +140,7 @@ end
function distance_to_positive_cone(Δ::GroupRingElem, λ, Q; R::Int=2)
separator = "-"^76
info_strs = [separator,
"Checking in floating-point arithmetic...",
"λ = "]
@info(join(info_strs, "\n"))
@info "$separator\nChecking in floating-point arithmetic..." λ
eoi = Δ^2-λ*Δ
@info("Computing sum of squares decomposition...")
@ -153,12 +149,11 @@ function distance_to_positive_cone(Δ::GroupRingElem, λ, Q; R::Int=2)
L1_norm = norm(residual,1)
distance = λ - 2.0^(2ceil(log2(R)))*L1_norm
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"))
info_strs = ["Numerical metrics of the obtained SOS:",
"ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ≈ $(aug(residual))",
"‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ≈ $(L1_norm)",
"Floating point distance (to positive cone) ≈"]
@info join(info_strs, "\n") distance
if distance 0
return distance
@ -173,9 +168,8 @@ function distance_to_positive_cone(Δ::GroupRingElem, λ, Q; R::Int=2)
@info("Projecting columns of Q to the augmentation ideal...")
@time Q, check = augIdproj(Interval, Q)
info_strs = ["Checking that sum of every column contains 0.0...",
(check ? "DONE!" : "FAILED!")]
@info(join(info_strs, "\n"))
result = (check ? "Correct." : "FAILED!")
@info "Checking that sum of every column contains 0.0..." result
check || @warn("The following numbers are meaningless!")
@info("Computing sum of squares decomposition...")
@ -184,13 +178,11 @@ function distance_to_positive_cone(Δ::GroupRingElem, λ, Q; R::Int=2)
L1_norm = norm(residual,1)
distance = λ - 2.0^(2ceil(log2(R)))*L1_norm
info_strs = ["Numerical metrics:",
info_strs = ["Numerical metrics of the obtained SOS:",
"ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ∈ $(aug(residual))",
"‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ∈ $(L1_norm)",
"Interval distance (to positive cone) ∈",
"$(distance)",
separator]
@info(join(info_strs, "\n"))
"Interval distance (to positive cone) ∈"]
@info join(info_strs, "\n") distance
return distance.lo
end
@ -220,21 +212,21 @@ function print_summary(sett::Settings)
"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"))
@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
@info("κ($(sett.name), S) ≥ $Kazhdan_κ: Group HAS property (T)!")
@info "κ($(sett.name), S) ≥ $Kazhdan_κ: Group HAS property (T)!"
return true
end
end
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"))
@info join(info_strs, "\n")
return false
end
@ -242,11 +234,9 @@ function spectral_gap(sett::Settings)
fp = PropertyT.fullpath(sett)
isdir(fp) || mkpath(fp)
if isfile(filename(sett,))
# cached
@info("Loading precomputed Δ...")
@info "Loading precomputed Δ..."
Δ = loadGRElem(filename(sett,), sett.G)
else
# compute
@ -263,20 +253,20 @@ function spectral_gap(sett::Settings)
save(filename(sett, :solution), "λ", λ, "P", P)
if λ < 0
@warn("Solver did not produce a valid solution!")
@warn "Solver did not produce a valid solution!"
end
end
info_strs = ["λ = ",
info_strs = ["Numerical metrics of matrix solution:",
"sum(P) = $(sum(P))",
"maximum(P) = $(maximum(P))",
"minimum(P) = $(minimum(P))"]
@info(join(info_strs, "\n"))
@info join(info_strs, "\n")
isapprox(eigvals(P), abs.(eigvals(P))) ||
@warn("The solution matrix doesn't seem to be positive definite!")
@warn "The solution matrix doesn't seem to be positive definite!"
@time Q = real(sqrt( (P.+ P')./2 ))
@time Q = real(sqrt(Symmetric( (P.+ P')./2 )))
certified_sgap = distance_to_positive_cone(Δ, λ, Q, R=sett.radius)
return certified_sgap

View File

@ -33,11 +33,11 @@ function Laplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.GroupElem
end
function Laplacian(S, Id, radius)
@info("Generating metric ball of radius $(2radius)...")
@info "Generating metric ball of radius" radius=2radius
@time E_R, sizes = Groups.generate_balls(S, Id, radius=2radius)
@info("Generated balls of sizes $sizes.")
@info "Generated balls:" sizes
@info("Creating product matrix...")
@info "Creating product matrix..."
rdict = GroupRings.reverse_dict(E_R)
@time pm = GroupRings.create_pm(E_R, rdict, sizes[radius]; twisted=true)

View File

@ -12,19 +12,19 @@ struct OrbitData{T<:AbstractArray{Float64, 2}, GEl<:GroupElem, P<:perm}
end
function OrbitData(RG::GroupRing, autS::Group, verbose=true)
verbose && @info("Decomposing basis of RG into orbits of $(autS)")
verbose && @info "Decomposing basis of RG into orbits of" autS
@time orbs = orbit_decomposition(autS, RG.basis, RG.basis_dict)
@assert sum(length(o) for o in orbs) == length(RG.basis)
verbose && @info("The action has $(length(orbs)) orbits")
verbose && @info "The action has $(length(orbs)) orbits"
verbose && @info("Finding projections in the Group Ring of $(autS)")
verbose && @info "Finding projections in the Group Ring of" autS
@time autS_mps = Projections.rankOne_projections(GroupRing(autS, collect(autS)))
verbose && @info("Finding AutS-action matrix representation")
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("Computing the 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)
@ -34,7 +34,7 @@ function OrbitData(RG::GroupRing, autS::Group, verbose=true)
lpad("multiplicities", 14) * " =" * join(lpad.(multiplicities, 4), ""),
lpad("dimensions", 14) * " =" * join(lpad.(dimensions, 4), "")
]
@info(join(info_strs, "\n"))
@info join(info_strs, "\n")
end
@assert dot(multiplicities, dimensions) == size(RG.pm,1)

View File

@ -90,7 +90,7 @@ function SOS_problem(X::GroupRingElem, orderunit::GroupRingElem, data::OrbitData
λ = JuMP.@variable(m, λ)
end
@info("Adding $(length(data.orbits)) constraints... ")
@info "Adding $(length(data.orbits)) constraints..."
@time addconstraints!(m, Ps, X, orderunit, data)
JuMP.@objective(m, Max, λ)