Hi, I’m with a problem that I have a problem with 2 models.
The first is ok, my model optimize the flow at the tubes.
At the second I need to use equations, using that flow, but the tubes with no flow (zero), it shod be exclude.
But I don’t know how to express this condition.

My model is showing this massage.
" **** Exec Error at line 412: division by zero (0) "

So, the problem is my model try to use the equation to my first set, that have a variable that was optimized previously equal to a zero
but at the second model, the equation use the variable that is zero, but it should be exclude and not be calculated.

Model 1
Set
n nodes / n1 * n3 /
nn(n,n) tubs…;
alias(n,np);
…
Variables qr(n,np) (m**3 per sec) …;
…
Model flow /consn,qin,qout,qin1,qcl,binar,binsaid,qred,minvaz/ ;

Thank you very much Roger, this is exactly what I wanted.
But I think my code is not considering my variable as a SET.
For when I insert an error is presented:

472 flag (n, np) $ (qr (n, np)> 0) = 1;
**** $143

Did you know how to put this variable as a SET together with the value?
so that I can consider it in my second model? Or correct this error?

Hi
qr is a variable, so one should use qr.L in the parameter and you should stage it like this (don’t repeat the line with the definition of the parameter). If you still have a division by zero, this can be caused by another parameter or variable. Make sure that your other variables are not equal to zero at the start of the solve as these are the values that Gams uses as start values (e.g. by initialising them: a.l(nn) =1; dr.l(nn) = 1

Hi Roger
I was trying to write
the Parameter flag2
flag2(nn)$(qr.l(nn) > 0 ) = flag(nn) ;

but not using different models, How I supposed to program this, in the same model?

It’s indicated a error : (qr.l(nn))
*** Error 141 in D:.…gms
Symbol neither initialized nor assigned
A wild shot: You may have spurious commas in the explanatory
text of a declaration. Check symbol reference list.

When I use this PARAMETER with 2 diferents models, it run with no error.

Hi
It looks like you have assigned the values before running the model which doesn’t make sense as you don’t have a solution for Q available.
If you run the same model again using Q.L you should assign flag2 after the solve of the first instance.