Unique key use for a closed form constraint

Problems with syntax of GAMS
Post Reply
Posts: 2
Joined: 1 month ago

Unique key use for a closed form constraint

Post by mrv_ce » 1 week ago

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.

User avatar
Posts: 187
Joined: 2 years ago

Re: Unique key use for a closed form constraint

Post by Renger » 1 week ago

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/;

set mapI_M(i,m)  Allowed combinations of i and m
/ i1.m2, i2.m4, i3.m1/;

    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 ;
I hope this answers your question

Post Reply