Execution Error : Division by zero

Problems with modeling
delelayo08
User Posts: 12
Joined: 1 year ago

Execution Error : Division by zero

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.
Attachments
STO.gms

Renger
Posts: 397
Joined: 3 years ago

Re: Execution Error : Division by zero

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
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

bussieck
Moderator Posts: 344
Joined: 3 years ago

Re: Execution Error : Division by zero

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)

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

delelayo08
User Posts: 12
Joined: 1 year ago

Re: Execution Error : Division by zero

Tnx alot bussieck and Renger. i appreciate you all.

Regards,

Moyo