Hi Renger
Thank you so much. It works now.
On Friday, August 16, 2013 5:21:26 AM UTC-7, Renger van Nieuwkoop wrote:
Hi Sarah
There is probably no need for a dynamic set i, but if you really want it just uncomment the commented lines,
Take a good look at ord and card in the manual and look for other examples using ord and card.
set j /1*100/;
x = 300;
kk = 10;
*i(j)$(ord(j) eq 1) = YES;
*i(j)(ord(j) le kk) = YES;
\
\
\
parameter y(j),dev;
\
\
\
dev=x/(kk-2);
\
\
\
y(j)(ord(j) eq 1) = 0;
y(j)$(ord(j) eq kk) = x;
y(j)$(ord(j) lt kk) = (2*ord(j)-3)*dev/2;
display y;
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 sarah....@gmail.com
Sent: Freitag, 16. August 2013 13:34
To: gams...@googlegroups.com
Subject: having a set in which the number of elements is not known at first.
I am new with GAMS. I want to use GAMS for solving the following problem: (in which the number of elements in set i is defined later in the program (the number of elements in set i is calculated based on another input data which will be clarified in the program later (kk)).
set i/ /
parameter y(i);
parameter x;
parameter kk;
x=300;
kk=10;
dev=x/(kk-2);
y(‘1’)=0;
y(‘kk’)=x;
for (i=1 to (kk-1),
y(i)=(2i-3)*dev/2;
);
Actually by this code, I want to discretize the value x in to 10 values and putting those 10 values in an indexed vector (y(i)).
I will really appreciate if anyone can help me.
Thanks in advance.
–
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/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.