I'm trying to formulate an indicator constraint. I'm using a small example for testing, but it still failed.

I used the small example from the GAMS official website, slightly modified though:

Here is the code

Code: Select all

```
set i /i1, i2, i3/
j /j1, j2, j3/;
Binary Variable use(i,j);
positive variable x(i,j);
variable z;
Equations
iminship(i,j), imaxship(i,j), ieqship(i,j), cost, binrel(i,j);
iminship(i,j).. x(i,j) =g= 0;
imaxship(i,j).. x(i,j) =l= 50;
ieqship(i,j).. x(i,j) =e= 0;
cost.. z =e= 20 * sum(i, sum(j, x(i,j)));
binrel(i,j)$(ord(i)=1).. use(i,j) =e= 0;
Model indicatorModel /all/ ;
file fcpx Cplex Option file / cplex.opt /;
putclose fcpx 'indic iminship(i,j)$use(i,j) 1' / 'indic ieqship(i,j)$use(i,j) 0';
indicatorModel.optfile = 1;
Solve indicatorModel using mip maximizing z ;
```

Code: Select all

```
Error: Variable not in model
Option record: indic iminship(i,j)$use(i,j) 1
```

P.S. I also tried formulating it in my big instance but it gave me a different error of

Code: Select all

` Error: Column is not of type Variable `

Though it is a separate issue, I would highly appreciate it if someone could shed some light on this error as well!

Best,

Gabriel