### summation eliminating some elements

Posted:

**Sat Jul 20, 2019 9:23 am**i have a set i =1,2,3,4,5,6 and a variable x(i). how to ∑ x(i) eliminating 1 and 5?

Forum for questions on the use of GAMS

https://forum.gamsworld.org/

Page **1** of **1**

Posted: **Sat Jul 20, 2019 9:23 am**

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

Posted: **Sun Jul 21, 2019 3:37 pm**

Hi
Hope this helps

Renger

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;
```

Renger

Posted: **Sun Jul 21, 2019 4:17 pm**

THANK YOU SO MUCH