GAMS Leave One Out

Problems with syntax of GAMS
Post Reply
ayledith
User
User
Posts: 9
Joined: 4 years ago

GAMS Leave One Out

Post by ayledith »

I'm hoping to use Leave On Out Cross Validation (https://en.wikipedia.org/wiki/Cross-val ... validation) with GAMS. Is there a way to tell GAMS to ignore particular values in a table? Say I have some set k / k1*k76 / is there a way to write only include k /k1*k25 / and k /k27*k76 in this run?
User avatar
bussieck
Moderator
Moderator
Posts: 1042
Joined: 7 years ago

Re: GAMS Leave One Out

Post by bussieck »

GAMS is pretty powerful when it comes to set and set operations. You should study the chapters in the User's Guide, e.g. https://www.gams.com/latest/docs/UG_SetDefinition.html and https://www.gams.com/latest/docs/UG_DynamicSets.html. In your case make kk the full set from k1 to k76 and have a dynamic set k(kk) where you kick the k you loop over out and back in:

Code: Select all

set kk / k1*k76 /, k(kk);
* Fill k with all elements of kk
k(kk) = yes;
loop(kk,
* Take kk out of k
  k(kk) = no;
* Now do something with k, e.g. solve a model
* ...
* Put kk back into k
  k(kk) = yes;
)  
-Michael
Post Reply