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

sparsify! in transform and in constrLHS

This commit is contained in:
kalmarek 2017-08-27 18:59:16 +02:00
parent 7dbd11bebf
commit db55927729

View File

@ -108,7 +108,7 @@ end
function transform(U::AbstractArray, V::AbstractArray; sparse=true) function transform(U::AbstractArray, V::AbstractArray; sparse=true)
if sparse if sparse
return sparsify(U'*V*U) return sparsify!(U'*V*U)
else else
return U'*V*U return U'*V*U
end end
@ -122,10 +122,9 @@ function constrLHS(m::JuMP.Model, data::OrbitData, t)
return lhs return lhs
end end
function constrLHS(m::JuMP.Model, cnstr, Us, Ust, dims, vars) function constrLHS(m::JuMP.Model, cnstr, Us, Ust, dims, vars, eps=100*eps(1.0))
lhs = @expression(m, M = [PropertyT.sparsify!(dims[π].*Ust[π]*cnstr*Us[π], eps) for π in 1:endof(Us)]
sum(vecdot(dims[π].*Ust[π]*cnstr*Us[π], vars[π]) for π in 1:endof(Us))) return @expression(m, sum(vecdot(M[π], vars[π]) for π in 1:endof(Us)))
return lhs
end 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 = )