mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-23 08:15:29 +01:00
avoid transposing Us for every constraint
This commit is contained in:
parent
5332d806cc
commit
582b7bc3c7
@ -91,7 +91,7 @@ function transform(U::AbstractArray, V::AbstractArray; sparse=true)
|
|||||||
end
|
end
|
||||||
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)
|
function constrLHS(m::JuMP.Model, data::OrbitData, t)
|
||||||
l = endof(data.Us)
|
l = endof(data.Us)
|
||||||
@ -99,13 +99,18 @@ function constrLHS(m::JuMP.Model, data::OrbitData, t)
|
|||||||
return lhs
|
return lhs
|
||||||
end
|
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 = :λ)
|
function addconstraints!(m::JuMP.Model, data::OrbitData, l::Int=length(data.laplacian); var::Symbol = :λ)
|
||||||
λ = m[var]
|
λ = m[var]
|
||||||
# orbits = load(joinpath(data.name, "orbits.jld"), "orbits");
|
Ust = [U' for U in data.Us]
|
||||||
# locate(t, orb=orbits) = findfirst(x->t in x, orb)
|
|
||||||
for t in 1:l
|
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, d² = data.laplacian[t], data.laplacianSq[t]
|
d, d² = data.laplacian[t], data.laplacianSq[t]
|
||||||
if lhs == zero(lhs)
|
if lhs == zero(lhs)
|
||||||
|
Loading…
Reference in New Issue
Block a user