problem writing a subset from excel to gams

Problems with syntax of GAMS
Post Reply
parag_patil
User
User
Posts: 30
Joined: 2 years ago
Location: Ahmedabad
Contact:

problem writing a subset from excel to gams

Post 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
?
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: problem writing a subset from excel to gams

Post 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
Post Reply