Skip to content

Commit

Permalink
Merge pull request #143 from JuliaOpt/ml/sdpupdate
Browse files Browse the repository at this point in the history
update for new SDP format
  • Loading branch information
madeleineudell committed Jun 15, 2016
2 parents ee89004 + d40280f commit 538d804
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.4
MathProgBase 0.4.0 0.5-
MathProgBase 0.5 0.6
DataStructures
9 changes: 6 additions & 3 deletions src/constraints/sdp_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ function conic_form!(c::SDPConstraint, unique_conic_forms::UniqueConicForms)
# construct linear indices to pick out the lower triangular part (including diagonal),
# the upper triangular part (not including diagonal)
# and the corresponding entries in the lower triangular part, so
# symmetry => c.child[upperpart]
diagandlowerpart = find(tril(ones(n,n)))
# symmetry => c.child[upperpart]
# scale off-diagonal elements by sqrt(2)
rescale = sqrt(2)*tril(ones(n,n))
rescale[find(diagm(ones(n)))] = 1.0
diagandlowerpart = find(rescale)
lowerpart = Array(Int, div(n*(n-1),2))
upperpart = Array(Int, div(n*(n-1),2))
klower = 0
Expand All @@ -59,7 +62,7 @@ function conic_form!(c::SDPConstraint, unique_conic_forms::UniqueConicForms)
lowerpart[klower] = n*(j-1) + i # (i,j)th element
end
end
objective = conic_form!(c.child[diagandlowerpart], unique_conic_forms)
objective = conic_form!((rescale.*c.child)[diagandlowerpart], unique_conic_forms)
sdp_constraint = ConicConstr([objective], :SDP, [div(n*(n+1),2)])
cache_conic_form!(unique_conic_forms, c, sdp_constraint)
# make sure upper and lower triangular part match in the solution
Expand Down

0 comments on commit 538d804

Please sign in to comment.