Page 1 of 1

problem writing a subset from excel to gams

Posted: Sun Sep 26, 2021 9:36 am
by parag_patil
I have a set : x containing x1,x2.

I take it from an excel sheet using following code:
$call GDXXRW o=x.gdx i=x_data.xlsx trace=3 set=x rng=x_set!a1 rdim=1

$GDXIN x.gdx
$LOAD x
$gdxin

Now I have another subset of x : y(x)

How to import it from excel ? And how should I write it in excel? I tried it similar to the parameter , but I am not able to get it from excel to gams. Can you please help me in this
?

Re: problem writing a subset from excel to gams

Posted: Mon Sep 27, 2021 10:38 am
by bussieck
Does y expand the set x? If not then you can just do:

Code: Select all

set x; set y(x);
$call GDXXRW o=x.gdx i=x_data.xlsx trace=3 set=x rng=x_set!a1 rdim=1 set=y rng=y_set!a1 rdim=1

$GDXIN x.gdx
$LOAD x y
$gdxin
If y extends the set x then this is more tricky:

Code: Select all

set x; set y(x);
$call GDXXRW o=x.gdx i=x_data.xlsx trace=3 set=x rng=x_set!a1 rdim=1 set=y rng=y_set!a1 rdim=1

$GDXIN x.gdx
$LOAD x
* The following merges set y from the GDX file into the set x
$LOADM x=y
$LOAD y
$gdxin
-Michael