error: division by zero (0)

Dear everyone,

After running the gams, I met the “error: division by zero (0)” in the row "“txid0(r,rr,s)= it0(r,rr,s) / (idtl0(r,rr,s)-it0(r,rr,s));” which defines one type tax.
Set defination is as follows.

set
R REGIONS /
NE, BT, NC , EC , SC , CE , NW, SW /,
S sectors /
Agri Agriculture,
Mine Mining and Processing,
Food Manufacture of Foods and Tobacoco,
TeCl Textile and Clothing,
Wood Processing of Timbers woods and Manufacture of Furniture,
Pape Paper making, printing and Manufacture of Articles for education,
Chem Chemical Industry,
NMet Manufacture of Nonmetallic Mineral Products,
Meta Metals Smelting and Products,
Mach Machinery industry,
TrEq Manufacture of Transport Equipment,
ElEq Manufacture of Electrical Machinery and Equipment,
OMan Other Manufacture,
EHGW Production and Supply of Electric Power, Heat Power, Gas and Water,
Cons Construction,
TdTp Trade and Transportation,
OSer Other Services/,
alias (s,g), (r, rr);

Then I use “put” to show the r, rr,and s of zero value, like follow:

parameter Test1(r,rr,s);
Test1(r,rr,s) = idtl0(r,rr,s)-it0(r,rr,s);
display Test1;

file Test /Test.txt/;
put Test;
loop((r,rr,s),
if(Test1(r,rr,s)=0,
put r.tl, " “, rr.tl,” ", s.tl, " ";
put /;
);
);

The results Text.txt shows like :

NE NE printing
NE NE Heat
NE NE Gas
NE BT printing
NE BT Heat
NE BT Gas
NE NC printing
NE NC Heat
NE NC Gas
NE EC printing
NE EC Heat
NE EC Gas
NE SC printing
…… …… ……

All the zero values happen to the three sectors “Printing, Heat, Gas” in the third column, But the question is I didnot define the three sectors in “set s”.
How does it happen, and how to deal with this problem?

Any of your help will be appreciated very much.

Waiting for someone’s help.

Best regards.

Fan


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/K4lUHjavdv8J.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Try giving the relevant variables initial conditions that are non-zero. I’m not sure what the relevant variables are but assuming your equation is a=b/c set a.l=1, b.l=1, c.l=1

On Monday, 2 July 2012 12:05:23 UTC+1, Jingli Fan wrote:

Dear everyone,

After running the gams, I met the “error: division by zero (0)” in the row "“txid0(r,rr,s)= it0(r,rr,s) / (idtl0(r,rr,s)-it0(r,rr,s));” which defines one type tax.
Set defination is as follows.

set
R REGIONS /
NE, BT, NC , EC , SC , CE , NW, SW /,
S sectors /
Agri Agriculture,
Mine Mining and Processing,
Food Manufacture of Foods and Tobacoco,
TeCl Textile and Clothing,
Wood Processing of Timbers woods and Manufacture of Furniture,
Pape Paper making, printing and Manufacture of Articles for education,
Chem Chemical Industry,
NMet Manufacture of Nonmetallic Mineral Products,
Meta Metals Smelting and Products,
Mach Machinery industry,
TrEq Manufacture of Transport Equipment,
ElEq Manufacture of Electrical Machinery and Equipment,
OMan Other Manufacture,
EHGW Production and Supply of Electric Power, Heat Power, Gas and Water,
Cons Construction,
TdTp Trade and Transportation,
OSer Other Services/,
alias (s,g), (r, rr);

Then I use “put” to show the r, rr,and s of zero value, like follow:

parameter Test1(r,rr,s);
Test1(r,rr,s) = idtl0(r,rr,s)-it0(r,rr,s);
display Test1;

file Test /Test.txt/;
put Test;
loop((r,rr,s),
if(Test1(r,rr,s)=0,
put r.tl, " “, rr.tl,” ", s.tl, " ";
put /;
);
);

The results Text.txt shows like :

NE NE printing
NE NE Heat
NE NE Gas
NE BT printing
NE BT Heat
NE BT Gas
NE NC printing
NE NC Heat
NE NC Gas
NE EC printing
NE EC Heat
NE EC Gas
NE SC printing
…… …… ……

All the zero values happen to the three sectors “Printing, Heat, Gas” in the third column, But the question is I didnot define the three sectors in “set s”.
How does it happen, and how to deal with this problem?

Any of your help will be appreciated very much.

Waiting for someone’s help.

Best regards.

Fan


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/ExNAy_icDckJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Providing starting values is always a good idea, but in this case, the problem is caused by spurious commas in the descriptive text on the set elements; GAMS treats those as new elements of the set. For instance, in line Pape, GAMS will see printing as a new set element, with descriptive text " and Manufacture of Articles for education". Solution: get rid of the commas, or use quotation marks around the descriptive text.
Enjoy the modelling,

Rob


From: gamsworld@googlegroups.com [gamsworld@googlegroups.com] on behalf of KJ [kjennett@gmail.com]
Sent: 10 July 2012 13:02
To: gamsworld@googlegroups.com
Subject: Re: error: division by zero (0)

Try giving the relevant variables initial conditions that are non-zero. I’m not sure what the relevant variables are but assuming your equation is a=b/c set a.l=1, b.l=1, c.l=1

On Monday, 2 July 2012 12:05:23 UTC+1, Jingli Fan wrote:
Dear everyone,

After running the gams, I met the “error: division by zero (0)” in the row "“txid0(r,rr,s)= it0(r,rr,s) / (idtl0(r,rr,s)-it0(r,rr,s));” which defines one type tax.
Set defination is as follows.

set
R REGIONS /
NE, BT, NC , EC , SC , CE , NW, SW /,
S sectors /
Agri Agriculture,
Mine Mining and Processing,
Food Manufacture of Foods and Tobacoco,
TeCl Textile and Clothing,
Wood Processing of Timbers woods and Manufacture of Furniture,
Pape Paper making, printing and Manufacture of Articles for education,
Chem Chemical Industry,
NMet Manufacture of Nonmetallic Mineral Products,
Meta Metals Smelting and Products,
Mach Machinery industry,
TrEq Manufacture of Transport Equipment,
ElEq Manufacture of Electrical Machinery and Equipment,
OMan Other Manufacture,
EHGW Production and Supply of Electric Power, Heat Power, Gas and Water,
Cons Construction,
TdTp Trade and Transportation,
OSer Other Services/,
alias (s,g), (r, rr);

Then I use “put” to show the r, rr,and s of zero value, like follow:

parameter Test1(r,rr,s);
Test1(r,rr,s) = idtl0(r,rr,s)-it0(r,rr,s);
display Test1;

file Test /Test.txt/;
put Test;
loop((r,rr,s),
if(Test1(r,rr,s)=0,
put r.tl, " “, rr.tl,” ", s.tl, " ";
put /;
);
);

The results Text.txt shows like :

NE NE printing
NE NE Heat
NE NE Gas
NE BT printing
NE BT Heat
NE BT Gas
NE NC printing
NE NC Heat
NE NC Gas
NE EC printing
NE EC Heat
NE EC Gas
NE SC printing
…… …… ……

All the zero values happen to the three sectors “Printing, Heat, Gas” in the third column, But the question is I didnot define the three sectors in “set s”.
How does it happen, and how to deal with this problem?

Any of your help will be appreciated very much.

Waiting for someone’s help.

Best regards.

Fan


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/ExNAy_icDckJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


\

Rob.
Thanks very much. You are right, it is solved by using quotation marks.
Best
Fan

2012/7/10 Dellink, Rob

Providing starting values is always a good idea, but in this case, the problem is caused by spurious commas in the descriptive text on the set elements; GAMS treats those as new elements of the set. For instance, in line Pape, GAMS will see printing as a new set element, with descriptive text " and Manufacture of Articles for education". Solution: get rid of the commas, or use quotation marks around the descriptive text.
Enjoy the modelling,

Rob


From: gamsworld@googlegroups.com [gamsworld@googlegroups.com] on behalf of KJ [kjennett@gmail.com]
Sent: 10 July 2012 13:02
To: gamsworld@googlegroups.com
Subject: Re: error: division by zero (0)

Try giving the relevant variables initial conditions that are non-zero. I’m not sure what the relevant variables are but assuming your equation is a=b/c set a.l=1, b.l=1, c.l=1

On Monday, 2 July 2012 12:05:23 UTC+1, Jingli Fan wrote:
Dear everyone,

After running the gams, I met the “error: division by zero (0)” in the row "“txid0(r,rr,s)= it0(r,rr,s) / (idtl0(r,rr,s)-it0(r,rr,s));” which defines one type tax.
Set defination is as follows.

set
R REGIONS /
NE, BT, NC , EC , SC , CE , NW, SW /,
S sectors /
Agri Agriculture,
Mine Mining and Processing,
Food Manufacture of Foods and Tobacoco,
TeCl Textile and Clothing,
Wood Processing of Timbers woods and Manufacture of Furniture,
Pape Paper making, printing and Manufacture of Articles for education,
Chem Chemical Industry,
NMet Manufacture of Nonmetallic Mineral Products,
Meta Metals Smelting and Products,
Mach Machinery industry,
TrEq Manufacture of Transport Equipment,
ElEq Manufacture of Electrical Machinery and Equipment,
OMan Other Manufacture,
EHGW Production and Supply of Electric Power, Heat Power, Gas and Water,
Cons Construction,
TdTp Trade and Transportation,
OSer Other Services/,
alias (s,g), (r, rr);

Then I use “put” to show the r, rr,and s of zero value, like follow:

parameter Test1(r,rr,s);
Test1(r,rr,s) = idtl0(r,rr,s)-it0(r,rr,s);
display Test1;

file Test /Test.txt/;
put Test;
loop((r,rr,s),
if(Test1(r,rr,s)=0,
put r.tl, " “, rr.tl,” ", s.tl, " ";
put /;
);
);

The results Text.txt shows like :

NE NE printing
NE NE Heat
NE NE Gas
NE BT printing
NE BT Heat
NE BT Gas
NE NC printing
NE NC Heat
NE NC Gas
NE EC printing
NE EC Heat
NE EC Gas
NE SC printing
…… …… ……

All the zero values happen to the three sectors “Printing, Heat, Gas” in the third column, But the question is I didnot define the three sectors in “set s”.
How does it happen, and how to deal with this problem?

Any of your help will be appreciated very much.

Waiting for someone’s help.

Best regards.

Fan


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/ExNAy_icDckJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.