# Using Julia to solve semidefinite programming problem that has vector solutions

**URL:** <https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [January 11, 2021, 2:50am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134 "2021-01-11T02:50:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheng\_chen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cheng_chen/32/20899_2.png) [@cheng\_chen](https://discourse.julialang.org/u/cheng_chen)\
**Post date:** [January 11, 2021, 2:50am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134/1 "2021-01-11T02:50:13Z")

</div>

Hi everyone! I need to use Julia to solve a SDP. What would you suggest to use to solve the SDP?

I tried Convex and JuMP with ProxSDP, I couldn’t get it to work.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 11, 2021, 3:46am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134/2 "2021-01-11T03:46:47Z")

</div>

Hi @cheng_chen.

You can make it easier to help by reading the first post of [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757).

For a list of solvers that support SDP, check [Installation Guide · JuMP](https://jump.dev/JuMP.jl/stable/installation/#Getting-Solvers-1).

ProxSDP should work. What was the error you encountered?

Otherwise, you could try a solver like SCS:

```nohighlight
import Pkg; Pkg.add("SCS")
using JuMP, SCS
model = Model(SCS.Optimizer)
@variable(model, X[1:2, 1:2], PSD)

```

---

<div class="post-metadata">

**Author:** ![cheng\_chen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cheng_chen/32/20899_2.png) [@cheng\_chen](https://discourse.julialang.org/u/cheng_chen)\
**Post date:** [January 11, 2021, 3:57am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134/3 "2021-01-11T03:57:22Z")

</div>

Hello @odow,

thank you for your reply!  
My code looks like this:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/2/12f27c10f60b3c243785d6824be353baeb2ad4be.png)

---

<div class="post-metadata">

**Author:** ![cheng\_chen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cheng_chen/32/20899_2.png) [@cheng\_chen](https://discourse.julialang.org/u/cheng_chen)\
**Post date:** [January 11, 2021, 3:57am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134/4 "2021-01-11T03:57:53Z")

</div>

@odow the error is :

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/2/82db39e4a040037c3ded0f5864fa53e419cbbb70.png)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 11, 2021, 4:14am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134/5 "2021-01-11T04:14:02Z")

</div>

Your objective is a matrix. You probably want to use convert it to a scalar using `sum(X)` or `LinearAlgebra.tr(X)`.

There are also some issues with your constraints. (You need to use vectorized algebra: [https://jump.dev/JuMP.jl/dev/constraints/#Vectorized-constraints](https://jump.dev/JuMP.jl/dev/constraints/#Vectorized-constraints)).

Here are some PSD examples that might be helpful:  
[https://jump.dev/JuMP.jl/dev/examples/cluster/](https://jump.dev/JuMP.jl/dev/examples/cluster/)  
[https://jump.dev/JuMP.jl/dev/examples/min\_distortion/](https://jump.dev/JuMP.jl/dev/examples/min_distortion/)

I would encourage you to re-read the PSA I linked. Instead of posting screenshots, post code that people can copy-paste. You should also provide all data needed to run the code.

---

<div class="post-metadata">

**Author:** ![cheng\_chen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cheng_chen/32/20899_2.png) [@cheng\_chen](https://discourse.julialang.org/u/cheng_chen)\
**Post date:** [January 11, 2021, 5:11am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134/6 "2021-01-11T05:11:02Z")

</div>

Thank you!  
I am sorry, it’s my first time posting. I will make sure that I follow the guidelines in the future

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 11, 2021, 6:50am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134/7 "2021-01-11T06:50:02Z")

</div>

No problem. Please post back if you still have trouble after reviewing the examples and the documentation.
