Page 1 of 1

Execution Error : Division by zero

Posted: Tue Jan 15, 2019 8:41 pm
by delelayo08
Dear (sirs),

I encounter an Execution error (Execution Error : Division by zero) on line 188 after running my model in GAMS.

Will like to know the root cause. and possibly rectification.

Find my GAMS code in the attached file.

Regards,

Moyo.

Re: Execution Error : Division by zero

Posted: Wed Jan 16, 2019 8:03 am
by Renger
Hi

The only equation in the model used with a division is:
augm_obj.. sum(o1,dir(o1)*b(o1)) + 1e-3*sum(om1,sl(om1)/(maxobj(om1) - minobj(om1))) =e= a_objval;
so, it looks like the difference between maxobj(om1) and minobj(om1) gets zero for a certain or all om1.
You could rewrite the equation by adding a $constraint, but I don't know if this is what you want:
augm_obj.. sum(o1,dir(o1)*b(o1)) + 1e-3*sum(om1$(maxobj(om1) - minobj(om1)),sl(om1)/(maxobj(om1) - minobj(om1))) =e= a_objval;
Hope this helps
Cheers
Renger

Re: Execution Error : Division by zero

Posted: Wed Jan 16, 2019 8:11 am
by bussieck
GAMS is pretty precise giving you pointers to your problem. In the listing file you find:

Code: Select all

**** Exec Error at line 188: division by zero (0)
line 188 reads

Code: Select all

 188  augm_obj.. sum(o1,dir(o1)*b(o1)) + 1e-3*sum(om1,sl(om1)/(maxobj(om1) - minobj(om1))) =e= a_objval;
Fortunately, there is only one division by '(maxobj(om1) - minobj(om1))'. So one of the om1 seem to have maxobj=minobj when generating the model in question (mod_epsmethod). I displayed om1, minobj, and maxobj before the repeat loop solving model mod_epsmethod and voila:

Code: Select all

----    260 SET om1  all but the first elements of k
te,    tj

----    260 PARAMETER maxobj  maximum value from the payoff table
                      ( ALL       0.000 )

----    260 PARAMETER minobj  minimum value from the payoff table
                      ( ALL       0.000 )
You can use the $ to avoid executing the division (e.g. sum(om1$(abs(maxobj(om1) - minobj(om1))>1e-6),sl(om1)/(maxobj(om1) - minobj(om1)))), but the logical error that resulted in the division by 0 might be somewhere else.

Hope this helps,
Michael

Re: Execution Error : Division by zero

Posted: Sat Jan 19, 2019 8:27 am
by delelayo08
Tnx alot bussieck and Renger. i appreciate you all.

Regards,

Moyo