I’m modelling a problem on GAMS (interfaced with Matlab) and I’m trying to sort some data before returning the values to Matlab in order to lower the amount of variables transferred back through MATOUT (which increase processing time).

pen, P_linha, sumPen and sumPen2 are variables; lim_linhas is a parameter;

This is basically what I’m trying to do:

```
penCalc(l,t,ind).. pen(l,t,ind) =e= (P_linha(l,t,ind) - lim_linhas(l))*10000;
penCalc2(l,t,ind).. IF (pen(l,t,int) =l= 0) THEN pen(l,t,int) = 0;
penCalc3(l,ind).. sum(t, pen(l,t,ind)) =e= sumPen(l,ind);
penCalc4(ind).. sum(l, sumPen(l,ind)) =e= sumPen2(ind);
```

I’ve tried doing this:

```
penCalc(l,t,ind).. pen(l,t,ind) =e= (P_linha(l,t,ind) - lim_linhas(l))*10000;
penCalc2(l,t,ind).. pen(l,t,ind) $ (pen(l,t,int) =l= 0) = 0;
penCalc3(l,ind).. sum(t, pen(l,t,ind)) =e= sumPen(l,ind);
penCalc4(ind).. sum(l, sumPen(l,ind)) =e= sumPen2(ind);
```

and this:

```
penCalc(l,t,ind)$(P_linha(l,t,ind) - lim_linhas(l) > 0).. pen(l,t,ind) =e= (P_linha(l,t,ind) - lim_linhas(l))*10000;
penCalc2(l,t,ind)$(P_linha(l,t,ind) - lim_linhas(l) < 0).... pen(l,t,int) =e= 0;
penCalc3(l,ind).. sum(t, pen(l,t,ind)) =e= sumPen(l,ind);
penCalc4(ind).. sum(l, sumPen(l,ind)) =e= sumPen2(ind);
```

I believe these don’t work because $ if verified at model generation and not passed on to the solver. Also, this data does not influence the optimization but is a consequence of it.

Any feedback is appreciated,