Dropped Elements Using GDXIN

Hi all,

Quick, hopefully simple question regarding $GDXIN. I’m trying to write some code to load a pre-existing gdx file, modify it, and then save it. I noticed that when I use the GDXIN or GDXOUT commands in conjunction with the LOAD and UNLOAD commands, it seems to only keep the non-zero elements. For example, here is the transport problem with modified numbers:

Sets
i canning plants / seattle, san-diego /
j markets / new-york, chicago, topeka / ;

Parameters

a(i) capacity of plant i in cases
/ seattle 350
san-diego 0 /

b(j) demand at market j in cases
/ new-york 325
chicago 0
topeka 275 / ;

$GDXOUT “C:\Users\Brian\Documents\P*******\N**********\trnsprt_test.gdx”
$UNLOAD a
$UNLOAD b
$GDXOUT

If I then go File->Open->choose trnsprt_test.gdx, it displays the following:
a: seattle 350
b: new-york 325
topeka 275

Is this correct behavior for GAMS? What would I do if I wanted to modify it so that b(chicago)=15?

Thanks,
Brian


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/groups/opt_out.

Hi Brian



Have a look at the squeeze option in the documentation of gdxutils.


This is correct behavior. If you want to display the value, Gams doesn’t display those values.

(If you really want to display a zero value, you just add +EPS (stands for a very small number in Gams) to the parameter (e.g. b(j) = b(j) + EPS).



If you want to change a value, you just write b(“Chicago”) = 0;

Cheers



Renger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Brian
Sent: Donnerstag, 17. Oktober 2013 20:51
To: gamsworld@googlegroups.com
Subject: Dropped Elements Using GDXIN



Hi all,



Quick, hopefully simple question regarding $GDXIN. I’m trying to write some code to load a pre-existing gdx file, modify it, and then save it. I noticed that when I use the GDXIN or GDXOUT commands in conjunction with the LOAD and UNLOAD commands, it seems to only keep the non-zero elements. For example, here is the transport problem with modified numbers:



Sets

i canning plants / seattle, san-diego /

j markets / new-york, chicago, topeka / ;



Parameters



a(i) capacity of plant i in cases

/ seattle 350

san-diego 0 /



b(j) demand at market j in cases

/ new-york 325

chicago 0

topeka 275 / ;



$GDXOUT “C:\Users\Brian\Documents\P*******\N**********\trnsprt_test.gdx”

$UNLOAD a

$UNLOAD b

$GDXOUT



If I then go File->Open->choose trnsprt_test.gdx, it displays the following:

a: seattle 350

b: new-york 325

topeka 275



Is this correct behavior for GAMS? What would I do if I wanted to modify it so that b(chicago)=15?



Thanks,

Brian


\

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/groups/opt_out.


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/groups/opt_out.

Much appreciated. Thank you Renger!

On Thursday, October 17, 2013 11:51:06 AM UTC-7, Brian wrote:

Hi all,

Quick, hopefully simple question regarding $GDXIN. I’m trying to write some code to load a pre-existing gdx file, modify it, and then save it. I noticed that when I use the GDXIN or GDXOUT commands in conjunction with the LOAD and UNLOAD commands, it seems to only keep the non-zero elements. For example, here is the transport problem with modified numbers:

Sets
i canning plants / seattle, san-diego /
j markets / new-york, chicago, topeka / ;

Parameters

a(i) capacity of plant i in cases
/ seattle 350
san-diego 0 /

b(j) demand at market j in cases
/ new-york 325
chicago 0
topeka 275 / ;

$GDXOUT “C:\Users\Brian\Documents\P*******\N**********\trnsprt_test.gdx”
$UNLOAD a
$UNLOAD b
$GDXOUT

If I then go File->Open->choose trnsprt_test.gdx, it displays the following:
a: seattle 350
b: new-york 325
topeka 275

Is this correct behavior for GAMS? What would I do if I wanted to modify it so that b(chicago)=15?

Thanks,
Brian


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/groups/opt_out.

Resurrecting this thread: How do I turn off squeezing when using $GDXOUT ? Is it possible ? It’s clear how to do it using gdxxrw but not with $GDXOUT.

Best regards and thanks in advance!
Claudio

El viernes, 18 de octubre de 2013 15:33:56 UTC-3, Brian escribió:

Much appreciated. Thank you Renger!

On Thursday, October 17, 2013 11:51:06 AM UTC-7, Brian wrote:

Hi all,

Quick, hopefully simple question regarding $GDXIN. I’m trying to write some code to load a pre-existing gdx file, modify it, and then save it. I noticed that when I use the GDXIN or GDXOUT commands in conjunction with the LOAD and UNLOAD commands, it seems to only keep the non-zero elements. For example, here is the transport problem with modified numbers:

Sets
i canning plants / seattle, san-diego /
j markets / new-york, chicago, topeka / ;

Parameters

a(i) capacity of plant i in cases
/ seattle 350
san-diego 0 /

b(j) demand at market j in cases
/ new-york 325
chicago 0
topeka 275 / ;

$GDXOUT “C:\Users\Brian\Documents\P*******\N**********\trnsprt_test.gdx”
$UNLOAD a
$UNLOAD b
$GDXOUT

If I then go File->Open->choose trnsprt_test.gdx, it displays the following:
a: seattle 350
b: new-york 325
topeka 275

Is this correct behavior for GAMS? What would I do if I wanted to modify it so that b(chicago)=15?

Thanks,
Brian


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.