I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
\
Hi Brett
I assume that you have a table of the form distance(startnode, endnode).
You can then add high values for all values that do not have an entry by simply adding
distance(startnode, endnode)$(not distance(startnode, endnode) = 1E6;
However, you could also define a mapping between the nodes and use this set (“arc”) in your equations:
Arc(endnode, startnode) /n1.n2, n3.4, …/;
This set can be defined using the table (assuming that the set node is the set with all the nodes)
Alias(node, anode);
Set arc(node, anode) ;
Arc(node,anode)$distance(node, anode) = YES;
Hope this helps
Renger
-----Ursprüngliche Nachricht-----
Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Brett Decker
Gesendet: Montag, 29. Juni 2015 16:13
An: gamsworld@googlegroups.com
Betreff: Create default value for missing arcs
I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
\
Brett,
You could use the value NA for the missing arcs. However, that implies that you store values for all possible arcs, even missing ones. That is not sparse, and GAMS is designed to handle data in a sparse way. In this case, I suggest leaving the distance as zero for missing arcs: this implies that no arc exists. For example:
set i ‘supply’ / s1, s2 /,
j ‘demand’ / d1, d2 /;
parameter d(i,j) ‘distance’ /
s1.d1 6
s2.d1 eps
s2.d2 7
/;
equation cost;
cost… z =e= sum{(i,j)$d(i,j), d(i,j)*x(i,j)};
This avoids creating variable x(‘s1’,‘d2’) since that arc does not exist. Note that we use the value eps for an arc like ‘s2’ → ‘d1’ that exists but has a zero cost/distance. That is exactly what eps is for.
Of course, if you don’t have any arcs with zero cost/distance, then you can skip all this stuff about eps. But it might help you to know it.
-Steve
On Mon, Jun 29, 2015 at 10:13 AM, Brett Decker wrote:
I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com
Steve,
Thank you for your response! I am not sure how I can make your suggestion work because I don’t have a table with the pairs that don’t exist. The only thing I have in my include file is the i,j pairs that exist and the distance between them. I am hoping to find a way to write a function that assigns a value or like you suggested “eps” for any pair that isn’t in my table of costs without manually creating each of those pairs.
Thanks,
Brett
On Monday, June 29, 2015 at 10:35:39 AM UTC-4, Steven Dirkse wrote:
Brett,
You could use the value NA for the missing arcs. However, that implies that you store values for all possible arcs, even missing ones. That is not sparse, and GAMS is designed to handle data in a sparse way. In this case, I suggest leaving the distance as zero for missing arcs: this implies that no arc exists. For example:
set i ‘supply’ / s1, s2 /,
j ‘demand’ / d1, d2 /;
parameter d(i,j) ‘distance’ /
s1.d1 6
s2.d1 eps
s2.d2 7
/;
equation cost;
cost… z =e= sum{(i,j)$d(i,j), d(i,j)*x(i,j)};
This avoids creating variable x(‘s1’,‘d2’) since that arc does not exist. Note that we use the value eps for an arc like ‘s2’ → ‘d1’ that exists but has a zero cost/distance. That is exactly what eps is for.
Of course, if you don’t have any arcs with zero cost/distance, then you can skip all this stuff about eps. But it might help you to know it.
-Steve
On Mon, Jun 29, 2015 at 10:13 AM, Brett Decker wrote:
I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
Brett,
The idea of sparsity is that you don’t list or enumerate the arcs that do not exist, only the arcs that do exist. In my example code, data for parameter d(i,j) exists only for arcs that exist, so the cost computation sum{(i,j)$d(i,j), d(i,j)*x(i,j)} uses space/time proportional to the number of arcs (i.e. card(d)), not the cartesian product (i.e. card(i) * card(j)).
Forget about using EPS for the moment: the bigger issue is handling data in a sparse way.
-Steve
On Mon, Jun 29, 2015 at 12:38 PM, Brett Decker wrote:
Steve,
Thank you for your response! I am not sure how I can make your suggestion work because I don’t have a table with the pairs that don’t exist. The only thing I have in my include file is the i,j pairs that exist and the distance between them. I am hoping to find a way to write a function that assigns a value or like you suggested “eps” for any pair that isn’t in my table of costs without manually creating each of those pairs.
Thanks,
Brett
On Monday, June 29, 2015 at 10:35:39 AM UTC-4, Steven Dirkse wrote:
Brett,
You could use the value NA for the missing arcs. However, that implies that you store values for all possible arcs, even missing ones. That is not sparse, and GAMS is designed to handle data in a sparse way. In this case, I suggest leaving the distance as zero for missing arcs: this implies that no arc exists. For example:
set i ‘supply’ / s1, s2 /,
j ‘demand’ / d1, d2 /;
parameter d(i,j) ‘distance’ /
s1.d1 6
s2.d1 eps
s2.d2 7
/;
equation cost;
cost… z =e= sum{(i,j)$d(i,j), d(i,j)*x(i,j)};
This avoids creating variable x(‘s1’,‘d2’) since that arc does not exist. Note that we use the value eps for an arc like ‘s2’ → ‘d1’ that exists but has a zero cost/distance. That is exactly what eps is for.
Of course, if you don’t have any arcs with zero cost/distance, then you can skip all this stuff about eps. But it might help you to know it.
-Steve
On Mon, Jun 29, 2015 at 10:13 AM, Brett Decker wrote:
I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com
Steve,
Ok this makes more sense to me, I think this will work for my situation. Thank you for your response and insight.
-Brett
On Monday, June 29, 2015 at 1:06:21 PM UTC-4, Steven Dirkse wrote:
Brett,
The idea of sparsity is that you don’t list or enumerate the arcs that do not exist, only the arcs that do exist. In my example code, data for parameter d(i,j) exists only for arcs that exist, so the cost computation sum{(i,j)$d(i,j), d(i,j)*x(i,j)} uses space/time proportional to the number of arcs (i.e. card(d)), not the cartesian product (i.e. card(i) * card(j)).
Forget about using EPS for the moment: the bigger issue is handling data in a sparse way.
-Steve
On Mon, Jun 29, 2015 at 12:38 PM, Brett Decker wrote:
Steve,
Thank you for your response! I am not sure how I can make your suggestion work because I don’t have a table with the pairs that don’t exist. The only thing I have in my include file is the i,j pairs that exist and the distance between them. I am hoping to find a way to write a function that assigns a value or like you suggested “eps” for any pair that isn’t in my table of costs without manually creating each of those pairs.
Thanks,
Brett
On Monday, June 29, 2015 at 10:35:39 AM UTC-4, Steven Dirkse wrote:
Brett,
You could use the value NA for the missing arcs. However, that implies that you store values for all possible arcs, even missing ones. That is not sparse, and GAMS is designed to handle data in a sparse way. In this case, I suggest leaving the distance as zero for missing arcs: this implies that no arc exists. For example:
set i ‘supply’ / s1, s2 /,
j ‘demand’ / d1, d2 /;
parameter d(i,j) ‘distance’ /
s1.d1 6
s2.d1 eps
s2.d2 7
/;
equation cost;
cost… z =e= sum{(i,j)$d(i,j), d(i,j)*x(i,j)};
This avoids creating variable x(‘s1’,‘d2’) since that arc does not exist. Note that we use the value eps for an arc like ‘s2’ → ‘d1’ that exists but has a zero cost/distance. That is exactly what eps is for.
Of course, if you don’t have any arcs with zero cost/distance, then you can skip all this stuff about eps. But it might help you to know it.
-Steve
On Mon, Jun 29, 2015 at 10:13 AM, Brett Decker wrote:
I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
Steve,
This is probably a simple part of GAMS but I’m fairly inexperienced with GAMS. Can you explain what is being done by putting a in the cost computation? I have been reading through the McCarl user guide and I see that the is used for a lot of different functions/operations.
Thank you for your time.
Brett
On Monday, June 29, 2015 at 1:06:21 PM UTC-4, Steven Dirkse wrote:
Brett,
The idea of sparsity is that you don’t list or enumerate the arcs that do not exist, only the arcs that do exist. In my example code, data for parameter d(i,j) exists only for arcs that exist, so the cost computation sum{(i,j)$d(i,j), d(i,j)*x(i,j)} uses space/time proportional to the number of arcs (i.e. card(d)), not the cartesian product (i.e. card(i) * card(j)).
Forget about using EPS for the moment: the bigger issue is handling data in a sparse way.
-Steve
On Mon, Jun 29, 2015 at 12:38 PM, Brett Decker wrote:
Steve,
Thank you for your response! I am not sure how I can make your suggestion work because I don’t have a table with the pairs that don’t exist. The only thing I have in my include file is the i,j pairs that exist and the distance between them. I am hoping to find a way to write a function that assigns a value or like you suggested “eps” for any pair that isn’t in my table of costs without manually creating each of those pairs.
Thanks,
Brett
On Monday, June 29, 2015 at 10:35:39 AM UTC-4, Steven Dirkse wrote:
Brett,
You could use the value NA for the missing arcs. However, that implies that you store values for all possible arcs, even missing ones. That is not sparse, and GAMS is designed to handle data in a sparse way. In this case, I suggest leaving the distance as zero for missing arcs: this implies that no arc exists. For example:
set i ‘supply’ / s1, s2 /,
j ‘demand’ / d1, d2 /;
parameter d(i,j) ‘distance’ /
s1.d1 6
s2.d1 eps
s2.d2 7
/;
equation cost;
cost… z =e= sum{(i,j)$d(i,j), d(i,j)*x(i,j)};
This avoids creating variable x(‘s1’,‘d2’) since that arc does not exist. Note that we use the value eps for an arc like ‘s2’ → ‘d1’ that exists but has a zero cost/distance. That is exactly what eps is for.
Of course, if you don’t have any arcs with zero cost/distance, then you can skip all this stuff about eps. But it might help you to know it.
-Steve
On Mon, Jun 29, 2015 at 10:13 AM, Brett Decker wrote:
I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
Brett,
In brief, the $-condition is limiting the sum, so instead of summing over all i,j pairs it sums over i,j pairs that occur in the parameter d.
This is an important and basic topic, and I can’t do it justice here. See the GAMS User Guide chapter 11 “Conditional Expressions, Assignments
and Equations” or in the McCarl Guide (search for “conditional”).
-Steve
On Mon, Jun 29, 2015 at 4:32 PM, Brett Decker wrote:
Steve,
This is probably a simple part of GAMS but I’m fairly inexperienced with GAMS. Can you explain what is being done by putting a in the cost computation? I have been reading through the McCarl user guide and I see that the is used for a lot of different functions/operations.
Thank you for your time.
Brett
On Monday, June 29, 2015 at 1:06:21 PM UTC-4, Steven Dirkse wrote:
Brett,
The idea of sparsity is that you don’t list or enumerate the arcs that do not exist, only the arcs that do exist. In my example code, data for parameter d(i,j) exists only for arcs that exist, so the cost computation sum{(i,j)$d(i,j), d(i,j)*x(i,j)} uses space/time proportional to the number of arcs (i.e. card(d)), not the cartesian product (i.e. card(i) * card(j)).
Forget about using EPS for the moment: the bigger issue is handling data in a sparse way.
-Steve
On Mon, Jun 29, 2015 at 12:38 PM, Brett Decker wrote:
Steve,
Thank you for your response! I am not sure how I can make your suggestion work because I don’t have a table with the pairs that don’t exist. The only thing I have in my include file is the i,j pairs that exist and the distance between them. I am hoping to find a way to write a function that assigns a value or like you suggested “eps” for any pair that isn’t in my table of costs without manually creating each of those pairs.
Thanks,
Brett
On Monday, June 29, 2015 at 10:35:39 AM UTC-4, Steven Dirkse wrote:
Brett,
You could use the value NA for the missing arcs. However, that implies that you store values for all possible arcs, even missing ones. That is not sparse, and GAMS is designed to handle data in a sparse way. In this case, I suggest leaving the distance as zero for missing arcs: this implies that no arc exists. For example:
set i ‘supply’ / s1, s2 /,
j ‘demand’ / d1, d2 /;
parameter d(i,j) ‘distance’ /
s1.d1 6
s2.d1 eps
s2.d2 7
/;
equation cost;
cost… z =e= sum{(i,j)$d(i,j), d(i,j)*x(i,j)};
This avoids creating variable x(‘s1’,‘d2’) since that arc does not exist. Note that we use the value eps for an arc like ‘s2’ → ‘d1’ that exists but has a zero cost/distance. That is exactly what eps is for.
Of course, if you don’t have any arcs with zero cost/distance, then you can skip all this stuff about eps. But it might help you to know it.
-Steve
On Mon, Jun 29, 2015 at 10:13 AM, Brett Decker wrote:
I have a network of 7000 demand points and 200 supply nodes and I have generated a table of distances between about 2000 of them. Does anyone know of a function in GAMS that allows me to set a very high value for the missing arcs? Any assistance is much appreciated!
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
–
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.
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com