Exec Error: division by zero (0) Topic is solved

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

Exec Error: division by zero (0)

Post by Judith »

Hi Members,

I am using a SAM Balancing Program in GAMS, released Dec 2013 distributed by PEP, to balance the SAM.
I am running this file: sambal_2013_JK in the attached zipped folder. The GAMS version I am using is: 24.3.3.

I have encountered the following execution error.
**** Exec Error at line 364: division by zero (0)
364 SAM0(INT,JNT) = SAM0(INT,JNT)/TOTO;

The error line is traced to this section:
Initial matrix values transformed in proportion ===============
PARAMETER
TOTO initial matrix total ;
TOTO = SUM((INT,JNT), SAM0(INT,JNT));
SAM0(INT,JNT) = SAM0(INT,JNT)/TOTO;

I find it illogical that TOTO can be zero. What could be the source of this error? How can I overcome it?

I have tried several solutions suggested in documentation but have not succeeded yet.
Attachments
GAMS_code & files.zip
(197.1 KiB) Downloaded 214 times
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Exec Error: division by zero (0)

Post by Renger »

Hi Judith

If Gams tells you something is zero, you better believe it and you should using display statements to check your code.
A quick check (display TOTO) reveals that TOTO has a value of zero.
If you look in your gdx file, TOTO is empty.
Now, if I look at your gdxxrw command to read your data, you specified the range of the sheet, but not the sheet itself. The code should read:

Code: Select all

$CALL GDXXRW i=NSAM_unbal2013.xlsx Par=SAM0 rng=sam0!A7:ER154 trace=3
$GDXIN NSAM_unbal2013.gdx
$LOAD SAM0
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: Exec Error: division by zero (0)

Post by Judith »

Dear Renger,

Thank you very much indeed. GAMS language is so precise. I am learning on the job.
All sorted for now. I can move to the next stage.

Best wishes,
Judith
Post Reply