Jacques,
At GAMS compile time you can add to sets by using the gdx functionality as Renger explained or some direct syntax:
set S /a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z/
set s2 / #s, element, element2/
set s3 / set.s, element, element2 /;
#setname and set.setname are equivalent.
You can’t remove individual elements at compile time from a set, but you can clear it (as long as you have not used it as a domain set):
set s /1,2,3/;
$clear s
At run time you have much more flexibility on set membership:
$eolcom //
set a /a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z/
n /0,1,2,3,4,5,6,7,8,9/;
set s;
s(a) = yes; // adds kall a-z to s
s(‘z’) = no; // removes z from s
s(n) = ord(n)<5; // adds 0,1,2,3 to s
s(‘9’) = yes; // adds ‘9’ to s
s(a) = no; // removes a-z from s
s(n) = no; // removed 0-9 from s
Sets that are dynamic at run-time can’t be used as domains. Domain checking is one of the really great things to catch errors in your programming at compile time.
Hope this helps,
Michael Bussieck - GAMSWorld Coordinator
On Tuesday, April 8, 2014 7:11:28 PM UTC+2, Jacques wrote:
Thank you !
It solved it.
On the same subject, is there a way to take out one element of a pre-existing list ?
thanx
Le mardi 8 avril 2014 18:05:39 UTC+2, Renger van Nieuwkoop a écrit :
Hi Jacques
The gdx utility has a new feature that allows you to merge two sets (search for LOADM in the documentations) while reading them from a gdx .
Cheers
Renger
Modelworks
Gewerbestrasse 15
3600 Thun – Switzerland
+41 79 818 53 73
In…@modelworks.ch
blog.modelworks.ch
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Jacques
Sent: Dienstag, 8. April 2014 17:57
To: gams...@googlegroups.com
Subject: defining "meta-"sets ?
Hello,
I would like to declare a set S2 that contains :
-
all the elements of the pre-existing set S /a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z/
-
and one or two elements more /element,element2/
… without repeating the entire set S (which I am importing from a gdx file…).
I have read about subsets, and I know I could declare S as: S(S2)
but what I want to do is the opposite.
I tried : set S2 /S,element/
but I takes “S” as an element of the set, and not as the previously defined set…
Thank you for your help !
Jacques.
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.