Page 1 of 1
Zero Division Error
Posted: Wed Apr 17, 2024 4:11 pm
by Merey
Hi!
I was trying to create a model for Mozambique. But the program gets zero division error every time. I see gaps in my data set, but I don't know how I can fill them. Any ideas?
Re: Zero Division Error
Posted: Thu Apr 18, 2024 2:21 pm
by Fred
Hi Merey,
Running your code, I get
Code: Select all
--- MOZSAM_test.gms(165) 4 Mb[FIL:"C:\Users\ffian\Documents\support\MOZSAM_test.gms",165,0]
*** Error at line 165: division by zero (0)[LST:522]
--- MOZSAM_test.gms(171) 4 Mb 1 Error[FIL:"C:\Users\ffian\Documents\support\MOZSAM_test.gms",171,0]
*** Error at line 171: division by zero (0)[LST:523]
--- MOZSAM_test.gms(899) 6 Mb 2 Errors
The corresponding lines in the
echo print are
Code: Select all
165 tq(c)=SAM("stax",c)/QQ0(c);
[...]
171 tim(c) = SAM("mtax",c)/SAM("ROW",c);
If QQ0(c) is zero for certain c, you get a division by zero error. The question is, what should tq(c) be for those elements in c? You could for example just skip those c by adding a simple dollar condition
Code: Select all
tq(c)$QQ0(c)=SAM("stax",c)/QQ0(c);
You could use the same "trick" in line 171 as well. The question is, whether this gives you the desired results? You are the only person that can answer this question.
I hope this helps!
Fred