mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-19 07:20:28 +01:00
parametrize Settings by {Symmetric, Naive}
This commit is contained in:
parent
23449ed3c0
commit
592f0bf7a5
@ -21,31 +21,36 @@ import MathProgBase.SolverInterface.AbstractMathProgSolver
|
|||||||
struct Symmetrize end
|
struct Symmetrize end
|
||||||
struct Naive end
|
struct Naive end
|
||||||
|
|
||||||
mutable struct Settings{Gr<:Group, GEl<:GroupElem, Sol<:AbstractMathProgSolver}
|
struct Settings{T} where T<:Union{Symmetrize, Naive}
|
||||||
name::String
|
name::String
|
||||||
G::Gr
|
|
||||||
S::Vector{GEl}
|
G::Group
|
||||||
|
S::Vector{GroupElem}
|
||||||
radius::Int
|
radius::Int
|
||||||
|
|
||||||
solver::Sol
|
solver::AbstractMathProgSolver
|
||||||
upper_bound::Float64
|
upper_bound::Float64
|
||||||
tol::Float64
|
tol::Float64
|
||||||
warmstart::Bool
|
warmstart::Bool
|
||||||
|
|
||||||
autS::Group
|
autS::Group
|
||||||
|
|
||||||
function Settings(name, G::Gr, S::Vector{GEl}, r::Int,
|
function Settings(name::String,
|
||||||
sol::Sol, ub, tol, ws) where {Gr, GEl, Sol}
|
G::Group, S::Vector{GEl}, r::Int,
|
||||||
return new{Gr, GEl, Sol}(name, G, S, r, sol, ub, tol, ws)
|
sol::Sol, ub, tol, ws) where
|
||||||
|
{GEl<:GroupElem, Sol<:AbstractMathProgSolver}
|
||||||
|
return new{Naive}(name, G, S, r, sol, ub, tol, ws)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Settings(name, G::Gr, S::Vector{GEl}, r::Int,
|
function Settings(name::String,
|
||||||
|
G::Group, S::Vector{GEl}, r::Int,
|
||||||
sol::Sol, ub, tol, ws, autS) where {Gr, GEl, Sol}
|
sol::Sol, ub, tol, ws, autS) where {Gr, GEl, Sol}
|
||||||
return new{Gr, GEl, Sol}(name, G, S, r, sol, ub, tol, ws, autS)
|
return new{Symmetrize}(name, G, S, r, sol, ub, tol, ws, autS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
prefix(s::Settings) = s.name
|
prefix(s::Settings{Naive}) = s.name
|
||||||
|
prefix(s::Settings{Symmetrize}) = "o"*s.name
|
||||||
suffix(s::Settings) = "$(s.upper_bound)"
|
suffix(s::Settings) = "$(s.upper_bound)"
|
||||||
prepath(s::Settings) = prefix(s)
|
prepath(s::Settings) = prefix(s)
|
||||||
fullpath(s::Settings) = joinpath(prefix(s), suffix(s))
|
fullpath(s::Settings) = joinpath(prefix(s), suffix(s))
|
||||||
@ -72,9 +77,7 @@ filename(prefix, s::Symbol) = filename(prefix, Val{s})
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for T in [:Naive, :Symmetrize]
|
function check_property_T(sett::Settings{$T})
|
||||||
@eval begin
|
|
||||||
function check_property_T(::Type{$T}, sett::Settings)
|
|
||||||
|
|
||||||
if exists(filename(prepath(sett),:pm)) &&
|
if exists(filename(prepath(sett),:pm)) &&
|
||||||
exists(filename(prepath(sett),:Δ))
|
exists(filename(prepath(sett),:Δ))
|
||||||
@ -100,7 +103,7 @@ for T in [:Naive, :Symmetrize]
|
|||||||
ws = nothing
|
ws = nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
λ, P, ws = computeλandP($T, Δ, sett,
|
λ, P, ws = computeλandP(sett, Δ,
|
||||||
solverlog=filename(fullpath(sett), :solverlog))
|
solverlog=filename(fullpath(sett), :solverlog))
|
||||||
saveλandP(fullpath(sett), λ, P, ws)
|
saveλandP(fullpath(sett), λ, P, ws)
|
||||||
|
|
||||||
@ -122,8 +125,6 @@ for T in [:Naive, :Symmetrize]
|
|||||||
|
|
||||||
return interpret_results(sett, sgap)
|
return interpret_results(sett, sgap)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Kazhdan(λ::Number, N::Integer) = sqrt(2*λ/N)
|
Kazhdan(λ::Number, N::Integer) = sqrt(2*λ/N)
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function computeλandP(::Type{Naive}, Δ::GroupRingElem, sett::Settings, ws=nothing; solverlog=tempname()*".log")
|
function computeλandP(sett::Settings{Naive},
|
||||||
|
Δ::GroupRingElem, ws=nothing; solverlog=tempname()*".log")
|
||||||
info("Creating SDP problem...")
|
info("Creating SDP problem...")
|
||||||
SDP_problem, varλ, varP = SOS_problem(Δ^2, Δ, upper_bound=sett.upper_bound)
|
SDP_problem, varλ, varP = SOS_problem(Δ^2, Δ, upper_bound=sett.upper_bound)
|
||||||
JuMP.setsolver(SDP_problem, sett.solver)
|
JuMP.setsolver(SDP_problem, sett.solver)
|
||||||
@ -73,7 +74,8 @@ function computeλandP(::Type{Naive}, Δ::GroupRingElem, sett::Settings, ws=noth
|
|||||||
return λ, P, ws
|
return λ, P, ws
|
||||||
end
|
end
|
||||||
|
|
||||||
function computeλandP(::Type{Symmetrize}, Δ::GroupRingElem, sett::Settings, ws=nothing; solverlog=tempname()*".log")
|
function computeλandP(sett::Settings{Symmetrize},
|
||||||
|
Δ::GroupRingElem, ws=nothing; solverlog=tempname()*".log")
|
||||||
pdir = prepath(sett)
|
pdir = prepath(sett)
|
||||||
|
|
||||||
files_exist = exists(filename(pdir,:Uπs)) && exists(filename(pdir,:orbits)) && exists(filename(pdir,:preps))
|
files_exist = exists(filename(pdir,:Uπs)) && exists(filename(pdir,:orbits)) && exists(filename(pdir,:preps))
|
||||||
|
Loading…
Reference in New Issue
Block a user