An OPL model of the Cellular Frequency Allocation Problem


int nbCells = ...;
int nbFreqs = ...;
range Cells 1..nbCells;
range Freqs 1..nbFreqs;
int nbTrans[Cells] = ...;
int distance[Cells,Cells] = ...;

struct TransmitterType { Cells c; int t; };
{TransmitterType} Transmitters = { | c in Cells & t in 1..nbTrans[c] };
var Freqs freq[Transmitters];

solve{
    forall(c in Cells & ordered t1,t2 in 1..nbTrans[c])
        abs(freq[] - freq[]) >= 16;

    forall(ordered c1,c2 in Cells: distance[c1,c2] > 0)
       forall(t1 in 1..nbTrans[c1] & t2 in 1..nbTrans[c2])
          abs(freq[] - freq[]) >= distance[c1,c2];
};



this model appears in: Pascal Van Hentenryck. The OPL Optimization Programming Language.
MIT Press, January 1999.