I want to write a summation equation that represents the following:
x1 <= y1
x1 + x2 <= y1+y2
x1 + x2 + x3 <= y1 +y2 + y3
x1 + x2 + x3 + x4 <= y1 + y2 + y3 + y4
x1 + x2 + x3 + x4 + x5 <= y1 + y2 + y3 + y4 + y5
x1 + x2 + x3 + x4 + x5 + x6 <= y1 + y2 +y3 +y4 + y5 + y6
GAMS code:
Set i /1*6/;
Variables
x(i)
y(i)
;
Please help me in writing this cumulative equation in GAMS
hi, you should define an alias. Try this code
bye!
Set i /1*6/;
alias(i,j)
Variables
x(i)
y(i)
;
equation
eq
;
eq(i).. sum(j$(ord(j) le ord(i)),x(j)) =l= sum(j$(ord(j) le ord(i)),y(j));
It worked, Thanks a lot for your response.
I have another question related to this topic:
I want to write an equation that represents the following:
z= (x1 - y1)
- ( (x1+x2) - (y1+y2) )
- ( (x1+x2+x3) - (y1+y2+y3) )
- ( (x1+x2+x3+x4) - (y1+y2+y3+y4) )
- ( (x1+x2+x3+x4+x5) - (y1+y2+y3+y4+y5) )
- ( (x1+x2+x3+x4+x5+x6) - (y1+y2+y3+y4+y5+y6) )
I think this can work…
eq.. z =e= sum((i,j)$(ord(j) le ord(i)),x(j) - y(j));
bye!