Hi All,
I have multiple sums as follow: \sum_{j=2}^J [ 1 - \sqrt(\sum_{l=1}^L \sum_{t=1}^T\ (sum_{k=2}^j x(k) - x(k-1))^2)].
I try to implement in GAMS as below:
sum(j $ (ord(j) gt 1), (1 - sqrt(sum((l,t), power(sum(k $ (ord(k) <= ord(j) and ord(k) >= 2), x(k) - x(k-1)),2)))).
Is this syntax correct? If not, what is the correct one?
The correct syntax for sum inside sum Topic is solved
Re: The correct syntax for sum inside sum
Hi
You only forget to close one parenthesis (something you could have find yourself). A good way to test your stuff is using small sets and a known parameter, so you can do the calculation by hand and check it this way.
Here an example:
CHeers
Renger
You only forget to close one parenthesis (something you could have find yourself). A good way to test your stuff is using small sets and a known parameter, so you can do the calculation by hand and check it this way.
Here an example:
Code: Select all
set j /1*3/, k /1*3/, l /1*3/, t /1*3/;
parameter x;
x(k) = k.val;
parameter test;
test = sum(j$(ord(j) gt 1), (1 - sqrt(sum((l,t), power(sum(k$(ord(k) <= ord(j) and ord(k) >= 2), x(k) - x(k-1)),2)))));
display test;
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Re: The correct syntax for sum inside sum
Thank you, Renger!