Hi,
I am importing two different tables into GAMS:
RotStandOut(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc,Ages,Items)
PixTable(Stands,Pixels,SiteIndexS,SiteIndexP,SiteIndexB,Rot_Perc,Items)
Both tables have common sets (SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc). I need to group those sets together creating sort of an "Index/key", so I can identity such index on table RotStandOut and bring its outcome/value to table PixTable.
What I want to do is kinda of concatenating such sets in both tables and then performing a vlookup.
Any ideas on how I can do that on GAMS?
Concatenate in GAMS Topic is solved
Re: Concatenate in GAMS
Rather than looking at spreadsheet logic (vlookup) relational algebra like SQL from databases will give you a better understanding of how GAMS looks at data:
-Michael
Code: Select all
* Declaration with artificial data
set SiteIndexS /s1*s10/,SiteIndexP /p1*p10/, SiteINdexB /b1*b10/,
Rot_Perc /r1*r10/, Ages /a1*a10/, Items /i1*i10/,
Stands /t1*t10/,Pixels /p1*p10/;
parameters
RotStandOut(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc,Ages,Items)
PixTable(Stands,Pixels,SiteIndexS,SiteIndexP,SiteIndexB,Rot_Perc,Items);
* Fill with sparsely with ranom data
RotStandOut(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc,Ages,Items)$(uniform(0,1)<0.005) = uniFormInt(1,10);
PixTable(Stands,Pixels,SiteIndexS,SiteIndexP,SiteIndexB,Rot_Perc,Items)$(uniform(0,1)<0.005) = uniFormInt(1,10);
* Declare indiviual index sets
set idx_RotStandOut(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc)
idx_PixTable(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc);
* Project relevant indexes out of the parameters
option idx_RotStandOut<idx_RotStandOut,
idx_PixTable<PixTable;
set idx(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc);
* Build the union of the two index spaces
idx(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc) =
idx_RotStandOut(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc)
or idx_PixTable(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc);
* Use the new sparse index in some calculation
Parameter maxAges(SiteIndexS,SiteIndexP,SiteINdexB,Rot_Perc,Items);
maxAges(idx,Items) = smax(Ages, RotStandOut(idx,Ages,Items))
Re: Concatenate in GAMS
Hi Michael,
Thank you for the didactic explanation. I learned new concepts that I had never heard before.
I tried it on my model and it works perfectly.
Cheers,
Ana
Thank you for the didactic explanation. I learned new concepts that I had never heard before.
I tried it on my model and it works perfectly.
Cheers,
Ana