move reconstruct to OrbitDecomposition.jl

also: AutS_mreps becomes a dictionary
This commit is contained in:
kalmar 2017-06-22 13:34:29 +02:00
parent ee08c52305
commit b6cf402260
2 changed files with 31 additions and 29 deletions

View File

@ -155,28 +155,6 @@ function λandP(m::JuMP.Model, data::OrbitData)
return λ, Ps
end
function matrix_reps{T<:GroupElem}(G::Group, S::Vector{T}, AutS::Group, radius::Int)
Id = (isa(G, Nemo.Ring) ? one(G) : G())
E2, _ = Groups.generate_balls(S, Id, radius=radius)
Edict = GroupRings.reverse_dict(E2)
mreps = Dict(g => matrix_repr(g, E2, Edict) for g in elements(AutS))
return mreps
end
function reconstruct(mreps::Dict, Us::Vector, Ps::Vector, dims::Vector)
recP = zeros(size(Us[1],1), size(Us[1],1))
for g in keys(mreps)
for π in 1:endof(Us)
recP .+= dims[π] .* mreps[g]*transform(Us[π]', Ps[π])*mreps[inv(g)]
end
end
recP .*= 1/length(collect(keys(mreps)))
return recP
end
function λandP(m::JuMP.Model, data::OrbitData, sett::Settings)
info(PropertyT.logger, "Solving SDP problem...")
λ, Ps = λandP(m, data)
@ -184,7 +162,7 @@ function λandP(m::JuMP.Model, data::OrbitData, sett::Settings)
info(PropertyT.logger, "Reconstructing P...")
mreps = matrix_reps(sett.G, sett.S, sett.AutS, sett.radius)
recP = reconstruct(mreps, data.Us, Ps, data.dims)
recP = reconstruct_sol(mreps, data.Us, Ps, data.dims)
fname = PropertyT.λSDPfilenames(data.name)[2]
save(fname, "origP", Ps, "P", recP)

View File

@ -117,10 +117,34 @@ function matrix_repr(g::GroupElem, E, E_dict)
return rep_matrix
end
function Cstar_repr(x::GroupRingElem, matrix_reps)
res = zeros(matrix_reps[1])
for i in 1:length(parent(x).basis)
res += x.coeffs[i]*matrix_reps[i]
function matrix_reps{T<:GroupElem}(G::Nemo.Group, S::Vector{T}, AutS::Nemo.Group, radius::Int)
Id = (isa(G, Nemo.Ring) ? one(G) : G())
E2, _ = Groups.generate_balls(S, Id, radius=radius)
Edict = GroupRings.reverse_dict(E2)
mreps = Dict(g=>matrix_repr(g, E2, Edict) for g in elements(AutS))
return mreps
end
function reconstruct_sol(mreps::Dict, Us::Vector, Ps::Vector, dims::Vector)
recP = zeros(size(Us[1],1), size(Us[1],1))
for g in keys(mreps)
for π in 1:endof(Us)
recP .+= dims[π] .* mreps[g]*transform(Us[π]', Ps[π])*mreps[inv(g)]
end
end
recP .*= 1/length(collect(keys(mreps)))
return recP
end
function Cstar_repr(x::GroupRingElem, mreps)
k = collect(keys(mreps))[1]
res = zeros(size(mreps[k])...)
for g in parent(x).basis
res .+= x[g]*mreps[g]
end
return res
end
@ -162,12 +186,12 @@ function compute_orbit_data{T<:GroupElem}(logger, name::String, G::Nemo.Group, S
info(logger, "Action matrices")
E2 = E4[1:sizes[radius]]
@time AutS_matrixreps = [matrix_repr(g, E2, E_dict) for g in elements(AutS)]
@time AutS_mreps = Dict(g=>matrix_repr(g, E2, E_dict) for g in elements(AutS))
info(logger, "Projections")
@time AutS_mps = rankOne_projections(AutS);
@time π_E_projections = [Cstar_repr(p, AutS_matrixreps) for p in AutS_mps]
@time π_E_projections = [Cstar_repr(p, AutS_mreps) for p in AutS_mps]
info(logger, "Uπs...")
@time Uπs = orthSVD.(π_E_projections)