Hi All,

Sets

i Index /1*20/*

j Index /120/

R Index /1*20/;

I want to write the code to run for all items in the set except the first item.

For example Sum(i$(i gt 1),W(i)); and it was accepted.

But when I wrote Y(R,I$(i gt 1),J)=L= 2*X(R,I$(i gt 1),J);

It cannot accept . Y is free and x is binary.

How can we solve it?

Thanks

Hi,

You first example with the sum is also syntactically incorrect. But if you change ‘i gt 1’ to ‘i.val gt 1’ this will work

```
Sets
i Index /1*20/
j Index /1*20/
R Index /1*20/;
parameter w(i), wsum;
w(i) = uniform(0,1);
wsum = Sum(i$(i.val gt 1),W(i));
```

Your other syntax is very different. You don’t control a “running index” with some $() command but what to do that in the variable itself. This you have R, I and J controlled by the equation (your example is unfortunately not complete, you need to control I there:

```
Sets
i Index /1*20/
j Index /1*20/
R Index /1*20/;
variable Y(R,I,J), X(R,I,J);
equation e(R,I,J); e(R,I,J)$(i.val gt 1).. Y(R,I,J)=L= 2*X(R,I,J);
```

-Michael