summation eliminating some elements Topic is solved

Problems with syntax of GAMS
Post Reply
rejinsr037
User
User
Posts: 8
Joined: 2 months ago

summation eliminating some elements

Post by rejinsr037 » 2 months ago

i have a set i =1,2,3,4,5,6 and a variable x(i). how to ∑ x(i) eliminating 1 and 5?

User avatar
Renger
Posts: 395
Joined: 3 years ago

Re: summation eliminating some elements

Post by Renger » 2 months ago

Hi

Code: Select all

set i /1,2,3,4,5,6/ ;

parameter x(i), mysum;
* assign some values
x(i) =ord(i);
mysum = sum(i$(i.val ne 1 and i.val ne 5), x(i));

display mysum;
Hope this helps
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

rejinsr037
User
User
Posts: 8
Joined: 2 months ago

Re: summation eliminating some elements

Post by rejinsr037 » 2 months ago

THANK YOU SO MUCH

Post Reply