## Closed form of a constraint

Problems with syntax of GAMS
mrv_ce
User Posts: 11
Joined: 8 months ago

### Closed form of a constraint

Hello everybody,

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

L(A(i),C(m)) +e =l= L(A(i),C(k))-r the constraint will work for every i and m not equal to k set. e is error decision variable. r is very small constant value to get rid of equality of L functions.

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. However I can not write the equation closed form for m not equal k case.(k is also same set with m) Up to now I write their open form but for more alternative set or class set member this code can not e written.

Thanks a lot.

cbhomia
User Posts: 8
Joined: 11 months ago

### Re: Closed form of a constraint

Hello,

Assuming that 'k is also same set with m' means have the same elements defined in the same order, (or they are declared aliases), you can use the dollar control option to define equations only when m is not equal to k as follows

eq1(i,m,k) \$(ord(m) <> ord(k)).. L(A(i),C(m)) +e =l= L(A(i),C(k))-r

i.e. you define eq1 over domains (i,m,k) only for cases where m<>k .

https://www.gams.com/latest/docs/UG_Con ... Definition

mrv_ce
User Posts: 11
Joined: 8 months ago

### Re: Closed form of a constraint

Thanks a lot. It become very useful for me.