From 33fc45687912ff6c2b3c160208c3dff4987ce98b Mon Sep 17 00:00:00 2001 From: kalmarek Date: Mon, 20 Aug 2018 03:50:03 +0200 Subject: [PATCH] constraints return linear indices --- src/SDPs.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/SDPs.jl b/src/SDPs.jl index 0272873..97792ca 100644 --- a/src/SDPs.jl +++ b/src/SDPs.jl @@ -1,13 +1,14 @@ using JuMP import MathProgBase: AbstractMathProgSolver -function constraints(pm, total_length=maximum(pm)) - n = size(pm,1) - constraints = [Vector{Tuple{Int,Int}}() for _ in 1:total_length] - for j in 1:n - for i in 1:n - idx = pm[i,j] - push!(constraints[idx], (i,j)) +function constraints(pm::Matrix{I}, total_length=maximum(pm)) where {I<:Integer} + cnstrs = [Vector{I}() for _ in 1:total_length] + for i in eachindex(pm) + push!(cnstrs[pm[i]], i) + end + return cnstrs +end + end end return constraints