rename ProblemData -> OrbitData

This commit is contained in:
kalmar 2017-06-08 21:38:14 +02:00
parent 34cb1c80ab
commit 633f2222c8

View File

@ -10,7 +10,7 @@ using ArgParse
include("OrbitDecomposition.jl") include("OrbitDecomposition.jl")
immutable ProblemData{T} immutable OrbitData
name::String name::String
Us::Vector Us::Vector
Ps::Vector{Array{JuMP.Variable,2}} Ps::Vector{Array{JuMP.Variable,2}}
@ -59,7 +59,7 @@ function init_model(Uπs)
return m, P return m, P
end end
function init_ProblemData(name::String) function init_OrbitData(name::String)
splap = load(joinpath(name, "delta.jld"), "Δ"); splap = load(joinpath(name, "delta.jld"), "Δ");
pm = load(joinpath(name, "pm.jld"), "pm"); pm = load(joinpath(name, "pm.jld"), "pm");
cnstr = PropertyT.constraints_from_pm(pm); cnstr = PropertyT.constraints_from_pm(pm);
@ -78,9 +78,9 @@ function init_ProblemData(name::String)
orb_splap = orbit_spvector(splap, orbits) orb_splap = orbit_spvector(splap, orbits)
orb_splap² = orbit_spvector(splap², orbits) orb_splap² = orbit_spvector(splap², orbits)
orb_SOutF4data = ProblemData(name, Uπs, P, orb_spcnstrm, orb_splap, orb_splap², dims); orbData = OrbitData(name, Uπs, P, orb_spcnstrm, orb_splap, orb_splap², dims);
return m, orb_SOutF4data return m, orbData
end end
function transform{T}(U::AbstractArray{T,2}, V::AbstractArray{T,2}, eps=eps(T)) function transform{T}(U::AbstractArray{T,2}, V::AbstractArray{T,2}, eps=eps(T))
@ -90,15 +90,15 @@ function transform{T}(U::AbstractArray{T,2}, V::AbstractArray{T,2}, eps=eps(T))
return w return w
end end
A(data::ProblemData, π, t) = data.dims[π]*transform(data.Us[π], data.cnstr[t]) A(data::OrbitData, π, t) = data.dims[π]*transform(data.Us[π], data.cnstr[t])
function constrLHS(m::JuMP.Model, data::ProblemData, t) function constrLHS(m::JuMP.Model, data::OrbitData, t)
l = endof(data.Us) l = endof(data.Us)
lhs = @expression(m, sum(vecdot(A(data, π, t), data.Ps[π]) for π in 1:l)) lhs = @expression(m, sum(vecdot(A(data, π, t), data.Ps[π]) for π in 1:l))
return lhs return lhs
end end
function addconstraints!(m::JuMP.Model, data::ProblemData, l::Int=length(data.cnstr); var::Symbol = ) function addconstraints!(m::JuMP.Model, data::OrbitData, l::Int=length(data.cnstr); var::Symbol = )
λ = getvariable(m, var) λ = getvariable(m, var)
for t in 1:l for t in 1:l
d, = data.laplacian[t], data.laplacianSq[t] d, = data.laplacian[t], data.laplacianSq[t]
@ -115,14 +115,14 @@ function addconstraints!(m::JuMP.Model, data::ProblemData, l::Int=length(data.cn
end end
end end
function reconstructP(m::JuMP.Model, data::ProblemData) function reconstructP(m::JuMP.Model, data::OrbitData)
computedPs = [getvalue(P) for P in data.Ps] computedPs = [getvalue(P) for P in data.Ps]
return sum(data.dims[π]*data.Us[π]*computedPs[π]*data.Us[π]' for π in 1:endof(data.Ps)) return sum(data.dims[π]*data.Us[π]*computedPs[π]*data.Us[π]' for π in 1:endof(data.Ps))
end end
function create_SDP_problem(name::String; upper_bound=Inf) function create_SDP_problem(name::String; upper_bound=Inf)
info(PropertyT.logger, "Loading data....") info(PropertyT.logger, "Loading data....")
t = @timed SDP_problem, orb_data = init_ProblemData(name); t = @timed SDP_problem, orb_data = init_OrbitData(name);
info(PropertyT.logger, PropertyT.timed_msg(t)) info(PropertyT.logger, PropertyT.timed_msg(t))
if upper_bound < Inf if upper_bound < Inf
@ -137,7 +137,7 @@ function create_SDP_problem(name::String; upper_bound=Inf)
return SDP_problem, orb_data return SDP_problem, orb_data
end end
function λandP(m::JuMP.Model, data::ProblemData) function λandP(m::JuMP.Model, data::OrbitData)
info(PropertyT.logger, "Solving SDP problem...") info(PropertyT.logger, "Solving SDP problem...")
varλ = JuMP.getvariable(m, ) varλ = JuMP.getvariable(m, )
varP = data.Ps varP = data.Ps