IBM ILOG Solver User's Manual > Extending the Library > Writing a Constraint: Allocating Frequencies > Writing a constraint: Frequency allocation

The problem is given here in the form of discrete data; that is, each frequency is represented by a number that can be called its channel number. For practical purposes, the network is divided into cells. (This problem is an actual cellular phone problem.) In each cell, there is a transmitter which uses different channels. The shape of the cells have been determined, as well as the precise location where the transmitters will be installed. For each of these cells, traffic requires a number of frequencies.

The problem of frequency assignment is to avoid interference. As a consequence, the distance between the frequencies within a cell must be greater than 16. To avoid inter-cell interference, the distance must vary because of the geography. In the example, you are assuming that the same frequencies can be used in the first cell and in the fourth cell, but you cannot use the same frequencies in the first cell and the third cell. Between two cells, the distance between frequencies appears in a matrix.

const int nbCell               = 25;
const int nbAvailFreq          = 256;
const int nbChannel[nbCell] =
  { 8,6,6,1,4,4,8,8,8,8,4,9,8,4,4,10,8,9,8,4,5,4,8,1,1 };
const int dist[nbCell][nbCell] = {
  { 16,1,1,0,0,0,0,0,1,1,1,1,1,2,2,1,1,0,0,0,2,2,1,1,1 },
  { 1,16,2,0,0,0,0,0,2,2,1,1,1,2,2,1,1,0,0,0,0,0,0,0,0 },
  { 1,2,16,0,0,0,0,0,2,2,1,1,1,2,2,1,1,0,0,0,0,0,0,0,0 },
  { 0,0,0,16,2,2,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1 },
  { 0,0,0,2,16,2,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1 },
  { 0,0,0,2,2,16,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1 },
  { 0,0,0,0,0,0,16,2,0,0,1,1,1,0,0,1,1,1,1,2,0,0,0,1,1 },
  { 0,0,0,0,0,0,2,16,0,0,1,1,1,0,0,1,1,1,1,2,0,0,0,1,1 },
  { 1,2,2,0,0,0,0,0,16,2,2,2,2,2,2,1,1,1,1,1,1,1,0,1,1 },
  { 1,2,2,0,0,0,0,0,2,16,2,2,2,2,2,1,1,1,1,1,1,1,0,1,1 },
  { 1,1,1,0,0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