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:
parent
a5a3d9d069
commit
dc14b2fd95
@ -16,7 +16,7 @@ struct Naive{El} <: Settings
|
|||||||
upper_bound::Float64
|
upper_bound::Float64
|
||||||
|
|
||||||
solver::JuMP.OptimizerFactory
|
solver::JuMP.OptimizerFactory
|
||||||
warmstart::Bool
|
force_compute::Bool
|
||||||
end
|
end
|
||||||
|
|
||||||
struct Symmetrized{El} <: Settings
|
struct Symmetrized{El} <: Settings
|
||||||
@ -28,19 +28,19 @@ struct Symmetrized{El} <: Settings
|
|||||||
upper_bound::Float64
|
upper_bound::Float64
|
||||||
|
|
||||||
solver::JuMP.OptimizerFactory
|
solver::JuMP.OptimizerFactory
|
||||||
warmstart::Bool
|
force_compute::Bool
|
||||||
end
|
end
|
||||||
|
|
||||||
function Settings(name::String,
|
function Settings(name::String,
|
||||||
G::Union{Group, NCRing}, S::AbstractVector{El}, solver::JuMP.OptimizerFactory;
|
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}
|
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, warmstart)
|
return Naive(name, G, S, halfradius, upper_bound, solver, force_compute)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Settings(name::String,
|
function Settings(name::String,
|
||||||
G::Union{Group, NCRing}, S::AbstractVector{El}, autS::Group, solver::JuMP.OptimizerFactory;
|
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}
|
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, warmstart)
|
return Symmetrized(name, G, S, autS, halfradius, upper_bound, solver, force_compute)
|
||||||
end
|
end
|
||||||
|
|
||||||
prefix(s::Naive) = s.name
|
prefix(s::Naive) = s.name
|
||||||
@ -81,11 +81,11 @@ end
|
|||||||
function warmstart(sett::Settings)
|
function warmstart(sett::Settings)
|
||||||
warmstart_fname = filename(sett, :warmstart)
|
warmstart_fname = filename(sett, :warmstart)
|
||||||
try
|
try
|
||||||
ws = load(filename(sett, :warmstart), "warmstart")
|
ws = load(warmstart_fname, "warmstart")
|
||||||
@info "Loaded $warmstart_fname."
|
@info "Loaded $warmstart_fname."
|
||||||
return ws
|
return ws
|
||||||
catch ex
|
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
|
return nothing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -239,23 +239,22 @@ end
|
|||||||
Kazhdan(λ::Number, N::Integer) = sqrt(2*λ/N)
|
Kazhdan(λ::Number, N::Integer) = sqrt(2*λ/N)
|
||||||
|
|
||||||
function check_property_T(sett::Settings)
|
function check_property_T(sett::Settings)
|
||||||
print_summary(sett)
|
@info sett
|
||||||
certified_sgap = spectral_gap(sett)
|
certified_sgap = spectral_gap(sett)
|
||||||
return interpret_results(sett, certified_sgap)
|
return interpret_results(sett, certified_sgap)
|
||||||
end
|
end
|
||||||
|
|
||||||
function print_summary(sett::Settings)
|
function Base.show(io::IO, sett::Settings)
|
||||||
separator = "="^76
|
info_strs = ["PropertyT Settings:",
|
||||||
info_strs = [separator,
|
"Group: $(sett.name)",
|
||||||
"Running tests for $(sett.name):",
|
|
||||||
"Upper bound for λ: $(sett.upper_bound), on halfradius $(sett.halfradius).",
|
"Upper bound for λ: $(sett.upper_bound), on halfradius $(sett.halfradius).",
|
||||||
"Warmstart: $(sett.warmstart)",
|
"Force computations: $(sett.force_compute);",
|
||||||
"Results will be stored in ./$(PropertyT.prepath(sett))",
|
"Results will be stored in ./$(PropertyT.prepath(sett));",
|
||||||
"Solver: $(typeof(sett.solver()))",
|
"Solver: $(typeof(sett.solver()))",
|
||||||
"Solvers options: "]
|
"Solvers options: "]
|
||||||
append!(info_strs, [rpad(" $k", 30)* "→ \t$v" for (k,v) in sett.solver().options])
|
append!(info_strs, [rpad(" $k", 30)* "→ \t$v" for (k,v) in sett.solver().options])
|
||||||
push!(info_strs, separator)
|
push!(info_strs, "="^76)
|
||||||
@info join(info_strs, "\n")
|
print(io, join(info_strs, "\n"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function interpret_results(sett::Settings, sgap::Number)
|
function interpret_results(sett::Settings, sgap::Number)
|
||||||
@ -300,7 +299,7 @@ function spectral_gap(sett::Settings)
|
|||||||
return λ, P
|
return λ, P
|
||||||
end
|
end
|
||||||
|
|
||||||
if sett.warmstart
|
if sett.force_compute
|
||||||
λ, P = compute(sett, Δ)
|
λ, P = compute(sett, Δ)
|
||||||
else
|
else
|
||||||
λ, P =try
|
λ, P =try
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
rm("SL($N,Z)", recursive=true, force=true)
|
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)
|
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)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ < 0.0
|
@test λ < 0.0
|
||||||
@ -23,7 +23,7 @@
|
|||||||
rm("SL($N,Z)", recursive=true, force=true)
|
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)
|
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)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ > 0.0999
|
@test λ > 0.0999
|
||||||
@ -39,9 +39,9 @@
|
|||||||
|
|
||||||
rm("SAut(F$N)", recursive=true, force=true)
|
rm("SAut(F$N)", recursive=true, force=true)
|
||||||
sett = PropertyT.Settings("SAut(F$N)", G, S, with_SCS(10000);
|
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)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ < 0.0
|
@test λ < 0.0
|
||||||
|
@ -8,22 +8,22 @@
|
|||||||
|
|
||||||
rm("oSL($N,Z)", recursive=true, force=true)
|
rm("oSL($N,Z)", recursive=true, force=true)
|
||||||
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
|
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)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ < 0.0
|
@test λ < 0.0
|
||||||
@test PropertyT.interpret_results(sett, λ) == false
|
@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.spectral_gap(sett)
|
||||||
@test PropertyT.check_property_T(sett) == false
|
@test PropertyT.check_property_T(sett) == false
|
||||||
|
|
||||||
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
|
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(4000, accel=20);
|
||||||
upper_bound=0.27, warmstart=true)
|
upper_bound=0.27, force_compute=true)
|
||||||
|
|
||||||
PropertyT.print_summary(sett)
|
@info sett
|
||||||
|
|
||||||
λ = PropertyT.spectral_gap(sett)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ > 0.269999
|
@test λ > 0.269999
|
||||||
@ -36,10 +36,10 @@
|
|||||||
##########
|
##########
|
||||||
# Symmetrizing by PermGroup(3):
|
# Symmetrizing by PermGroup(3):
|
||||||
|
|
||||||
sett = PropertyT.Settings("SL($N,Z)", G, S, PermGroup(N), with_SCS(4000, accel=20);
|
sett = PropertyT.Settings("SL($N,Z)", G, S, PermGroup(N), with_SCS(4000, accel=20, warm_start=false);
|
||||||
upper_bound=0.27, warmstart=true)
|
upper_bound=0.27, force_compute=true)
|
||||||
|
|
||||||
PropertyT.print_summary(sett)
|
@info sett
|
||||||
|
|
||||||
λ = PropertyT.spectral_gap(sett)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ > 0.269999
|
@test λ > 0.269999
|
||||||
@ -54,22 +54,22 @@
|
|||||||
|
|
||||||
rm("oSL($N,Z)", recursive=true, force=true)
|
rm("oSL($N,Z)", recursive=true, force=true)
|
||||||
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
|
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)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ < 0.0
|
@test λ < 0.0
|
||||||
@test PropertyT.interpret_results(sett, λ) == false
|
@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.spectral_gap(sett)
|
||||||
@test PropertyT.check_property_T(sett) == false
|
@test PropertyT.check_property_T(sett) == false
|
||||||
|
|
||||||
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(5000, accel=20);
|
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(5000, accel=20, warm_start=true);
|
||||||
upper_bound=1.3, warmstart=true)
|
upper_bound=1.3, force_compute=true)
|
||||||
|
|
||||||
PropertyT.print_summary(sett)
|
@info sett
|
||||||
|
|
||||||
λ = PropertyT.spectral_gap(sett)
|
λ = PropertyT.spectral_gap(sett)
|
||||||
@test λ > 1.2999
|
@test λ > 1.2999
|
||||||
@ -89,9 +89,9 @@
|
|||||||
rm("oSAut(F$N)", recursive=true, force=true)
|
rm("oSAut(F$N)", recursive=true, force=true)
|
||||||
|
|
||||||
sett = PropertyT.Settings("SAut(F$N)", G, S, autS, with_SCS(1000);
|
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
|
@test PropertyT.check_property_T(sett) == false
|
||||||
end
|
end
|
||||||
|
@ -136,7 +136,7 @@ end
|
|||||||
|
|
||||||
@test 2^2*norm(residual, 1) < λ # i.e. we can certify positivity
|
@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
|
end
|
||||||
|
|
||||||
@testset "Adj₃ is SOS" begin
|
@testset "Adj₃ is SOS" begin
|
||||||
@ -205,7 +205,7 @@ end
|
|||||||
Base.Libc.flush_cstdio()
|
Base.Libc.flush_cstdio()
|
||||||
@info "obtained λ and residual" λ norm(residual, 1)
|
@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
|
end
|
||||||
|
|
||||||
@testset "Adj₄ + Op₄ is SOS" begin
|
@testset "Adj₄ + Op₄ is SOS" begin
|
||||||
|
@ -6,10 +6,10 @@ using JLD
|
|||||||
|
|
||||||
using JuMP, SCS
|
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,
|
with_optimizer(SCS.Optimizer,
|
||||||
linear_solver=SCS.Direct, max_iters=iters,
|
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("1703.09680.jl")
|
||||||
include("actions.jl")
|
include("actions.jl")
|
||||||
|
Loading…
Reference in New Issue
Block a user