Thanks Renger, it works!
On Wed, Dec 18, 2013 at 11:17 AM, Renger van Nieuwkoop wrote:
Hi Frederico
You can use fr_fea.val if the set elements are in fact numbers.
Cheers
Renger
\
Modelworks
Gewerbestrasse 15
3600 Thun – Switzerland
+41 79 818 53 73
Info@modelworks.ch
blog.modelworks.ch
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Federico Perea
Sent: Mittwoch, 18. Dezember 2013 11:07
To: gamsworld@googlegroups.com
Subject: Re: loop over a set
Thanks Nazmi. I tried this, but then it makes k=1 and k=2 (the first and second element of the set) and I want k=2 and k=3 (the values I gave to the elements). I tried to do something like
n(‘2’) = 2; n(‘3’) = 3, and then make k=n(fr_fea). But I don’t think it is very elegant. This would be my code (see the different displays in the different loops):
Set fr_fea /2,3/;
Parameter n(fr_fea);
n(‘2’) = 2;
n(‘3’) = 3;
scalar k;
loop(fr_fea,
k = ord(fr_fea);
display k;
);
loop(fr_fea,
k = n(fr_fea);
display k;
);
Regards
On Wed, Dec 18, 2013 at 10:56 AM, Nazmi Åžener wrote:
Hi Fede,
You must not equal a set to a parameter or scalar. Use ordinality of set for example ord(fr_fea)
Have a nice day,
Nazmi
Kimden: Federico Perea
Gönderme tarihi: 18 Aralık 2013 Çarşamba 11:48
Kime: gamsworld@googlegroups.com
Hello everyone,
i want to loop over a set and get the value of the set elements, something like this:
Set fr_fea /2,3/;
scalar k;
loop(fr_fea,
k = fr_fea;
);
But something seems to go wrong. Anyone could help me out?
Thanks in advance,
Fede
–
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/groups/opt_out.
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/groups/opt_out.
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/groups/opt_out.