1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-23 00:10:28 +01:00

avoid transposing Us for every constraint

This commit is contained in:
kalmar 2017-07-26 18:02:21 +02:00
parent 5332d806cc
commit 582b7bc3c7

View File

@ -91,7 +91,7 @@ function transform(U::AbstractArray, V::AbstractArray; sparse=true)
end
end
A(data::OrbitData, π, 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::OrbitData, t)
l = endof(data.Us)
@ -99,13 +99,18 @@ function constrLHS(m::JuMP.Model, data::OrbitData, t)
return lhs
end
function constrLHS(m::JuMP.Model, cnstr, Us, Ust, dims, vars)
lhs = @expression(m,
sum(vecdot(dims[π].*Ust[π]*cnstr*Us[π], vars[π]) for π in 1:endof(Us)))
return lhs
end
function addconstraints!(m::JuMP.Model, data::OrbitData, l::Int=length(data.laplacian); var::Symbol = )
λ = m[var]
# orbits = load(joinpath(data.name, "orbits.jld"), "orbits");
# locate(t, orb=orbits) = findfirst(x->t in x, orb)
Ust = [U' for U in data.Us]
for t in 1:l
# lhs = constrLHS(m, data, locate(t))
lhs = constrLHS(m, data, t)
# lhs = constrLHS(m, data, t)
lhs = constrLHS(m, data.cnstr[t], data.Us, Ust, data.dims, data.Ps)
d, = data.laplacian[t], data.laplacianSq[t]
if lhs == zero(lhs)