Hello everybody,

I'm conducting a research and I need to write a constraint for my model in GAMS. Can you help me?

L(A(i),C(m)) +e =l= L(A(i),C(k))-r

In this constraint L is distance function it calculates the distance between A(i) and C(m). i is alternative set. m is class set. The constraint compares their distance values. The constraint will work for every i and m not equal to k set. (m and k is the same set) However for each i, I have a defined m value. So LHS of the constaint for each i is defined. I need to write RHS of the equation m not equal to k. (for any i, m is specified and k can not be equal to the m)

This is the point that I cannot write. I thought new defined parameter for unique i and m combination can be used but I can ot add it to the existing equation. Up to now I write their open form but for each data set I need to write the model again.

Please help me.

Thanks a lot.

Note: e is error decision variable. r is very small constant value to get rid of equality of L functions.

## Unique key use for a closed form constraint

### Re: Unique key use for a closed form constraint

Hi

If I understand your question correctly, this could be solved by a mapping between i and m for every combination that is valid, e.g.

I hope this answers your question

Cheers

Renger

If I understand your question correctly, this could be solved by a mapping between i and m for every combination that is valid, e.g.

Code: Select all

```
set i /i1, i2, i3/, set m /m1, m2, m3, m4/;
alias(m,k);
set mapI_M(i,m) Allowed combinations of i and m
/ i1.m2, i2.m4, i3.m1/;
equations
myconstraint(i, m,k);
mycontrainst(i,m,k)$(map(i,m) and not sameas(m,k))..
L(A(i),C(m)) +e =l= L(A(i),C(k))-r ;
```

Cheers

Renger