### Conic constraint in GAMS

Posted:

**Tue Nov 19, 2019 10:13 pm**Hi experts!

I just ran into some problems for writing conic constraints in GAMS. I was trying to test the second-order cone programming (SOCP) duality by the following problem from the Stanford course:

min 2 * x1 + x2 + x3

s.t. x1 + x2 + x3 = 1

sqr(x1) =g= sqr(x2) + sqr(x3)

And the dual of this SOCP is

max y

s.t. y + s1 = 2

y + s2 = 1

y + s3 = 1

sqr(s1) =g= sqr(s2) + sqr(s3)

Seems simple right? Here is the code I wrote for the two programs, and I used Mosek as the solver.

If you try this code, Mosek will give you a piece of information saying that
Here PSD denotes positive semi-definite. But what? I believe the coefficient matrices in my eq3 and eq8 are PSD!

However, when I changed the notation of eq3 and eq8 to:
and
They now run correctly! And they both give the correct optimal solution of square root 2, which supports the strong duality.

Then I moved to Gurobi and Cplex, then found that the =c= operator is only valid in Mosek. But I still heard that Gurobi and Cplex CAN solve SOCP problems. So my question is, how can I code correctly by using =g= instead of =c= for a SOCP problem?

Thanks in advance!

Gabriel

I just ran into some problems for writing conic constraints in GAMS. I was trying to test the second-order cone programming (SOCP) duality by the following problem from the Stanford course:

min 2 * x1 + x2 + x3

s.t. x1 + x2 + x3 = 1

sqr(x1) =g= sqr(x2) + sqr(x3)

And the dual of this SOCP is

max y

s.t. y + s1 = 2

y + s2 = 1

y + s3 = 1

sqr(s1) =g= sqr(s2) + sqr(s3)

Seems simple right? Here is the code I wrote for the two programs, and I used Mosek as the solver.

Code: Select all

```
free variable
x1, x2, x3;
free variable
y, obj, obj2;
equations
eq1
eq2
eq3
eq10;
eq1.. obj =e= 2 * x1 + x2 + x3;
eq2.. x1 + x2 + x3 =e= 1;
eq3.. sqr(x1) =g= sqr(x2) + sqr(x3);
option qcp = mosek;
model test /eq1, eq2, eq3/;
solve test using qcp minimizing obj;
free variable
s1, s2, s3;
equations
eq4
eq5
eq6
eq7
eq8;
eq4.. obj2 =e= y;
eq5.. y + s1 =e= 2;
eq6.. y + s2 =e= 1;
eq7.. y + s3 =e= 1;
eq8.. sqr(s1) =g= sqr(s2) + sqr(s3);
model test2 /eq4, eq5, eq6, eq7, eq8/;
solve test2 using qcp maximizing obj2;
```

Code: Select all

```
Return code - 1293 [MSK_RES_ERR_CON_Q_NOT_PSD]: The quadratic constraint matrix is not PSD
```

However, when I changed the notation of eq3 and eq8 to:

Code: Select all

```
eq3.. x1 =c= x2 + x3;
```

Code: Select all

```
eq8.. s1 =c= s2 + s3;
```

Then I moved to Gurobi and Cplex, then found that the =c= operator is only valid in Mosek. But I still heard that Gurobi and Cplex CAN solve SOCP problems. So my question is, how can I code correctly by using =g= instead of =c= for a SOCP problem?

Thanks in advance!

Gabriel