Cumulated sum
Posted: Sat May 06, 2017 10:38 am
Hi guys,
I am pretty new to GAMS - don't think this is gonna be hard for someone with experience.
I'd like to create a cumulated sum.
Please find the equation I'd like to implemet in the attached file.
I therefore defined a set t with several periods and a set m with several product variant types.
x(m,t) is a binary variable assigning t to m.
Now for every t I need the cumulated amount of x(m,t) in the respective period y(m,t).
Hence, I declared the sum to start with t'=1 an sum up to the currently considered t.
I'm pretty sure I somehow have to work with an alias and a $-(ord)condition here.
This is what I got so far, but something is missing:
Sets m / 1, 2, 3 /
t / 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 /;
alias (t,tt);
y(m,t) =e= Sum((t$(ord(t) =l= ord(tt)), x(m,t));
I'd apperciate your help!
Thanks
Marc
I am pretty new to GAMS - don't think this is gonna be hard for someone with experience.
I'd like to create a cumulated sum.
Please find the equation I'd like to implemet in the attached file.
I therefore defined a set t with several periods and a set m with several product variant types.
x(m,t) is a binary variable assigning t to m.
Now for every t I need the cumulated amount of x(m,t) in the respective period y(m,t).
Hence, I declared the sum to start with t'=1 an sum up to the currently considered t.
I'm pretty sure I somehow have to work with an alias and a $-(ord)condition here.
This is what I got so far, but something is missing:
Sets m / 1, 2, 3 /
t / 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 /;
alias (t,tt);
y(m,t) =e= Sum((t$(ord(t) =l= ord(tt)), x(m,t));
I'd apperciate your help!
Thanks
Marc