Controlling the Domain of a Variable with a different Set

Hello Gamsworld,

I’m in a bit of a pickle and need your Help. I have set up a queuing
problem to solve an Emergency response scenario. I have been able to
handle the majority of special cases using subsets, but there is one
thing that I have not been able to solve. The model was initially a
MINLP problem, but transforming the model we were able to formulate a
mathematically sound LP. The problem now is to implement it in GAMS.

The Mathematical equation which I would like to model is the
following:

Y(i,q,k) + Y(q,j,k) - 1 <= Y(i,j,k)

This equation accounts for the transitivity of predecessor
relationships, and is essential for my model to function properly.
What I need, is to adress a variable (in this case Y, normally defined
over i, j and k) but on two occasions this variable should be
controlled by another index.

Here are a few of my ideas:

*Transitivity(si,j,k,l)… Y(si,%l,k) + Y(%l,j,k) - 1 =l= Y(si,j,k) ;
(Last resort attempt, compiling error)

*Transitivity(si,li,j,lj,k)(ORD(lj) eq ORD(li)).. Y(si,lj,k) + Y(li,j,k)(ORD(li) eq ORD(lj)) - 1 =l= Y(si,j,k) ;
(No Joy, since lj was a dynamic subset of j, ORD(lj) is infeasible,
compiling error)

*Transitivity(ssi,ssj,k,l)… Y(ssi,ssj,k)(ORD(ssj) eq ORD(l)) + Y(ssi,ssj,k)(ORD(ssi) eq ORD(l)) - 1 =l= Y(ssi,ssj,k) ;
(Worked, but it did not do what it was supposed to do,- obviously not
the right idea to this problem :slight_smile:)

Here’s a bit of Code for your understanding, (I can send my current
full code on request):


Set ssi incident superset i from 0 to n+1 /
i0*i6 / ;

Set ssj incident superset j from 0 to n+1 /
j0*j6 / ;

Set k rescue unit k from 1 to m /
k1*k3 / ;

Set l incident transitivity subset /
l0*l6 / ;

Set si(ssi) incident subset i from 0 to n ;
si(ssi) = YES$((ORD(ssi) ge 1) AND (ORD(ssi) le (CARD(ssi)-1)));

Set i(ssi) incident subset i from 1 to n ;
i(ssi) = YES$((ORD(ssi) ge 2) AND (ORD(ssi) le (CARD(ssi)-1)));

Set ii(ssi) incident subset i from 1 to n+1 ;
ii(ssi) = YES$((ORD(ssi) ge 2) AND (ORD(ssi) le CARD(ssi)));

Set ifirst(ssi) incident subset i controlling the first
pseudo incident i ;
ifirst(ssi) = YES$(ORD(ssi) eq 1);

Set ilast(ssi) incident subset i controlling the last pseudo
incident i ;
ilast(ssi) = YES$(ORD(ssi) eq CARD(ssi));

Set sj(ssj) incident subset j from 0 to n ;
sj(ssj) = YES$((ORD(ssj) ge 1) AND (ORD(ssj) le (CARD(ssj)-1)));

Set j(ssj) incident subset j from 1 to n ;
j(ssj) = YES$((ORD(ssj) ge 2) AND (ORD(ssj) le (CARD(ssj)-1)));

Set jj(ssj) incident subset j from 1 to n+1 ;
jj(ssj) = YES$((ORD(ssj) ge 2) AND (ORD(ssj) le CARD(ssj)));

Set jfirst(ssj) incident subset j controlling the first
pseudo incident j ;
jfirst(ssj) = YES$(ORD(ssj) eq 1);

Set jlast(ssj) incident subset j controlling the last pseudo
incident j ;
jlast(ssj) = YES$(ORD(ssj) eq CARD(ssj));

Binary Variables
X(ssi,ssj,k) Decision if incident i is processed
immediately before incident j by rescue unit k
Y(ssi,ssj,k) Decision if incident i is processed before
incident j by rescue unit k ;

Equation Preincident(ssj) (C1) Each incident has a
predecessor ;
Preincident(j)… sum((si,k), X(si,j,k)) =e= 1 ;

Equation Postincident(ssi) (C2) Each incident has a successor
incident ;
Postincident(i)… sum((jj,k), X(i,jj,k)) =e= 1 ;

Equation Transitivity(ssi,ssj,k,l) (C5) Transitivity of predecessor
incidents ;
*Transitivity(si,j,k,l)… Y(si,%l,k) + Y(%l,j,k) - 1 =l= Y(si,j,k) ;
*Transitivity(si,li,j,lj,k)(ORD(lj) eq ORD(li)).. Y(si,lj,k) + Y(li,j,k)(ORD(li) eq ORD(lj)) - 1 =l= Y(si,j,k) ;
*Transitivity(ssi,ssj,k,l)… Y(ssi,ssj,k)(ORD(ssj) eq ORD(l)) + Y(ssi,ssj,k)(ORD(ssi) eq ORD(l)) - 1 =l= Y(ssi,ssj,k) ;

Equation Immediate(ssi,ssj,k) (C6) An immediate predecessor is a
specific predecessor ;
Immediate(si,jj,k)… X(si,jj,k) =l= Y(si,jj,k) ;


Any help would be greatly appreciated.

\

Dear Arne,

thank you for your input. In terms of sets, i, j and l need to be
different in the sense that they need to be controlled independently.
In other words, in the equation:
Y(i,l,k) + Y(l,j,k) - 1 From what I understand, using the alias results in GAMS controlling
the parent set, and changing the alias along with it. I’ll give it a
try with the alias, but perhaps you have another idea.

Regards
Chris

On 20 Jan., 12:42, “Arne Stolbjerg Drud” wrote:

Bodenstein:

Do your sets i, j, and l really represent different things? You element
naming with /i0i6/, /j0j6/, and /k0*k6/ indicates that they are different
but I expect that they are not – they just represent elements in a
sequence.

If I am right you can just have

set i / i0i6 / (or mayby just /06/ )
alias (i,j,l);

If l need to be a subset you could have
alias(i,j);
set l(i) /i0*i6/M

and you can use i, j, and l in the same positions in Y as long as your
declaration has Y(i,i,k).

Your equation would be something like
Transitivity(i,j,k,l)… Y(i,l,k) + Y(l,j,k) - 1 =l= Y(i,j,k) ;

Hope it helps

Arne


Arne Stolbjerg Drud
ARKI Consulting & Development A/S
Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark
Phone:(+45) 44 49 03 23begin_of_the_skype_highlighting (+45) 44 49 03 23 end_of_the_skype_highlighting, Fax: (+45) 44 49 03 33, email: ad…@arki.dk

-----Oprindelig meddelelse-----
Fra: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] PÃ¥ vegne
af Bodenstein
Sendt: 20. januar 2011 11:58
Til: gamsworld
Emne: Controlling the Domain of a Variable with a different Set

Hello Gamsworld,

I’m in a bit of a pickle and need your Help. I have set up a queuing
problem to solve an Emergency response scenario. I have been able to
handle the majority of special cases using subsets, but there is one
thing that I have not been able to solve. The model was initially a
MINLP problem, but transforming the model we were able to formulate a
mathematically sound LP. The problem now is to implement it in GAMS.

The Mathematical equation which I would like to model is the
following:

Y(i,q,k) + Y(q,j,k) - 1 >
This equation accounts for the transitivity of predecessor
relationships, and is essential for my model to function properly.
What I need, is to adress a variable (in this case Y, normally defined
over i, j and k) but on two occasions this variable should be
controlled by another index.

Here are a few of my ideas:

*Transitivity(si,j,k,l)… Y(si,%l,k) + Y(%l,j,k) - 1 =l= Y(si,j,k) ;
(Last resort attempt, compiling error)

*Transitivity(si,li,j,lj,k)(ORD(lj) eq ORD(li)).. Y(si,lj,k) + Y(li,j,k)(ORD(li) eq ORD(lj)) - 1 =l= Y(si,j,k) ;
(No Joy, since lj was a dynamic subset of j, ORD(lj) is infeasible,
compiling error)

*Transitivity(ssi,ssj,k,l)… Y(ssi,ssj,k)(ORD(ssj) eq ORD(l)) + Y(ssi,ssj,k)(ORD(ssi) eq ORD(l)) - 1 =l= Y(ssi,ssj,k) ;
(Worked, but it did not do what it was supposed to do,- obviously not
the right idea to this problem :slight_smile:)

Here’s a bit of Code for your understanding, (I can send my current
full code on request):


Set ssi incident superset i from 0 to n+1 /
i0*i6 / ;

Set ssj incident superset j from 0 to n+1 /
j0*j6 / ;

Set k rescue unit k from 1 to m /
k1*k3 / ;

Set l incident transitivity subset /
l0*l6 / ;

Set si(ssi) incident subset i from 0 to n ;
si(ssi) = YES$((ORD(ssi) ge 1) AND (ORD(ssi) le (CARD(ssi)-1)));

Set i(ssi) incident subset i from 1 to n ;
i(ssi) = YES$((ORD(ssi) ge 2) AND (ORD(ssi) le (CARD(ssi)-1)));

Set ii(ssi) incident subset i from 1 to n+1 ;
ii(ssi) = YES$((ORD(ssi) ge 2) AND (ORD(ssi) le CARD(ssi)));

Set ifirst(ssi) incident subset i controlling the first
pseudo incident i ;
ifirst(ssi) = YES$(ORD(ssi) eq 1);

Set ilast(ssi) incident subset i controlling the last pseudo
incident i ;
ilast(ssi) = YES$(ORD(ssi) eq CARD(ssi));

Set sj(ssj) incident subset j from 0 to n ;
sj(ssj) = YES$((ORD(ssj) ge 1) AND (ORD(ssj) le (CARD(ssj)-1)));

Set j(ssj) incident subset j from 1 to n ;
j(ssj) = YES$((ORD(ssj) ge 2) AND (ORD(ssj) le (CARD(ssj)-1)));

Set jj(ssj) incident subset j from 1 to n+1 ;
jj(ssj) = YES$((ORD(ssj) ge 2) AND (ORD(ssj) le CARD(ssj)));

Set jfirst(ssj) incident subset j controlling the first
pseudo incident j ;
jfirst(ssj) = YES$(ORD(ssj) eq 1);

Set jlast(ssj) incident subset j controlling the last pseudo
incident j ;
jlast(ssj) = YES$(ORD(ssj) eq CARD(ssj));

Binary Variables
X(ssi,ssj,k) Decision if incident i is processed
immediately before incident j by rescue unit k
Y(ssi,ssj,k) Decision if incident i is processed before
incident j by rescue unit k ;

Equation Preincident(ssj) (C1) Each incident has a
predecessor ;
Preincident(j)… sum((si,k), X(si,j,k)) =e= 1 ;

Equation Postincident(ssi) (C2) Each incident has a successor
incident ;
Postincident(i)… sum((jj,k), X(i,jj,k)) =e= 1 ;

Equation Transitivity(ssi,ssj,k,l) (C5) Transitivity of predecessor
incidents ;
*Transitivity(si,j,k,l)… Y(si,%l,k) + Y(%l,j,k) - 1 =l= Y(si,j,k) ;
*Transitivity(si,li,j,lj,k)(ORD(lj) eq ORD(li)).. Y(si,lj,k) + Y(li,j,k)(ORD(li) eq ORD(lj)) - 1 =l= Y(si,j,k) ;
*Transitivity(ssi,ssj,k,l)… Y(ssi,ssj,k)(ORD(ssj) eq ORD(l)) + Y(ssi,ssj,k)(ORD(ssi) eq ORD(l)) - 1 =l= Y(ssi,ssj,k) ;

Equation Immediate(ssi,ssj,k) (C6) An immediate predecessor is a
specific predecessor ;
Immediate(si,jj,k)… X(si,jj,k) =l= Y(si,jj,k) ;


Any help would be greatly appreciated.


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/gamsworld?hl=en.

\

Dear Arne,

I tried it with the Alias, and I reconfigured how I defined my sets.
It is as you say, there is one set of incidents, so it makes sense to
refer to the positions as alias. I’ve redefined l as a subset of
incidents and it worked well.

It’s always interesting how sometimes we are so fixed with the idea,
we loose track of such simple solutions :slight_smile: In my case the force of
defining a set over two different ones, when it is simpler to define
the two sets as one, and then define the set over that one :slight_smile:

Thanks for your help.

FYI, that particular equation now functions as it should, but as with
all problems, they are merely the front of the queue. Only this time,
it’s the Math guys fault, and not the GAMS coding :slight_smile:

Regards
Chris

On 20 Jan., 16:28, “Arne Stolbjerg Drud” wrote:

Dear Chris

I think you should look at alias again. It is used to refer to independently
controlled instances of the same set.

If you have

set i /i0*i2/
alias (i,j);

then the declaration

variable y(i,j); equation e(i,j);

is equivalent to

variable y(i,i); equation e(i,i);

However when you use the variables and equation then

y(i,i) refers to the diagonal, i.e. y(‘i0’,‘i0’), y(‘i1’,i1’), y(‘i2’,‘i2’)
while
y(i,j) refers to all elements of y.

The equation

Transitivity(i,j,k,l)… Y(i,l,k) + Y(l,j,k) - 1 =l= Y(i,j,k) ;

reads: for all combinations of i, j, k, and l, Y(i,l,k)+Y(l,j,k) =L=
1+Y(i,j,k);

which translates into: For all combinations of i, j, and k, if Y(i,j,k) is
zero then no more than one of Y(i,l,k) and Y(l,j,k) can be one for each
value of l and if Y(i,j,k) is one then the constraint is not binding (since
Y is binary).

Regards

Arne


Arne Stolbjerg Drud
ARKI Consulting & Development A/S
Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark
Phone:(+45) 44 49 03 23begin_of_the_skype_highlighting (+45) 44 49 03 23 end_of_the_skype_highlighting, Fax: (+45) 44 49 03 33, email: ad…@arki.dk

-----Oprindelig meddelelse-----
Fra: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] PÃ¥ vegne
af Bodenstein
Sendt: 20. januar 2011 14:18
Til: gamsworld
Emne: Re: Controlling the Domain of a Variable with a different Set

Dear Arne,

thank you for your input. In terms of sets, i, j and l need to be
different in the sense that they need to be controlled independently.
In other words, in the equation:
Y(i,l,k) + Y(l,j,k) - 1 > it may not be the case that l is controlled by i or j, it needs to
remain independent, however the position should be defined, else the
transitivity constraint does not hold. In logical terms,

if Y(1,1,1) at most one of the other Y(1,,k) or Y(,1,k) may be 1.
(Star is the value from 1 to 5 for this example)

This is basically what we model with the equation.

From what I understand, using the alias results in GAMS controlling
the parent set, and changing the alias along with it. I’ll give it a
try with the alias, but perhaps you have another idea.

Regards
Chris

On 20 Jan., 12:42, “Arne Stolbjerg Drud” wrote:

Bodenstein:

Do your sets i, j, and l really represent different things? You element
naming with /i0i6/, /j0j6/, and /k0*k6/ indicates that they are
different
but I expect that they are not – they just represent elements in a
sequence.

If I am right you can just have

set i / i0i6 / (or mayby just /06/ )
alias (i,j,l);

If l need to be a subset you could have
alias(i,j);
set l(i) /i0*i6/M

and you can use i, j, and l in the same positions in Y as long as your
declaration has Y(i,i,k).

Your equation would be something like
Transitivity(i,j,k,l)… Y(i,l,k) + Y(l,j,k) - 1 =l= Y(i,j,k) ;

Hope it helps

Arne


Arne Stolbjerg Drud
ARKI Consulting & Development A/S
Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark
Phone:(+45) 44 49 03 23begin_of_the_skype_highlighting (+45)

44 49 03 23 end_of_the_skype_highlighting, Fax: (+45) 44 49 03 33,
email: ad…@arki.dk

-----Oprindelig meddelelse-----
Fra: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] PÃ¥
vegne
af Bodenstein
Sendt: 20. januar 2011 11:58
Til: gamsworld
Emne: Controlling the Domain of a Variable with a different Set

Hello Gamsworld,

I’m in a bit of a pickle and need your Help. I have set up a queuing
problem to solve an Emergency response scenario. I have been able to
handle the majority of special cases using subsets, but there is one
thing that I have not been able to solve. The model was initially a
MINLP problem, but transforming the model we were able to formulate a
mathematically sound LP. The problem now is to implement it in GAMS.

The Mathematical equation which I would like to model is the
following:

Y(i,q,k) + Y(q,j,k) - 1 >
This equation accounts for the transitivity of predecessor
relationships, and is essential for my model to function properly.
What I need, is to adress a variable (in this case Y, normally defined
over i, j and k) but on two occasions this variable should be
controlled by another index.

Here are a few of my ideas:

*Transitivity(si,j,k,l)… Y(si,%l,k) + Y(%l,j,k) - 1 =l= Y(si,j,k) ;
(Last resort attempt, compiling error)

*Transitivity(si,li,j,lj,k)(ORD(lj) eq ORD(li)).. Y(si,lj,k) + Y(li,j,k)(ORD(li) eq ORD(lj)) - 1 =l= Y(si,j,k) ;
(No Joy, since lj was a dynamic subset of j, ORD(lj) is infeasible,
compiling error)

*Transitivity(ssi,ssj,k,l)… Y(ssi,ssj,k)(ORD(ssj) eq ORD(l)) + Y(ssi,ssj,k)(ORD(ssi) eq ORD(l)) - 1 =l= Y(ssi,ssj,k) ;
(Worked, but it did not do what it was supposed to do,- obviously not
the right idea to this problem :slight_smile:)

Here’s a bit of Code for your understanding, (I can send my current
full code on request):


Set ssi incident superset i from 0 to n+1 /
i0*i6 / ;

Set ssj incident superset j from 0 to n+1 /
j0*j6 / ;

Set k rescue unit k from 1 to m /
k1*k3 / ;

Set l incident transitivity subset /
l0*l6 / ;

Set si(ssi) incident subset i from 0 to n ;
si(ssi) = YES$((ORD(ssi) ge 1) AND (ORD(ssi) le (CARD(ssi)-1)));

Set i(ssi) incident subset i from 1 to n ;
i(ssi) = YES$((ORD(ssi) ge 2) AND (ORD(ssi) le (CARD(ssi)-1)));

Set ii(ssi) incident subset i from 1 to n+1 ;
ii(ssi) = YES$((ORD(ssi) ge 2) AND (ORD(ssi) le CARD(ssi)));

Set ifirst(ssi) incident subset i controlling the first
pseudo incident i ;
ifirst(ssi) = YES$(ORD(ssi) eq 1);

Set ilast(ssi) incident subset i controlling the last pseudo
incident i ;
ilast(ssi) = YES$(ORD(ssi) eq CARD(ssi));

Set sj(ssj) incident subset j from 0 to n ;
sj(ssj) = YES$((ORD(ssj) ge 1) AND (ORD(ssj) le (CARD(ssj)-1)));

Set j(ssj) incident subset j from 1 to n ;
j(ssj) = YES$((ORD(ssj) ge 2) AND (ORD(ssj) le (CARD(ssj)-1)));

Set jj(ssj) incident subset j from 1 to n+1 ;
jj(ssj) = YES$((ORD(ssj) ge 2) AND (ORD(ssj) le CARD(ssj)));

Set jfirst(ssj) incident subset j controlling the first
pseudo incident j ;
jfirst(ssj) = YES$(ORD(ssj) eq 1);

Set jlast(ssj) incident subset j controlling the last pseudo
incident j ;
jlast(ssj) = YES$(ORD(ssj) eq CARD(ssj));

Binary Variables
X(ssi,ssj,k) Decision if incident i is processed
immediately before incident j by rescue unit k
Y(ssi,ssj,k) Decision if incident i is processed before
incident j by rescue unit k ;

Equation Preincident(ssj) (C1) Each incident has a
predecessor ;
Preincident(j)… sum((si,k), X(si,j,k)) =e= 1 ;

Equation Postincident(ssi) (C2) Each incident has a successor
incident ;
Postincident(i)… sum((jj,k), X(i,jj,k)) =e= 1 ;

Equation Transitivity(ssi,ssj,k,l) (C5) Transitivity of predecessor
incidents ;
*Transitivity(si,j,k,l)… Y(si,%l,k) + Y(%l,j,k) - 1 =l= Y(si,j,k) ;
*Transitivity(si,li,j,lj,k)(ORD(lj) eq ORD(li)).. Y(si,lj,k) + Y(li,j,k)(ORD(li) eq ORD(lj)) - 1 =l= Y(si,j,k) ;
*Transitivity(ssi,ssj,k,l)… Y(ssi,ssj,k)(ORD(ssj) eq ORD(l)) + Y(ssi,ssj,k)(ORD(ssi) eq ORD(l)) - 1 =l= Y(ssi,ssj,k) ;

Equation Immediate(ssi,ssj,k) (C6) An immediate predecessor is a
specific predecessor ;
Immediate(si,jj,k)… X(si,jj,k) =l= Y(si,jj,k) ;


Any help would be greatly appreciated.


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group

athttp://groups.google.com/group/gamsworld?hl=en.


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/gamsworld?hl=en.

\