summaryrefslogtreecommitdiffstats
path: root/apps/pci/optimizers/solver
diff options
context:
space:
mode:
authordhebeha <dhebeha.mj71@wipro.com>2020-04-30 16:12:32 +0530
committerdhebeha <dhebeha.mj71@wipro.com>2020-04-30 16:35:30 +0530
commite07bb7a6bce3fa331c3e556395663dd77bc02676 (patch)
tree3fb75972940303b79cf237caa034824d96b9758c /apps/pci/optimizers/solver
parentd4a0085a8f75c62912d19613459ad1bc3dce3e73 (diff)
Change to support PCI unchangeable cells
Issue-ID: OPTFRA-678 Signed-off-by: dhebeha <dhebeha.mj71@wipro.com> Change-Id: Ib7620cb19850d77e80b2baea5ef318e8b0182d7c
Diffstat (limited to 'apps/pci/optimizers/solver')
-rw-r--r--apps/pci/optimizers/solver/min_confusion_inl.mzn16
-rw-r--r--apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn17
-rw-r--r--apps/pci/optimizers/solver/optimizer.py44
-rw-r--r--apps/pci/optimizers/solver/pci_utils.py7
4 files changed, 77 insertions, 7 deletions
diff --git a/apps/pci/optimizers/solver/min_confusion_inl.mzn b/apps/pci/optimizers/solver/min_confusion_inl.mzn
index 0f0fc91..e677e27 100644
--- a/apps/pci/optimizers/solver/min_confusion_inl.mzn
+++ b/apps/pci/optimizers/solver/min_confusion_inl.mzn
@@ -52,6 +52,14 @@ int: NUM_IGNORABLE_NEIGHBOR_LINKS;
% of the links, like the previous structures.
array[1..NUM_IGNORABLE_NEIGHBOR_LINKS, 1..2] of int: IGNORABLE_NEIGHBOR_LINKS;
+% ids of cells for which the pci should remain unchanged
+set of int: PCI_UNCHANGEABLE_CELLS;
+
+% This array has the original pcis of all the cells. array is indexed by the ids
+% of the cell. eg. ORIGINAL_PCIS[3] returns the pci of cell whose id is 3.
+% ids start from 0
+array[1..NUM_NODES] of 0..NUM_PCIS-1: ORIGINAL_PCIS;
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Decision variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -65,6 +73,14 @@ array[1..NUM_IGNORABLE_NEIGHBOR_LINKS] of var 0..1: used_ignorables;
% Constraints
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% fixed pci cells
+constraint
+if(length(PCI_UNCHANGEABLE_CELLS) !=0) then
+forall(i in PCI_UNCHANGEABLE_CELLS)(
+ pci[i] == ORIGINAL_PCIS[i+1]
+)
+endif;
+
% Direct neighbors must have different PCIs for avoid **COLLISION**.
% Forced links.
constraint
diff --git a/apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn b/apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn
index 0a9b3e3..f059d4a 100644
--- a/apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn
+++ b/apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn
@@ -44,6 +44,15 @@ int: NUM_SECOND_LEVEL_NEIGHBORS;
% Each line represents an edge between undirect neighbors as defined before.
array[1..NUM_SECOND_LEVEL_NEIGHBORS, 1..2] of int: SECOND_LEVEL_NEIGHBORS;
+% ids of cells for which the pci should remain unchanged
+set of int: PCI_UNCHANGEABLE_CELLS;
+
+% This array has the original pcis of all the cells. array is indexed by the ids
+% of the cell. eg. ORIGINAL_PCIS[3] returns the pci of cell whose id is 3.
+% ids start from 0
+% array[0..NUM_NODES-1] of 0..NUM_PCIS-1: ORIGINAL_PCIS;
+array[1..NUM_NODES] of 0..NUM_PCIS-1: ORIGINAL_PCIS;
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Decision variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -55,6 +64,14 @@ array[0..NUM_NODES-1] of var 0..NUM_PCIS-1: pci;
% Constraints
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+constraint
+if(length(PCI_UNCHANGEABLE_CELLS) !=0) then
+forall(i in PCI_UNCHANGEABLE_CELLS)(
+ pci[i] == ORIGINAL_PCIS[i+1]
+)
+endif;
+
+
% Direct neighbors must have different PCIs for avoid **COLLISION**.
constraint
forall(i in 1..NUM_NEIGHBORS)(
diff --git a/apps/pci/optimizers/solver/optimizer.py b/apps/pci/optimizers/solver/optimizer.py
index 0a6d5a4..940f9f7 100644
--- a/apps/pci/optimizers/solver/optimizer.py
+++ b/apps/pci/optimizers/solver/optimizer.py
@@ -19,28 +19,56 @@
import itertools
import os
from collections import defaultdict
-
import pymzn
-from .pci_utils import get_id
+from .pci_utils import get_id,mapping
BASE_DIR = os.path.dirname(__file__)
-
+cell_id_mapping = dict()
+id_cell_mapping = dict()
def pci_optimize(network_cell_info, cell_info_list, request_json):
+ global cell_id_mapping, id_cell_mapping
+ cell_id_mapping, id_cell_mapping = mapping(network_cell_info)
+ original_pcis = get_original_pci_list(network_cell_info)
+ unchangeable_pcis = get_ids_of_fixed_pci_cells(request_json['cellInfo'].get('fixedPCICells', []))
neighbor_edges = get_neighbor_list(network_cell_info)
second_level_edges = get_second_level_neighbor(network_cell_info)
ignorable_links = get_ignorable_links(network_cell_info, request_json)
anr_flag = is_anr(request_json)
- dzn_data = build_dzn_data(cell_info_list, ignorable_links, neighbor_edges, second_level_edges, anr_flag)
+ dzn_data = build_dzn_data(cell_info_list, ignorable_links, neighbor_edges, second_level_edges, anr_flag, original_pcis, unchangeable_pcis)
return build_pci_solution(dzn_data, ignorable_links, anr_flag)
+def get_ids_of_fixed_pci_cells(fixed_pci_list):
+ fixed_pci_ids = set()
+ for cell in fixed_pci_list:
+ fixed_pci_ids.add(cell_id_mapping[cell])
+ return fixed_pci_ids
+
+
+def get_cell_id_pci_mapping(network_cell_info):
+ original_pcis = dict()
+ for cell in network_cell_info['cell_list']:
+ for nbr in cell['nbr_list']:
+ if cell_id_mapping[nbr['targetCellId']] not in original_pcis:
+ original_pcis[cell_id_mapping[nbr['targetCellId']]] = nbr['pciValue']
+ return original_pcis
+
+
+def get_original_pci_list(network_cell_info):
+ cell_id_pci_mapping = get_cell_id_pci_mapping(network_cell_info)
+ original_pcis_list = []
+ for i in range(len(cell_id_pci_mapping)):
+ original_pcis_list.append(cell_id_pci_mapping.get(i))
+ return original_pcis_list
+
def build_pci_solution(dzn_data, ignorable_links, anr_flag):
mzn_solution = solve(get_mzn_model(anr_flag), dzn_data)
-
+ if mzn_solution == 'UNSATISFIABLE':
+ return mzn_solution
solution = {'pci': mzn_solution[0]['pci']}
if anr_flag:
@@ -55,14 +83,16 @@ def build_pci_solution(dzn_data, ignorable_links, anr_flag):
return solution
-def build_dzn_data(cell_info_list, ignorable_links, neighbor_edges, second_level_edges, anr_flag):
+def build_dzn_data(cell_info_list, ignorable_links, neighbor_edges, second_level_edges, anr_flag,original_pcis, unchangeable_pcis):
dzn_data = {
'NUM_NODES': len(cell_info_list),
'NUM_PCIS': len(cell_info_list),
'NUM_NEIGHBORS': len(neighbor_edges),
'NEIGHBORS': get_list(neighbor_edges),
'NUM_SECOND_LEVEL_NEIGHBORS': len(second_level_edges),
- 'SECOND_LEVEL_NEIGHBORS': get_list(second_level_edges)
+ 'SECOND_LEVEL_NEIGHBORS': get_list(second_level_edges),
+ 'PCI_UNCHANGEABLE_CELLS': unchangeable_pcis,
+ 'ORIGINAL_PCIS': original_pcis
}
if anr_flag:
dzn_data['NUM_IGNORABLE_NEIGHBOR_LINKS'] = len(ignorable_links)
diff --git a/apps/pci/optimizers/solver/pci_utils.py b/apps/pci/optimizers/solver/pci_utils.py
index 04829cf..7db3a6f 100644
--- a/apps/pci/optimizers/solver/pci_utils.py
+++ b/apps/pci/optimizers/solver/pci_utils.py
@@ -16,6 +16,13 @@
# -------------------------------------------------------------------------
#
+def mapping(network_cell_info):
+ cell_id_mapping= dict()
+ id_cell_mapping = dict()
+ for i in network_cell_info['cell_list']:
+ cell_id_mapping[i['cell_id']] = i['id']
+ id_cell_mapping[i['id']] = i['cell_id']
+ return cell_id_mapping, id_cell_mapping
def get_id(network_cell_info, cell_id):
for i in network_cell_info['cell_list']: