Hi Guys,

I am trying to develop a model with one of the decision variable being the following:

W(i,j): store i is the closest alternative store for region j;

i assume that each customer region has a local store and want to study the customer shopping behavior when their local store is closed - e.g. will they travel to the nearest store in another region?

This variable is only meaningful for the model when i is not equal to j. So how should I reflect that in GAMS? Should I put down W(i,j) $(ord(i) ne ord(j)) every single time I use the variable w(i,j) or is there another way to define this once and for all?

Thank you very much indeed for the help.

## variable ensuring two index are different

### Re: variable ensuring two index are different

Dynamic subsets are the solution. Make a set ij(i,j) and put the possible combination in there. Then whenever you need to restrict the ij combination (e.g. in equation algebra) use ij(i,j) (e.g. sum(ij(i,j), W(i,j))). You need to exclude the region local store from ij but you also might remove the stores that are too far away (use some heuristic) to limit the number of variables:

-Michael

Code: Select all

```
ij(i,j) = yes;
ij(i,j)$(ord(i)=ord(j)) = no;
ij(i,j)$(dist(i,j)>1000) = no;
```

### Re: variable ensuring two index are different

Hi Michael,

You are absolutely a star! I actually need the maximum travel distance for the model as well and your answers are really helpful. Thank you a million and hope you have a wonderful week.

Best regards,

Lina

You are absolutely a star! I actually need the maximum travel distance for the model as well and your answers are really helpful. Thank you a million and hope you have a wonderful week.

Best regards,

Lina