.. _frequencyAssignment: Frequency assignment ==================== The area of telecommunications, and in particular mobile telecommunications, gives rise to many different variants of frequency assignment problems. We are given a network of cells (nodes) with requirements of discrete frequency bands. Each cell has a given demand for a number of frequencies (bands). Figure 11.2.1 shows the structure of the network. Nodes linked by an edge are considered as neighbors. They must not be assigned the same frequencies to avoid interference. Furthermore, if a cell uses several frequencies they must all be different by at least 2. The objective is to minimize the total number of frequencies used in the network. .. _fig4_telecommunications_network: .. figure:: images/4_telecommunications_network.png :align: center :scale: 60% Telecommunications network The following table lists the number of frequency demands for every cell: +--------+---+---+---+---+---+---+---+---+---+----+ | Cell | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | +--------+---+---+---+---+---+---+---+---+---+----+ | Demand | 4 | 5 | 2 | 3 | 2 | 4 | 3 | 4 | 3 | 2 | +--------+---+---+---+---+---+---+---+---+---+----+ Model formulation ----------------- Let :math:`NODES` be the set of all nodes in the network and :math:`DEM_n` the demand of frequencies at node :math:`n \in NODES`. The network is given as a set of edges :math:`LINKS`. Furthermore, let :math:`DEMANDS = \{1, 2, . . . ,NUMDEM\}` be the set of frequencies, numbered consecutively across all nodes where the upper bound :math:`NUMDEM` is given by the total number of demands. The auxiliary array :math:`INDEX_n` indicates the starting index in :math:`DEMANDS` for node :math:`n`. For representing the frequency assigned to every demand :math:`d \in DEMANDS` we introduce the variables :math:`use` that take their values from the set :math:`\{1, 2, . . . ,NUMDEM\}`. The two sets of constraints (different frequencies assigned to neighboring nodes and minimum distance between frequencies within a node) can then be modeled as follows. .. math:: &\forall (n,m) \in LINKS : \text{all-different}(\bigcup\limits_{d=INDEX_n}^{INDEX_n+DEM_n-1} use_d \cup \bigcup\limits_{d=INDEX_m}^{INDEX_m+DEM_m-1} use_d) \\ &\forall n \in NODES, \forall c < d \in \{INDEX_n, ...,INDEX_n + DEM_n - 1\} : |use_c - use_d| \geq 2 \\ The objective function is to minimize to the number of frequencies used. We formulate this by minimizing the largest frequency number that occurs for the :math:`use` variables: .. math:: &\text{minimize} \text{ } \text{maximum}_{d \in DEMANDS}(use_d)\\ Implementation ----------------- The edges forming the telecommunications network are modeled as a list :math:`LINK`, where edge :math:`l` is given as :math:`(LINK(l,1),LINK(l,2))`. For the implementation of the constraints on the values of frequencies assigned to the same node we have two equivalent choices with Kalis, namely using ``abs`` or ``distance`` constraints. .. tabs:: .. code-tab:: c++ const int NODES = 10; // Range of links between nodes const int LINKS = 18 ; // Demand of nodes int DEM[] = {4, 5, 2, 3, 2, 4, 3, 4, 3, 2}; // Neighboring nodes int LINK[18][2] = {{1, 3}, {1, 4}, {1, 6},{2, 4}, {2, 7},{3, 4}, {3, 6}, {3, 8}, {3, 9},{4, 7}, {4, 9}, {4,10},{5, 7}, {5, 8}, {5, 9},{6, 9}, {7, 8}, {8,10}}; // Start index in 'use' int INDEX[10]; // Upper bound on no. of freq. int NUMDEM; int n; NUMDEM = 0; for (n=0;ngetObjectiveValue(); numfreq.setSup(nsol-1); } printf("Number of frequencies: %f\n", problem.getSolution().getObjectiveValue()); printf("Frequency assignment: \n"); for (n=0;n 0) { solver.printStats(); KSolution sol = problem.getSolution(); nsol = (int) sol.getObjectiveValue(); numfreq.setSup(nsol - 1); } System.out.println("Number of frequencies: " + problem.getSolution().getObjectiveValue()); System.out.println("Frequency assignment: "); for (indexNode=0; indexNode 0) { solver2.printStats(); KSolution sol = problem.getSolution(); } System.out.println("Number of frequencies: " + problem.getSolution().getObjectiveValue()); System.out.println("Frequency assignment: "); for (indexNode=0; indexNodegetSolution().printResume(); return 0; } .. code-tab:: py class SolutionListener(KSolverEventListener): def __init__(self, problem): KSolverEventListener.__init__(self, problem) def solutionFound(self, solution, thread_id): solution.printResume() .. code-tab:: java class MySolverEventListener extends KSolverEventListener { public void nodeExplored() { System.out.println("Node explored"); } public void branchGoDown() { System.out.println("Branch go down"); } public void branchGoUp() { System.out.println("Branch go up"); } public void branchingScheme() { } public boolean stopComputations() { return false; } public void solutionFound() { System.out.println("A solution has been found!"); } } Improving the problem formulation --------------------------------- We may observe that in our problem formulation all demand variables within a node and the constraints on these variables are entirely symmetric. In the absence of other constraints, we may reduce these symmetries by imposing an order on the :math:`use` variables, :math:`use_d + 1 \leq use_{d+1}` for demands :math:`d` and :math:`d+1` belonging to the same cell. Doing so, the problem is solved to optimality within less than 40 nodes using just the default strategy. We may take this a step further by writing: :math:`use_d + 2 \leq use_{d+1}`. The addition of these constraints shortens the search by yet a few more nodes. They can even be used simply in replacement of the ``abs`` or ``distance`` constraints. Results ----------------- An optimal solution to this problem uses 11 different frequencies. The model shown in the program listing prints out the following assignment of frequencies to nodes: .. _fig4_frequence_assignment: .. figure:: images/4_Frequencies_assignment.png :align: center Assignment of frequencies result