# Modelling of SOCP constraint and solving through CPLEX

**URL:** <https://discourse.julialang.org/t/modelling-of-socp-constraint-and-solving-through-cplex/82580>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [June 10, 2022, 7:14pm UTC](https://discourse.julialang.org/t/modelling-of-socp-constraint-and-solving-through-cplex/82580 "2022-06-10T19:14:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![musman](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@musman](https://discourse.julialang.org/u/musman)\
**Post date:** [June 10, 2022, 7:14pm UTC](https://discourse.julialang.org/t/modelling-of-socp-constraint-and-solving-through-cplex/82580/1 "2022-06-10T19:14:57Z")

</div>

Hello all, I am trying to implement and solve the following SOCP constraint through CPLEX solver

```julia
(cij)^2 + (sij)^2 <= cii*cjj

```

through Rotated Second Order cone as follows:

```julia
nSc = 10
nTP = 24
nBus = 34
nLines = 33
@variables(acopf,begin
        (c_ii[i=1:nSc, j=1:nTP,k=1:nBus])                                      
        (c_ij[i=1:nSc, j=1:nTP,k=1:nLines])                                   
        (s_ij[i=1:nSc, j=1:nTP,k=1:nLines])                                     
                 end

for s in 1:nSc 
     for t in 1:nTP 
          for i in 1:nLines
             aux_var = [sqrt(2)*cij[s,t,i],sqrt(2)*sij[s,t,i]]
             @constraint(acopf,[cii[s,t,i]; cii[s,t,i]; aux_var] in RotatedSecondOrderCone())
         end
     end
end

```

However, when I tried to solve it, I received the following error.

> LoadError: Constraints of type MathOptInterface.VectorAffineFunction{Float64}-in-MathOptInterface.RotatedSecondOrderCone are not supported by the solver.

Definitely, there is something wrong in the implementation of the constraint. Can someone tell where is the mistake and how to implement this constraint?

---

<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:** [June 12, 2022, 7:01am UTC](https://discourse.julialang.org/t/modelling-of-socp-constraint-and-solving-through-cplex/82580/2 "2022-06-12T07:01:40Z")

</div>

How did you define `acopf`? Did you try `adopt = Model(CPLEX.Optimizer)`?

Otherwise, just write it as the quadratic form.

```nohighlight
@constraint(acopf, 2 * cii[s,t,i] * cii[s,t,i] >= sum(x^2 for x in aux_var)

```
