Can anyone help me with this problem please. I want to add to i one by one and put the amount of x(i) equal to 1 in each step, so i wrote it as below but it’s not working
loop(i,
x(‘0’)=1;
t(‘0’)=1;
while(t>m,
ord(i)=ord(i)+1;
display i;
x(i)=1;
display x;
t(i)=t(i-1) +1;
);
);
And by the way m is a variable which is calculated before this, in an equation.
\
Hi Sepideh
Could you define your question in another way, as it is not clear to me what you are aiming at? (for example the first 4 or 5 values of all parameters that will be calculated in the loop)
Cheers
Renger
-----Original Message-----
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Sepideh Ghajari
Sent: Montag, 2. November 2015 07:58
To: gamsworld
Subject: How to write a while loop in GAMS
Can anyone help me with this problem please. I want to add to i one by one and put the amount of x(i) equal to 1 in each step, so i wrote it as below but it’s not working
loop(i,
x(‘0’)=1;
t(‘0’)=1;
while(t>m,
ord(i)=ord(i)+1;
display i;
x(i)=1;
display x;
t(i)=t(i-1) +1;
);
);
And by the way m is a variable which is calculated before this, in an equation.
\
I have a sum equation with a upper bound which is a variable (named M).
sum(i $ (ord(i) <= M), … I got the Error 52.
Then I wrote a number for the upper bound of the summation and multiplied a binary variable named x(i) to that equation. I want to add 1 to i in each step and check if the summation of x has reached M . I thought I should use a while.
I would be grateful if you could help me.
\
I still don’t get…
-----Original Message-----
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Sepideh Ghajari
Sent: Montag, 2. November 2015 17:02
To: gamsworld
Subject: RE: How to write a while loop in GAMS
I have a sum equation with a upper bound which is a variable (named M).
sum(i $ (ord(i) <= M), … I got the Error 52.
Then I wrote a number for the upper bound of the summation and multiplied a binary variable named x(i) to that equation. I want to add 1 to i in each step and check if the summation of x has reached M . I thought I should use a while.
I would be grateful if you could help me.
\