summation eliminating some elements Topic is solved

Problems with syntax of GAMS
Post Reply
rejinsr037
User
User
Posts: 8
Joined: 1 month ago

summation eliminating some elements

Post by rejinsr037 » 1 month 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: 353
Joined: 2 years ago

Re: summation eliminating some elements

Post by Renger » 4 weeks 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: The lazy economist

rejinsr037
User
User
Posts: 8
Joined: 1 month ago

Re: summation eliminating some elements

Post by rejinsr037 » 4 weeks ago

THANK YOU SO MUCH

Post Reply