mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-10-15 08:05:35 +02:00
Move Settings to PropertyT.jl
This commit is contained in:
parent
859a751b01
commit
c929b0f149
@ -3,23 +3,6 @@ using SCS
|
|||||||
|
|
||||||
export Settings, OrbitData
|
export Settings, OrbitData
|
||||||
|
|
||||||
immutable Settings{T<:AbstractMathProgSolver}
|
|
||||||
name::String
|
|
||||||
N::Int
|
|
||||||
G::Group
|
|
||||||
S::Vector
|
|
||||||
autS::Group
|
|
||||||
radius::Int
|
|
||||||
solver::T
|
|
||||||
upper_bound::Float64
|
|
||||||
tol::Float64
|
|
||||||
warmstart::Bool
|
|
||||||
end
|
|
||||||
|
|
||||||
prefix(s::Settings) = s.name
|
|
||||||
suffix(s::Settings) = "$(s.upper_bound)"
|
|
||||||
prepath(s::Settings) = prefix(s)
|
|
||||||
fullpath(s::Settings) = joinpath(prefix(s), suffix(s))
|
|
||||||
|
|
||||||
struct OrbitData{T<:AbstractArray{Float64, 2}}
|
struct OrbitData{T<:AbstractArray{Float64, 2}}
|
||||||
orbits::Vector{Vector{Int}}
|
orbits::Vector{Vector{Int}}
|
||||||
|
@ -9,11 +9,11 @@ import AbstractAlgebra: Group, GroupElem, Ring, perm
|
|||||||
|
|
||||||
using JLD
|
using JLD
|
||||||
using JuMP
|
using JuMP
|
||||||
using MathProgBase
|
|
||||||
|
|
||||||
exists(fname::String) = isfile(fname) || islink(fname)
|
exists(fname::String) = isfile(fname) || islink(fname)
|
||||||
|
|
||||||
filename(prefix, s::Symbol) = filename(prefix, Val{s})
|
filename(prefix, s::Symbol) = filename(prefix, Val{s})
|
||||||
|
import MathProgBase.SolverInterface.AbstractMathProgSolver
|
||||||
|
|
||||||
@eval begin
|
@eval begin
|
||||||
for (s,n) in [
|
for (s,n) in [
|
||||||
@ -43,6 +43,11 @@ function loadLaplacian(name::String, G::Group)
|
|||||||
end
|
end
|
||||||
return Δ
|
return Δ
|
||||||
end
|
end
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Settings and filenames
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
function computeLaplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.RingElem
|
function computeLaplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.RingElem
|
||||||
R = parent(first(S))
|
R = parent(first(S))
|
||||||
@ -53,14 +58,24 @@ function computeLaplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.GroupEl
|
|||||||
G = parent(first(S))
|
G = parent(first(S))
|
||||||
return computeLaplacian(S, G(), radius)
|
return computeLaplacian(S, G(), radius)
|
||||||
end
|
end
|
||||||
|
mutable struct Settings{Gr<:Group, GEl<:GroupElem, Sol<:AbstractMathProgSolver}
|
||||||
|
name::String
|
||||||
|
G::Gr
|
||||||
|
S::Vector{GEl}
|
||||||
|
radius::Int
|
||||||
|
|
||||||
function computeLaplacian(S, Id, radius)
|
function computeLaplacian(S, Id, radius)
|
||||||
info("Generating metric ball of radius $radius...")
|
info("Generating metric ball of radius $radius...")
|
||||||
@time E_R, sizes = Groups.generate_balls(S, Id, radius=2radius)
|
@time E_R, sizes = Groups.generate_balls(S, Id, radius=2radius)
|
||||||
info("Generated balls of sizes $sizes.")
|
info("Generated balls of sizes $sizes.")
|
||||||
|
solver::Sol
|
||||||
|
upper_bound::Float64
|
||||||
|
tol::Float64
|
||||||
|
warmstart::Bool
|
||||||
|
|
||||||
info("Creating product matrix...")
|
info("Creating product matrix...")
|
||||||
@time pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
@time pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
||||||
|
autS::Group
|
||||||
|
|
||||||
RG = GroupRing(parent(Id), E_R, pm)
|
RG = GroupRing(parent(Id), E_R, pm)
|
||||||
Δ = spLaplacian(RG, S)
|
Δ = spLaplacian(RG, S)
|
||||||
@ -70,6 +85,10 @@ end
|
|||||||
function loadλandP(name::String)
|
function loadλandP(name::String)
|
||||||
λ_fname = filename(name, :λ)
|
λ_fname = filename(name, :λ)
|
||||||
P_fname = filename(name, :P)
|
P_fname = filename(name, :P)
|
||||||
|
function Settings(name, G::Gr, S::Vector{GEl}, r::Int,
|
||||||
|
sol::Sol, ub, tol, ws) where {Gr, GEl, Sol}
|
||||||
|
return new{Gr, GEl, Sol}(name, G, S, r, sol, ub, tol, ws)
|
||||||
|
end
|
||||||
|
|
||||||
if exists(λ_fname) && exists(P_fname)
|
if exists(λ_fname) && exists(P_fname)
|
||||||
info("Loading precomputed λ, P...")
|
info("Loading precomputed λ, P...")
|
||||||
@ -77,6 +96,9 @@ function loadλandP(name::String)
|
|||||||
P = load(P_fname, "P")
|
P = load(P_fname, "P")
|
||||||
else
|
else
|
||||||
throw("You need to precompute $λ_fname and $P_fname to load it!")
|
throw("You need to precompute $λ_fname and $P_fname to load it!")
|
||||||
|
function Settings(name, G::Gr, S::Vector{GEl}, r::Int,
|
||||||
|
sol::Sol, ub, tol, ws, autS) where {Gr, GEl, Sol}
|
||||||
|
return new{Gr, GEl, Sol}(name, G, S, r, sol, ub, tol, ws, autS)
|
||||||
end
|
end
|
||||||
return λ, P
|
return λ, P
|
||||||
end
|
end
|
||||||
@ -91,12 +113,17 @@ function computeλandP(Δ::GroupRingElem, upper_bound::AbstractFloat, solver, ws
|
|||||||
|
|
||||||
return λ, P, ws
|
return λ, P, ws
|
||||||
end
|
end
|
||||||
|
prefix(s::Settings) = s.name
|
||||||
|
suffix(s::Settings) = "$(s.upper_bound)"
|
||||||
|
prepath(s::Settings) = prefix(s)
|
||||||
|
fullpath(s::Settings) = joinpath(prefix(s), suffix(s))
|
||||||
|
|
||||||
function saveλandP(name, λ, P, ws)
|
function saveλandP(name, λ, P, ws)
|
||||||
save(filename(name, :λ), "λ", λ)
|
save(filename(name, :λ), "λ", λ)
|
||||||
save(filename(name, :P), "P", P)
|
save(filename(name, :P), "P", P)
|
||||||
save(filename(name, :warm), "warmstart", ws)
|
save(filename(name, :warm), "warmstart", ws)
|
||||||
end
|
end
|
||||||
|
exists(fname::String) = isfile(fname) || islink(fname)
|
||||||
|
|
||||||
Kazhdan(λ::Number,N::Integer) = sqrt(2*λ/N)
|
Kazhdan(λ::Number,N::Integer) = sqrt(2*λ/N)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user