mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2025-03-17 09:12:13 +01:00
move Laplacians to separate file
This commit is contained in:
parent
278a62da2f
commit
19e52909ac
58
src/Laplacians.jl
Normal file
58
src/Laplacians.jl
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Laplacians
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
function spLaplacian(RG::GroupRing, S, T::Type=Float64)
|
||||||
|
result = RG(T)
|
||||||
|
result[RG.group()] = T(length(S))
|
||||||
|
for s in S
|
||||||
|
result[s] -= one(T)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
function spLaplacian(RG::GroupRing{R}, S, T::Type=Float64) where {R<:Ring}
|
||||||
|
result = RG(T)
|
||||||
|
result[one(RG.group)] = T(length(S))
|
||||||
|
for s in S
|
||||||
|
result[s] -= one(T)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
function computeLaplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.RingElem
|
||||||
|
R = parent(first(S))
|
||||||
|
return computeLaplacian(S, one(R), radius)
|
||||||
|
end
|
||||||
|
|
||||||
|
function computeLaplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.GroupElem
|
||||||
|
G = parent(first(S))
|
||||||
|
return computeLaplacian(S, G(), radius)
|
||||||
|
end
|
||||||
|
|
||||||
|
function computeLaplacian(S, Id, radius)
|
||||||
|
info("Generating metric ball of radius $radius...")
|
||||||
|
@time E_R, sizes = Groups.generate_balls(S, Id, radius=2radius)
|
||||||
|
info("Generated balls of sizes $sizes.")
|
||||||
|
|
||||||
|
info("Creating product matrix...")
|
||||||
|
@time pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
||||||
|
|
||||||
|
RG = GroupRing(parent(Id), E_R, pm)
|
||||||
|
Δ = spLaplacian(RG, S)
|
||||||
|
return Δ
|
||||||
|
end
|
||||||
|
|
||||||
|
function loadLaplacian(name::String, G::Group)
|
||||||
|
if exists(filename(name, :Δ)) && exists(filename(name, :pm))
|
||||||
|
info("Loading precomputed Δ...")
|
||||||
|
RG = GroupRing(G, load(filename(name, :pm), "pm"))
|
||||||
|
Δ = GroupRingElem(load(filename(name, :Δ), "Δ")[:, 1], RG)
|
||||||
|
else
|
||||||
|
throw("You need to precompute $(filename(name, :pm)) and $(filename(name, :Δ)) to load it!")
|
||||||
|
end
|
||||||
|
return Δ
|
||||||
|
end
|
||||||
|
|
@ -12,54 +12,26 @@ using JuMP
|
|||||||
|
|
||||||
import MathProgBase.SolverInterface.AbstractMathProgSolver
|
import MathProgBase.SolverInterface.AbstractMathProgSolver
|
||||||
|
|
||||||
function loadLaplacian(name::String, G::Group)
|
|
||||||
if exists(filename(name, :Δ)) && exists(filename(name, :pm))
|
|
||||||
info("Loading precomputed Δ...")
|
|
||||||
RG = GroupRing(G, load(filename(name, :pm), "pm"))
|
|
||||||
Δ = GroupRingElem(load(filename(name, :Δ), "Δ")[:, 1], RG)
|
|
||||||
else
|
|
||||||
throw("You need to precompute $(filename(name, :pm)) and $(filename(name, :Δ)) to load it!")
|
|
||||||
end
|
|
||||||
return Δ
|
|
||||||
end
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Settings and filenames
|
# Settings and filenames
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function computeLaplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.RingElem
|
|
||||||
R = parent(first(S))
|
|
||||||
return computeLaplacian(S, one(R), radius)
|
|
||||||
end
|
|
||||||
|
|
||||||
function computeLaplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.GroupElem
|
|
||||||
G = parent(first(S))
|
|
||||||
return computeLaplacian(S, G(), radius)
|
|
||||||
end
|
|
||||||
mutable struct Settings{Gr<:Group, GEl<:GroupElem, Sol<:AbstractMathProgSolver}
|
mutable struct Settings{Gr<:Group, GEl<:GroupElem, Sol<:AbstractMathProgSolver}
|
||||||
name::String
|
name::String
|
||||||
G::Gr
|
G::Gr
|
||||||
S::Vector{GEl}
|
S::Vector{GEl}
|
||||||
radius::Int
|
radius::Int
|
||||||
|
|
||||||
function computeLaplacian(S, Id, radius)
|
|
||||||
info("Generating metric ball of radius $radius...")
|
|
||||||
@time E_R, sizes = Groups.generate_balls(S, Id, radius=2radius)
|
|
||||||
info("Generated balls of sizes $sizes.")
|
|
||||||
solver::Sol
|
solver::Sol
|
||||||
upper_bound::Float64
|
upper_bound::Float64
|
||||||
tol::Float64
|
tol::Float64
|
||||||
warmstart::Bool
|
warmstart::Bool
|
||||||
|
|
||||||
info("Creating product matrix...")
|
|
||||||
@time pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
|
||||||
autS::Group
|
autS::Group
|
||||||
|
|
||||||
RG = GroupRing(parent(Id), E_R, pm)
|
|
||||||
Δ = spLaplacian(RG, S)
|
|
||||||
return Δ
|
|
||||||
end
|
|
||||||
|
|
||||||
function loadλandP(name::String)
|
function loadλandP(name::String)
|
||||||
λ_fname = filename(name, :λ)
|
λ_fname = filename(name, :λ)
|
||||||
@ -187,6 +159,8 @@ function interpret_results(name::String, Δ::GroupRingElem, radius::Integer, len
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
include("Laplacians.jl")
|
||||||
include("SDPs.jl")
|
include("SDPs.jl")
|
||||||
include("CheckSolution.jl")
|
include("CheckSolution.jl")
|
||||||
include("Orbit-wise.jl")
|
include("Orbit-wise.jl")
|
||||||
|
Loading…
Reference in New Issue
Block a user