It is a great help Renger. Thank you so much.
On Friday, 6 November 2015 14:08:10 UTC+5:30, Renger van Nieuwkoop wrote:
Hi Partha
Two remarks:
-
In your second calculation you will have zeros for alle combinations of the set z and itself that are not available in the table (e.g. b1.b1) which causes the error. You just add a $-condition on the left hand side to get rid of the errors.
-
In your second calculation of t you only calculate the diagonal elements (b1.b1, b2.b2, etc.). If you want to calculate all the elements, you should define an alias for z.
Here is the way it works for me:
alias(z,z1);
parameter p(z,z);
p(z,z1)$(sqr(t(z,z1,‘r’))+sqr(t(z,z1,‘x’)))=t(z,z1,‘r’)/(sqr(t(z,z1,‘r’))+sqr(t(z,z1,‘x’)));
Chees
Renger
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Partha Das
Sent: Freitag, 6. November 2015 07:23
To: gamsworld
Subject: Re: Division by zero error
Actually I have the following issue:
I am calculating p(z) from the table as follows with no error,
set z /b1*b6/ ;
table t(z,*) dat
r x
b1 0.005 0.17
b2 0.001 0.037
b3 0.003 0.258
b4 0.007 0.197
b5 0.001 0.037
b6 0.002 0.14 ;
parameter p(z);
p(z)=t(z,‘r’)/(sqr(t(z,‘r’))+sqr(t(z,‘x’)));
but when we define the table like the following I have division by zero error
set z /b1*b6/ ;
table t(z,z,*) dat
r x
b1.b2 0.005 0.17
b2.b3 0.001 0.037
b1.b4 0.003 0.258
b2.b4 0.007 0.197
b4.b5 0.001 0.037
b5.b6 0.002 0.14
b3.b6 0.001 0.018 ;
parameter p(z,z);
p(z,z)=t(z,z,‘r’)/(sqr(t(z,z,‘r’))+sqr(t(z,z,‘x’)));
Any clue?
On Thursday, 5 November 2015 19:00:27 UTC+5:30, Partha Das wrote:
I am trying to calculate a parameter x=y/(y^2+z^2).
I have written x=y/(sqr(y)+sqr(z))
the values of y & z parameters are already defined. y contains some zeros, but z contains no zeros. still I am getting UNDF as the output (i.e. x). Any help?
On Wednesday, 4 July 2012 14:39:44 UTC+5:30, Renger van Nieuwkoop wrote:
HI Jackson
Assume you have a set I /i1, i2,i3/ and a parameter c(i) that is initialized as follows:
c(“i1â€) = 2;
c(“i2â€) = 0;
c(“i3â€) = 3;
If you do a display, gams will display this as follows:
---- 9 PARAMETER c
i1 2.000, i3 3.000
The value for i2 is not reported. Here it is easy to spot this missing value, as you only have 3 set elements, but if you have lots of I’s it gets harder to spot the zeros.
If you do the following
c(i) = c(i) + EPS;
Gams adds a very, very small figure to c(i), which does not impact the results. Your output will now be:
i1 2.000, i2 EPS, i3 3.000
and you see the “zero†easily.
Another way would be:
Parameter testforzeros(i);
Testforzeros(i)$(c(i) eq 0) = 1;
Display testforzeros;
With the following output (even if you added EPS!)
---- 16 PARAMETER testforzeros
i2 1.000
Hope, this helps. If you still have this error message, send the model and I have a look at it.
Cheers
Renger
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Jackson
Sent: Tuesday, July 03, 2012 10:42 PM
To: gams...@googlegroups.com
Subject: Re: Division by zero error
Hi Renger,
Thanks for helping me out today.
I ran the display for parameter c(i) and none of the values are zero. Where do I add the eps to values? Under parameters or equations?
Thanks,
Jackson
On Tuesday, July 3, 2012 4:28:21 PM UTC-4, Renger van Nieuwkoop wrote:
Hi Jackson
It looks like one of the c(i) is zero…
Just display them and see if one of them is zero (be sure to add eps to the values, so Gams reports the zero values ( e.g. c(i) = c(i) + EPS)
Renger
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Jackson
Sent: Tuesday, July 03, 2012 10:22 PM
To: gams...@googlegroups.com
Cc: herve guene
Subject: Re: Division by zero error
Hello Mr. Herve,
I’m also having a similar error. This is my objective function code:
Objfunction … z =e= sum((i), ( x(i)*((m(i)/c(i))) ) )
The x(i) is my variable.
The m(i) and c(i) are both parameters.
However, I’ve already read in data from excel for each parameter. Would this still cause the c(i) to be zero? How can I fix this?
Thanks,
Jackson
On Monday, July 2, 2012 4:40:00 PM UTC-4, Herve wrote:
check the values of your parameters,
specially those that are denominators, because the default value of a parameter is zero. so untill you give or compute an initial value for them you’ll get division by zero error.
Merci et bonne réception!
M. Hervé Jean-Louis GUENE
Ingénieur Statisticien - Economiste
Institut National de la Statistique et de la Démographie/ Burkina-Faso
cel:(+226) 71 31 53 52/ 75 503 803/ 78 35 77 76
De : Mohd Shuaib
À : gams...@googlegroups.com
Envoyé le : Lundi 2 juillet 2012 18h12
Objet : Division by zero error
Hi All,
I encountered a division by zero error when i tried to run my model.
Specifically, the error takes me to the following lines in my gams code:
tyh(H) = DTHO(H)/YHO(H); (**** Exec Error at line 28078: division by zero (0))
psi(H) = SHO(H)/YDHO(H); (**** Exec Error at line 28138: division by zero (0))
I have also defined them under variable assignment as follows:
YHO(H) = lambda_w(H)+lambda_r(H)+TGO(H)+TRHO(H);
SHO(H) = YHO(H)-DTHO(H)-SUM(TR,CO(H,TR));
Can someone please assist towards rectifying this errors.
Thank you in advance.
–
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
…
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.