Division by Zero error

Problems with syntax of GAMS
Post Reply
Judith
User
User
Posts: 6
Joined: 4 years ago

Division by Zero error

Post 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
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Division by Zero error

Post 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
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Judith
User
User
Posts: 6
Joined: 4 years ago

Re: Division by Zero error

Post by Judith »

Hi Renger,

Thank you very much for your guidance.

Best wishes,
Judith
Post Reply