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

replace Settings.warmstart by force_compute

This commit is contained in:
kalmarek 2019-10-30 23:56:53 +01:00
parent a5a3d9d069
commit dc14b2fd95
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
5 changed files with 42 additions and 43 deletions

View File

@ -16,7 +16,7 @@ struct Naive{El} <: Settings
upper_bound::Float64
solver::JuMP.OptimizerFactory
warmstart::Bool
force_compute::Bool
end
struct Symmetrized{El} <: Settings
@ -28,19 +28,19 @@ struct Symmetrized{El} <: Settings
upper_bound::Float64
solver::JuMP.OptimizerFactory
warmstart::Bool
force_compute::Bool
end
function Settings(name::String,
G::Union{Group, NCRing}, S::AbstractVector{El}, solver::JuMP.OptimizerFactory;
halfradius::Integer=2, upper_bound::Float64=1.0, warmstart=true) where El <: Union{GroupElem, NCRingElem}
return Naive(name, G, S, halfradius, upper_bound, solver, warmstart)
halfradius::Integer=2, upper_bound::Float64=1.0, force_compute=false) where El <: Union{GroupElem, NCRingElem}
return Naive(name, G, S, halfradius, upper_bound, solver, force_compute)
end
function Settings(name::String,
G::Union{Group, NCRing}, S::AbstractVector{El}, autS::Group, solver::JuMP.OptimizerFactory;
halfradius::Integer=2, upper_bound::Float64=1.0, warmstart=true) where El <: Union{GroupElem, NCRingElem}
return Symmetrized(name, G, S, autS, halfradius, upper_bound, solver, warmstart)
halfradius::Integer=2, upper_bound::Float64=1.0, force_compute=false) where El <: Union{GroupElem, NCRingElem}
return Symmetrized(name, G, S, autS, halfradius, upper_bound, solver, force_compute)
end
prefix(s::Naive) = s.name
@ -81,11 +81,11 @@ end
function warmstart(sett::Settings)
warmstart_fname = filename(sett, :warmstart)
try
ws = load(filename(sett, :warmstart), "warmstart")
ws = load(warmstart_fname, "warmstart")
@info "Loaded $warmstart_fname."
return ws
catch ex
@warn "$(ex.msg). Not providing a warmstart to the solver."
@warn "$(ex.msg). Could not provide a warmstart to the solver."
return nothing
end
end
@ -239,23 +239,22 @@ end
Kazhdan(λ::Number, N::Integer) = sqrt(2*λ/N)
function check_property_T(sett::Settings)
print_summary(sett)
@info 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):",
function Base.show(io::IO, sett::Settings)
info_strs = ["PropertyT Settings:",
"Group: $(sett.name)",
"Upper bound for λ: $(sett.upper_bound), on halfradius $(sett.halfradius).",
"Warmstart: $(sett.warmstart)",
"Results will be stored in ./$(PropertyT.prepath(sett))",
"Force computations: $(sett.force_compute);",
"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")
push!(info_strs, "="^76)
print(io, join(info_strs, "\n"))
end
function interpret_results(sett::Settings, sgap::Number)
@ -300,7 +299,7 @@ function spectral_gap(sett::Settings)
return λ, P
end
if sett.warmstart
if sett.force_compute
λ, P = compute(sett, Δ)
else
λ, P =try

View File

@ -8,7 +8,7 @@
rm("SL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, with_SCS(20000, accel=20); upper_bound=0.1)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0
@ -23,7 +23,7 @@
rm("SL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, with_SCS(1000, accel=20); upper_bound=0.1)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ > 0.0999
@ -39,9 +39,9 @@
rm("SAut(F$N)", recursive=true, force=true)
sett = PropertyT.Settings("SAut(F$N)", G, S, with_SCS(10000);
upper_bound=0.15, warmstart=false)
upper_bound=0.15)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0

View File

@ -8,22 +8,22 @@
rm("oSL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
upper_bound=0.27, warmstart=false)
upper_bound=0.27, force_compute=false)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0
@test PropertyT.interpret_results(sett, λ) == false
# second run just checks the solution due to warmstart=false above
# second run just checks the solution due to force_compute=false above
@test λ == PropertyT.spectral_gap(sett)
@test PropertyT.check_property_T(sett) == false
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
upper_bound=0.27, warmstart=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(4000, accel=20);
upper_bound=0.27, force_compute=true)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ > 0.269999
@ -36,10 +36,10 @@
##########
# Symmetrizing by PermGroup(3):
sett = PropertyT.Settings("SL($N,Z)", G, S, PermGroup(N), with_SCS(4000, accel=20);
upper_bound=0.27, warmstart=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, PermGroup(N), with_SCS(4000, accel=20, warm_start=false);
upper_bound=0.27, force_compute=true)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ > 0.269999
@ -54,22 +54,22 @@
rm("oSL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
upper_bound=1.3, warmstart=false)
upper_bound=1.3, force_compute=false)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0
@test PropertyT.interpret_results(sett, λ) == false
# second run just checks the solution due to warmstart=false above
# second run just checks the solution due to force_compute=false above
@test λ == PropertyT.spectral_gap(sett)
@test PropertyT.check_property_T(sett) == false
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(5000, accel=20);
upper_bound=1.3, warmstart=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(5000, accel=20, warm_start=true);
upper_bound=1.3, force_compute=true)
PropertyT.print_summary(sett)
@info sett
λ = PropertyT.spectral_gap(sett)
@test λ > 1.2999
@ -89,9 +89,9 @@
rm("oSAut(F$N)", recursive=true, force=true)
sett = PropertyT.Settings("SAut(F$N)", G, S, autS, with_SCS(1000);
upper_bound=0.15, warmstart=false)
upper_bound=0.15)
PropertyT.print_summary(sett)
@info sett
@test PropertyT.check_property_T(sett) == false
end

View File

@ -136,7 +136,7 @@ end
@test 2^2*norm(residual, 1) < λ # i.e. we can certify positivity
@test 2^2*norm(residual, 1) < λ/100
@test 2^2*norm(residual, 1) < 2λ/100
end
@testset "Adj₃ is SOS" begin
@ -205,7 +205,7 @@ end
Base.Libc.flush_cstdio()
@info "obtained λ and residual" λ norm(residual, 1)
@test 2^2*norm(residual, 1) > λ # i.e. we can certify positivity
@test 2^2*norm(residual, 1) > λ # i.e. we can't certify positivity
end
@testset "Adj₄ + Op₄ is SOS" begin

View File

@ -6,10 +6,10 @@ using JLD
using JuMP, SCS
with_SCS(iters; accel=1, eps=1e-10) =
with_SCS(iters; accel=1, eps=1e-10, warm_start=true) =
with_optimizer(SCS.Optimizer,
linear_solver=SCS.Direct, max_iters=iters,
acceleration_lookback=accel, eps=eps, warm_start=true)
acceleration_lookback=accel, eps=eps, warm_start=warm_start)
include("1703.09680.jl")
include("actions.jl")