# SOCP constraint

**URL:** <https://discourse.julialang.org/t/socp-constraint/56234>\
**Category:** Optimization (Mathematical)\
**Created:** [March 1, 2021, 6:05am UTC](https://discourse.julialang.org/t/socp-constraint/56234 "2021-03-01T06:05:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SonLe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sonle/32/9507_2.png) [@SonLe](https://discourse.julialang.org/u/SonLe)\
**Post date:** [March 1, 2021, 6:05am UTC](https://discourse.julialang.org/t/socp-constraint/56234/1 "2021-03-01T06:05:53Z")

</div>

Hi, I have a question about verifying the SOCP constraint in JuMP.

So far, my SOCP constraint is \epsilon t \geq \theta\|\mathbf{x}\|\_{2}+\frac{1}{N} \sum\_{i \in[N]} r^{i}

and my code is

`@constraint(model, [ϵ * t * (1/θ) .- (1/θ*N)*sum(r[i] for i in [1:N]); x] in SecondOrderCone()) `

Is my approach true? This is a constraint in model 37, section 6.1 of this [paper](https://arxiv.org/abs/2007.06750)

---

<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:** [March 1, 2021, 7:46am UTC](https://discourse.julialang.org/t/socp-constraint/56234/2 "2021-03-01T07:46:36Z")

</div>

Couple of small things. You want instead

```julia
[ϵ * t * (1/θ) - 1/(θ*N)*sum(r[i] for i in 1:N)

```

---

<div class="post-metadata">

**Author:** ![SonLe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sonle/32/9507_2.png) [@SonLe](https://discourse.julialang.org/u/SonLe)\
**Post date:** [March 1, 2021, 8:03am UTC](https://discourse.julialang.org/t/socp-constraint/56234/3 "2021-03-01T08:03:48Z")

</div>

Thanks so much. To make sure my understanding, why we use **-** instead of **.-**?

---

<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:** [March 1, 2021, 6:25pm UTC](https://discourse.julialang.org/t/socp-constraint/56234/4 "2021-03-01T18:25:14Z")

</div>

Use .- for the elementwise subtraction between arrays. In this case, the first element is a scalar, so you don’t need the dot.

It will still work if you include it though.
