--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
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.
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
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/90W3M2OxjzQJ.
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
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/8JwCjqGicmYJ.
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
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to
gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
...