Hi all,

Can anyone please kindly help below. I need to do double summation but index l should not equal to k. Below is what I write but seems wrong. Do you have any suggestions? Thanks!

**sum** {k **in** K,l **in** K **diff** {k}} y[k,l]

Best,

Ruonan

Hi all,

Can anyone please kindly help below. I need to do double summation but index l should not equal to k. Below is what I write but seems wrong. Do you have any suggestions? Thanks!

**sum** {k **in** K,l **in** K **diff** {k}} y[k,l]

Best,

Ruonan

I did a little test where I set K equal to {1,2,3,4,5} and assigned some random numbers to y. Your sum was evaluated without any errors:

```
ampl: set K := 1..5;
ampl: var y {K,K} := Uniform01();
ampl: display sum {k in K, l in K diff {k}} y[k,l];
sum{k in K, l in K diff {k}} y[k,l] = 9.30924
```

However, some other error in your model might be causing an error when you use this expression. To get more help, upload a complete example that we can run to reproduce the error message.

I did a little test where I set K equal to {1,2,3,4,5} and assigned some random numbers to y. Your sum was evaluated without any errors:

```
ampl: set K := 1..5;
ampl: var y {K,K} := Uniform01();
ampl: display sum {k in K, l in K diff {k}} y[k,l];
sum{k in K, l in K diff {k}} y[k,l] = 9.30924
```

However, some other error in your model might be causing an error when you use this expression. To get more help, reply with a complete example that we can run to reproduce the error message.