mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-12-24 02:00:30 +01:00
constraints_from_pm -> constraints
returns a vector of constraints, i.e. vectors of Tuple{Int, Int}
This commit is contained in:
parent
31715701cc
commit
0c9fb40e65
@ -79,14 +79,14 @@ function orbit_spvector(vect::AbstractVector, orbits)
|
||||
return orb_vector
|
||||
end
|
||||
|
||||
function orbit_constraint(constraints::Vector{Vector{Vector{Int64}}}, n)
|
||||
function orbit_constraint(constraints::Vector{Vector{Tuple{Int,Int}}}, n)
|
||||
result = spzeros(n,n)
|
||||
for cnstr in constraints
|
||||
for p in cnstr
|
||||
result[p[2], p[1]] += 1.0
|
||||
result[p[2], p[1]] += 1.0/length(constraints)
|
||||
end
|
||||
end
|
||||
return 1/length(constraints)*result
|
||||
return result
|
||||
end
|
||||
|
||||
###############################################################################
|
||||
|
@ -88,7 +88,7 @@ function ΔandSDPconstraints(prefix::String, G::Group)
|
||||
pm_fname, Δ_fname = pmΔfilenames(prefix)
|
||||
|
||||
product_matrix = load(pm_fname, "pm")
|
||||
sdp_constraints = constraints_from_pm(product_matrix)
|
||||
sdp_constraints = constraints(product_matrix)
|
||||
|
||||
RG = GroupRing(G, product_matrix)
|
||||
Δ = GroupRingElem(load(Δ_fname, "Δ")[:, 1], RG)
|
||||
@ -107,15 +107,15 @@ end
|
||||
|
||||
function ΔandSDPconstraints{T<:GroupElem}(S::Vector{T}, Id::T; radius::Int=2)
|
||||
info(logger, "Generating balls of sizes $sizes")
|
||||
@logtime logger B, sizes = Groups.generate_balls(S, Id, radius=2*radius)
|
||||
@logtime logger E_R, sizes = Groups.generate_balls(S, Id, radius=2*radius)
|
||||
|
||||
info(logger, "Creating product matrix...")
|
||||
@logtime logger pm = GroupRings.create_pm(B, GroupRings.reverse_dict(B), sizes[radius]; twisted=true)
|
||||
@logtime logger pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
||||
|
||||
info(logger, "Creating sdp_constratints...")
|
||||
@logtime logger sdp_constraints = PropertyT.constraints_from_pm(pm)
|
||||
@logtime logger sdp_constraints = PropertyT.constraints(pm)
|
||||
|
||||
RG = GroupRing(parent(Id), B, pm)
|
||||
RG = GroupRing(parent(Id), E_R, pm)
|
||||
|
||||
Δ = splaplacian(RG, S)
|
||||
return Δ, sdp_constraints
|
||||
|
@ -1,13 +1,13 @@
|
||||
using JuMP
|
||||
import MathProgBase: AbstractMathProgSolver
|
||||
|
||||
function constraints_from_pm(pm, total_length=maximum(pm))
|
||||
function constraints(pm, total_length=maximum(pm))
|
||||
n = size(pm,1)
|
||||
constraints = [Array{Int,1}[] for x in 1:total_length]
|
||||
constraints = [Vector{Tuple{Int,Int}}() for _ in 1:total_length]
|
||||
for j in 1:n
|
||||
for i in 1:n
|
||||
idx = pm[i,j]
|
||||
push!(constraints[idx], [i,j])
|
||||
push!(constraints[idx], (i,j))
|
||||
end
|
||||
end
|
||||
return constraints
|
||||
|
Loading…
Reference in New Issue
Block a user