problem writing a subset from excel to gams

Problems with syntax of GAMS
Post Reply
parag_patil
User
User
Posts: 28
Joined: 6 months ago
Location: Ahmedabad
Contact:

problem writing a subset from excel to gams

Post by parag_patil » 3 weeks ago

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: 645
Joined: 5 years ago

Re: problem writing a subset from excel to gams

Post by bussieck » 2 weeks ago

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