A "division by zero" in a line where no calculation happens Topic is solved

Problems with modeling
Post Reply
Daymon
User
User
Posts: 6
Joined: 3 years ago

A "division by zero" in a line where no calculation happens

Post by Daymon »

Being a relatively new in GAMS programming, I have a dynamic single country CGE model implemented in GAMS. I am trying to change the region of interest for the model. After changing the model's input data, I firstly try to run the static simulation. By doing so, while the sets are read smoothly, a division by zero occurs in a line where no calculation happens (e.g. line 2967 the first error). So, I am unable to debugg the model. Atached photo shows the errors that arise. For reproducing the case, from the attached files (files (2).zip), the "stat_shk.gms" needs to be run. The other folder's files are just needed because the "stat_shk.gms" opens them. Only the working directory path and the paths of the files that are opened need to be changed (I have marked these three regions with "to be changed").

Could anyone help me?

Thank you in advance.
files (2).zip
(33.97 KiB) Downloaded 195 times
Error log.PNG
Fred
Posts: 373
Joined: 7 years ago

Re: A "division by zero" in a line where no calculation happens

Post by Fred »

Hi,

Note that the line numbers refer to the echo print in the lst file.
Unfortunately, some if the include files are missing in the zip archive, so it is not possible to reproduce the problem.

Best,
Fred
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: A "division by zero" in a line where no calculation happens

Post by Renger »

Hi
If you want help, you should provide your model in such a way that it runs without any interference from the person who wants to help you.
In your case, you should be sure that all files used are included (which is not the case) and the model produces lots of errors because of paths to subdirectories that do not exist.
Test your files before you send them.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Daymon
User
User
Posts: 6
Joined: 3 years ago

Re: A "division by zero" in a line where no calculation happens

Post by Daymon »

Thank you so much for your replies and apologies for any missing files required for reproducing the problem (stat_shk.gms).

I hope that now by using the attached files, the reproduction (stat_shk.gms) is possible.
The only requirement is the file's working directory to be changed.

Thank you in advance.
files (2).zip
(101.52 KiB) Downloaded 208 times
Fred
Posts: 373
Joined: 7 years ago

Re: A "division by zero" in a line where no calculation happens

Post by Fred »

Hi,

As I wrote in my previous post, the line numbers refer to the echo print in the lst file.
Looking up the lines and checking the data, there is obviously a division by zero.

Best,
Fred
Daymon
User
User
Posts: 6
Joined: 3 years ago

Re: A "division by zero" in a line where no calculation happens

Post by Daymon »

thank you so much for your reply.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: A "division by zero" in a line where no calculation happens

Post by Renger »

Hi
A good way of testing if you are missing zero values is the following:

Code: Select all

yh.l(h,t) = yh.l(h,t) + EPS;
display yh.l;
GAMS doesn't display zeros, so you would easily miss parameters that are zero. Adding EPS (the special value EPS is numerically equal to zero, so when used in the context of numerical comparisons, it behaves as zero) displays all values.
In your case:

Code: Select all

----   2967 VARIABLE yh.L  Total household income

            base       check       shock

PRIV         EPS         EPS         EPS
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Daymon
User
User
Posts: 6
Joined: 3 years ago

Re: A "division by zero" in a line where no calculation happens

Post by Daymon »

Thank you Mr. Renger for your answer.
Post Reply