Page 1 of 1

Division by Zero error

Posted: Wed May 06, 2020 6:13 pm
by Judith
Dear Members,
I hope you are well and keeping safe.
This is to request for your assistance in resolving this execution error. I am a basic GAMS user and have encountered the error: “Division by zero”. I have read the GAMS guide and some posts on the forum but I have not yet found the solution. The error is located at line 847-Division by zero.
847 KDO(k,j) = RKDO(k,j)/RO(k,j);
Here is the genesis of that computation in the model code:
alpha = SUM[(k,j),RKDO(k,j)*{(n1+delta(k,j))
/(delta(k,j)+IRO)}
/(ITO-SUM[i,PCO(i)*VSTKO(i)])];
RO(k,j) = alpha*UO(k,j);
KDO(k,j) = RKDO(k,j)/RO(k,j);
I am attaching the zipped model file in case you need to run through it, in order to assist me. In the project file: Ug-CGE.gpr, I am running the model: PEP_1-t-b_v2_1.gms, which calls the files: SAM-V2_0.xlxs and VAL_PAR.
Model_Ug.zip
(2.04 MiB) Downloaded 186 times
Thanking you for your kind assistance in advance.
Best wishes,
Judith

Re: Division by Zero error

Posted: Thu May 07, 2020 8:37 am
by Renger
Hi Judith
If GAMS tells you that there is a division by zero, you can bet on it that there is one, so you should display the divisor. One problem is that zero values are not shown in the output. You can check this by adding EPS to the parameter (after checking I should remove it).

Code: Select all

RO(k,j) = RO(k,j) + EPS;
display RO;
If you do this, you will see that AGA21 and AGA22 have zero values. Check if that makes sense, and if yes adjust your code accordingly.
Cheers
Renger

Re: Division by Zero error

Posted: Mon May 11, 2020 1:12 pm
by Judith
Hi Renger,

Thank you very much for your guidance.

Best wishes,
Judith