# A problem with SOCP constraint

**URL:** <https://discourse.julialang.org/t/a-problem-with-socp-constraint/79414>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [April 13, 2022, 4:15am UTC](https://discourse.julialang.org/t/a-problem-with-socp-constraint/79414 "2022-04-13T04:15:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahon](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mahon](https://discourse.julialang.org/u/mahon)\
**Post date:** [April 13, 2022, 4:15am UTC](https://discourse.julialang.org/t/a-problem-with-socp-constraint/79414/1 "2022-04-13T04:15:31Z")

</div>

I want to formulate a SOCP constraint like this  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/5/15d2e7f16662e64a508f1e15f5e7d5c6ee2b1946.png)  
using Mosek and my code here

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/7/17f8dccb2e67211d040932c0c8ef1e6e2e18bb99.png)  
all variables are 32 × 24 matrix，but it pulls a error  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/5/b55add0f78003b8af9eab54d4db50745a5ecc531.png)  
and if i give the concrete row and columns ，it works  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/7/17b145fbddbb89ad8999d06921c75975625f32d6.png)

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [April 13, 2022, 4:25am UTC](https://discourse.julialang.org/t/a-problem-with-socp-constraint/79414/2 "2022-04-13T04:25:29Z")

</div>

Hi and welcome!  
It is hard to tell what went wrong without a Minimum Working Example (see the [forum guidelines](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)), maybe you could provide one?  
If `branch` is a variable, the problem could come from the indexing `V[Int.(real(branch[:,1])),:]`.  
Otherwise, my best guess is that SOCP constraints don’t accept multiplications (`V .* I` or squares `P.^2`) _inside_ the constraint, since it is their job to square stuff. But I’m not sure about this.

---

<div class="post-metadata">

**Author:** ![mahon](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mahon](https://discourse.julialang.org/u/mahon)\
**Post date:** [April 13, 2022, 4:32am UTC](https://discourse.julialang.org/t/a-problem-with-socp-constraint/79414/3 "2022-04-13T04:32:50Z")

</div>

thanks for replying， _ **branch** _ is just an known parameters，i think the key problem is that how to add a series SOCP constraint，like vector representation SOCP constraint

---

<div class="post-metadata">

**Author:** ![mahon](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mahon](https://discourse.julialang.org/u/mahon)\
**Post date:** [April 13, 2022, 4:47am UTC](https://discourse.julialang.org/t/a-problem-with-socp-constraint/79414/4 "2022-04-13T04:47:12Z")

</div>

i solved it like this

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/3/33950eaf0a05cf3701c755e1b5c2314a9e1da8d9.png)

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [April 13, 2022, 5:03am UTC](https://discourse.julialang.org/t/a-problem-with-socp-constraint/79414/5 "2022-04-13T05:03:41Z")

</div>

Glad you got it working!

Just for the future, it’s super useful for reading if you can follow the suggestions [here](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) especially this one:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757/1):
>
> **Post** [**quoted code**](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530) by enclosing code blocks in triple-backticks ````` :

Screenshots are a little a hard to read and edit. Thanks.
