[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] ordered sets query
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] ordered sets query |
Date: |
Sat, 20 Oct 2007 13:34:31 +0400 |
Friday, October 19, 2007, 4:23:49 PM, you wrote:
> I have a piece of AMPL code I am trying
> to rewrite in MATHPROG that uses ord()
> subject to g1{k in TT, i in Pat1[k], j in Patt1[k]:ord(i)=ord(j)}:
> -10<=sum{(i,t) in PatP1[k]}
> R[i]*x[i,t]-sum{(j,s) in PatPP1[k]} R[j]*x[j,s] <=10;
> The ord part looks at the ordered set (Pat1[k], Patt1[k]) and
> matches those two set members individually.
You can define parameters which map elements of Pat1 and Patt1 to
their ordinal numbers, e.g.
param ord1{k in TT, i in Pat1[k]};
param ord2{k in TT, i in Patt1[k]};
and then write something like this:
subject to g1{k in TT, i in Pat1[k], j in Patt1[k]:ord1[i]=ord2[j]}:
-10<=sum{(i,t) in PatP1[k]}
R[i]*x[i,t]-sum{(j,s) in PatPP1[k]} R[j]*x[j,s] <=10;