From 430153e1a9489a86cf0ff7942eceb0bf5f1c170c Mon Sep 17 00:00:00 2001 From: vrvarma Date: Fri, 13 Dec 2019 10:24:55 -0500 Subject: osdf rearchitecture into apps and libs Change-Id: I2db2f8e252bd5e60807b2ffabf5a5b193a789f7a Signed-off-by: vrvarma Issue-ID: OPTFRA-637 --- apps/pci/optimizers/solver/__init__.py | 0 apps/pci/optimizers/solver/min_confusion.mzn | 98 +++++++++++++++ apps/pci/optimizers/solver/min_confusion_inl.mzn | 140 +++++++++++++++++++++ .../solver/no_conflicts_no_confusion.mzn | 86 +++++++++++++ apps/pci/optimizers/solver/optimizer.py | 137 ++++++++++++++++++++ apps/pci/optimizers/solver/pci_utils.py | 40 ++++++ 6 files changed, 501 insertions(+) create mode 100644 apps/pci/optimizers/solver/__init__.py create mode 100644 apps/pci/optimizers/solver/min_confusion.mzn create mode 100644 apps/pci/optimizers/solver/min_confusion_inl.mzn create mode 100644 apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn create mode 100644 apps/pci/optimizers/solver/optimizer.py create mode 100644 apps/pci/optimizers/solver/pci_utils.py (limited to 'apps/pci/optimizers/solver') diff --git a/apps/pci/optimizers/solver/__init__.py b/apps/pci/optimizers/solver/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/pci/optimizers/solver/min_confusion.mzn b/apps/pci/optimizers/solver/min_confusion.mzn new file mode 100644 index 0000000..ff56c18 --- /dev/null +++ b/apps/pci/optimizers/solver/min_confusion.mzn @@ -0,0 +1,98 @@ +% ------------------------------------------------------------------------- +% Copyright (c) 2018 AT&T Intellectual Property +% +% Licensed under the Apache License, Version 2.0 (the "License"); +% you may not use this file except in compliance with the License. +% You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +% See the License for the specific language governing permissions and +% limitations under the License. +% +% ------------------------------------------------------------------------- +% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Parameters and its assertions +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Number of cells/radios. +int: NUM_NODES; + +% Maximum number of Physical Cell Identifiers to be assigned to the nodes. +int: NUM_PCIS; + +% Number of edges between neighbor nodes. There is a edge (i,j) if and only +% if nodes i and j are neighbors, i.e., an user equipment (UE) can make +% handoff between i and j. Such edges are used to avoid **COLLISION**, i.e., +% to guarantee that nodes i and j have different PCIs. +int: NUM_NEIGHBORS; + +% Each line represents an edge between direct neighbors as defined before. +array[1..NUM_NEIGHBORS, 1..2] of int: NEIGHBORS; + +% Number of undirect neighbor pairs (j, k) such that both j and k are direct +% neighbors of node i, i.e., (j, k) exits if and only if exists (i, j) and +% (i, k). Nodes (i, k) can generate "confunsions" in the network if they have +% the same PCI. Such edges are used to avoid/minimize **CONFUSIONS**. +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; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Decision variables +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Defines the PCI for each node. +array[0..NUM_NODES-1] of var 0..NUM_PCIS-1: pci; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Constraints +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Direct neighbors must have different PCIs for avoid **COLLISION**. +constraint +forall(i in 1..NUM_NEIGHBORS)( + pci[NEIGHBORS[i, 1]] != pci[NEIGHBORS[i, 2]] +); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Objective function +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Total number of confusions. +var int: total_confusions = + sum([bool2int(pci[SECOND_LEVEL_NEIGHBORS[i, 1]] == + pci[SECOND_LEVEL_NEIGHBORS[i, 2]]) + | i in 1..NUM_SECOND_LEVEL_NEIGHBORS]); + +% Minimize the total number of confusions. +solve :: int_search(pci, smallest, indomain_min, complete) +minimize total_confusions; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Output +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +output +["PCI assigment"] ++ +["\nnode,pci"] ++ +[ + "\n" ++ show(node) ++ "," ++ show(pci[node]) +| node in 0..NUM_NODES-1 +] ++ + +["\n\nConfusions"] ++ +["\nTotal confusions: " ++ show(total_confusions)] ++ +["\nConfusion pairs"] ++ +[ + "\n" ++ show(SECOND_LEVEL_NEIGHBORS[i, 1]) ++ "," ++ + show(SECOND_LEVEL_NEIGHBORS[i, 2]) +| i in 1..NUM_SECOND_LEVEL_NEIGHBORS where + fix(pci[SECOND_LEVEL_NEIGHBORS[i, 1]] == pci[SECOND_LEVEL_NEIGHBORS[i, 2]]) +] diff --git a/apps/pci/optimizers/solver/min_confusion_inl.mzn b/apps/pci/optimizers/solver/min_confusion_inl.mzn new file mode 100644 index 0000000..0f0fc91 --- /dev/null +++ b/apps/pci/optimizers/solver/min_confusion_inl.mzn @@ -0,0 +1,140 @@ +% ------------------------------------------------------------------------- +% Copyright (c) 2018 AT&T Intellectual Property +% +% Licensed under the Apache License, Version 2.0 (the "License"); +% you may not use this file except in compliance with the License. +% You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +% See the License for the specific language governing permissions and +% limitations under the License. +% +% ------------------------------------------------------------------------- +% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Parameters and its assertions +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Number of cells/radios. +int: NUM_NODES; + +% Maximum number of Physical Cell Identifiers to be assigned to the nodes. +int: NUM_PCIS; + +% Number of edges between neighbor nodes. There is a edge (i,j) if and only +% if nodes i and j are neighbors, i.e., an user equipment (UE) can make +% handoff between i and j. Such edges are used to avoid **COLLISION**, i.e., +% to guarantee that nodes i and j have different PCIs. +int: NUM_NEIGHBORS; + +% Each line represents an edge between direct neighbors as defined before. +array[1..NUM_NEIGHBORS, 1..2] of int: NEIGHBORS; + +% Number of undirect neighbor pairs (j, k) such that both j and k are direct +% neighbors of node i, i.e., (j, k) exits if and only if exists (i, j) and +% (i, k). Nodes (i, k) can generate "confunsions" in the network if they have +% the same PCI. Such edges are used to avoid/minimize **CONFUSIONS**. +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; + +% Number of ignorable neighbor links. Such links can be ignored during +% optimization if needed. +int: NUM_IGNORABLE_NEIGHBOR_LINKS; + +% The links that can be ignored if needed. Each line represents the two ends +% of the links, like the previous structures. +array[1..NUM_IGNORABLE_NEIGHBOR_LINKS, 1..2] of int: IGNORABLE_NEIGHBOR_LINKS; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Decision variables +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Defines the PCI for each node. +array[0..NUM_NODES-1] of var 0..NUM_PCIS-1: pci; + +array[1..NUM_IGNORABLE_NEIGHBOR_LINKS] of var 0..1: used_ignorables; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Constraints +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Direct neighbors must have different PCIs for avoid **COLLISION**. +% Forced links. +constraint +forall(i in 1..NUM_NEIGHBORS, j in 1..NUM_IGNORABLE_NEIGHBOR_LINKS + where + NEIGHBORS[i, 1] != IGNORABLE_NEIGHBOR_LINKS[j, 1] \/ + NEIGHBORS[i, 2] != IGNORABLE_NEIGHBOR_LINKS[j, 2] +)( + pci[NEIGHBORS[i, 1]] != pci[NEIGHBORS[i, 2]] +); + + +% Ignorable links. +constraint +forall(i in 1..NUM_NEIGHBORS, j in 1..NUM_IGNORABLE_NEIGHBOR_LINKS + where + NEIGHBORS[i, 1] == IGNORABLE_NEIGHBOR_LINKS[j, 1] /\ + NEIGHBORS[i, 2] == IGNORABLE_NEIGHBOR_LINKS[j, 2] +)( + used_ignorables[j] >= bool2int(pci[NEIGHBORS[i, 1]] == pci[NEIGHBORS[i, 2]]) +); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Objective function +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Total number of confusions. +var int: total_confusions = + sum([bool2int(pci[SECOND_LEVEL_NEIGHBORS[i, 1]] == + pci[SECOND_LEVEL_NEIGHBORS[i, 2]]) + | i in 1..NUM_SECOND_LEVEL_NEIGHBORS]); + +% Total number of used ignorables links. +var int: total_used_ignorables = sum(used_ignorables); + +solve :: int_search(pci, smallest, indomain_min, complete) + +% Minimize the total number of confusions. +%minimize total_confusions; + +% Minimize the total number of confusions first, +% then the number of used ignorables links. +minimize (2 * NUM_IGNORABLE_NEIGHBOR_LINKS * total_confusions) + + total_used_ignorables; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Output +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +output +["PCI assigment"] ++ +["\nnode,pci"] ++ +[ + "\n" ++ show(node) ++ "," ++ show(pci[node]) +| node in 0..NUM_NODES-1 +] ++ +["\n\nTotal used ignorables links: " ++ show(total_used_ignorables)] ++ +["\nUsed ignorables links: "] ++ +[ + "\n" ++ show(IGNORABLE_NEIGHBOR_LINKS[i, 1]) ++ + "," ++ show(IGNORABLE_NEIGHBOR_LINKS[i, 2]) + | i in 1..NUM_IGNORABLE_NEIGHBOR_LINKS where fix(used_ignorables[i] > 0) +] ++ +["\n\nConfusions"] ++ +["\nTotal confusions: " ++ show(total_confusions)] ++ +["\nConfusion pairs"] ++ +[ + "\n" ++ show(SECOND_LEVEL_NEIGHBORS[i, 1]) ++ "," ++ + show(SECOND_LEVEL_NEIGHBORS[i, 2]) + | i in 1..NUM_SECOND_LEVEL_NEIGHBORS where + fix(pci[SECOND_LEVEL_NEIGHBORS[i, 1]] == pci[SECOND_LEVEL_NEIGHBORS[i, 2]]) +] + diff --git a/apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn b/apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn new file mode 100644 index 0000000..0a9b3e3 --- /dev/null +++ b/apps/pci/optimizers/solver/no_conflicts_no_confusion.mzn @@ -0,0 +1,86 @@ +% ------------------------------------------------------------------------- +% Copyright (c) 2018 AT&T Intellectual Property +% +% Licensed under the Apache License, Version 2.0 (the "License"); +% you may not use this file except in compliance with the License. +% You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +% See the License for the specific language governing permissions and +% limitations under the License. +% +% ------------------------------------------------------------------------- +% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Parameters and its assertions +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Number of cells/radios. +int: NUM_NODES; + +% Maximum number of Physical Cell Identifiers to be assigned to the nodes. +int: NUM_PCIS; + +% Number of edges between neighbor nodes. There is a edge (i,j) if and only +% if nodes i and j are neighbors, i.e., an user equipment (UE) can make +% handoff between i and j. Such edges are used to avoid **COLLISIONS**, i.e., +% to guarantee that nodes i and j have different PCIs. +int: NUM_NEIGHBORS; + +% Each line represents an edge between direct neighbors as defined before. +array[1..NUM_NEIGHBORS, 1..2] of int: NEIGHBORS; + +% Number of undirect neighbor pairs (j, k) such that both j and k are direct +% neighbors of node i, i.e., (j, k) exits if and only if exists (i, j) and +% (i, k). Nodes (i, k) can generate "confunsions" in the network if they have +% the same PCI. Such edges are used to avoid/minimize **CONFUSIONS**. +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; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Decision variables +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Defines the PCI for each node. +array[0..NUM_NODES-1] of var 0..NUM_PCIS-1: pci; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Constraints +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Direct neighbors must have different PCIs for avoid **COLLISION**. +constraint +forall(i in 1..NUM_NEIGHBORS)( + pci[NEIGHBORS[i, 1]] != pci[NEIGHBORS[i, 2]] +); + +% Undirect neighbors must have different PCIs for avoid **CONFUSIONS**. +constraint +forall(i in 1..NUM_SECOND_LEVEL_NEIGHBORS)( + pci[SECOND_LEVEL_NEIGHBORS[i, 1]] != pci[SECOND_LEVEL_NEIGHBORS[i, 2]] +); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Objective function +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Just satisfy the problem. +solve :: int_search(pci, smallest, indomain_min, complete) satisfy; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Output +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +output +["node,pci\n"] ++ +[ + show(node) ++ "," ++ show(pci[node]) ++ "\n" +| node in 0..NUM_NODES-1 +] diff --git a/apps/pci/optimizers/solver/optimizer.py b/apps/pci/optimizers/solver/optimizer.py new file mode 100644 index 0000000..0a6d5a4 --- /dev/null +++ b/apps/pci/optimizers/solver/optimizer.py @@ -0,0 +1,137 @@ +# ------------------------------------------------------------------------- +# Copyright (c) 2018 AT&T Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + +import itertools +import os +from collections import defaultdict + +import pymzn + +from .pci_utils import get_id + +BASE_DIR = os.path.dirname(__file__) + + +def pci_optimize(network_cell_info, cell_info_list, request_json): + 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) + + return build_pci_solution(dzn_data, ignorable_links, anr_flag) + + +def build_pci_solution(dzn_data, ignorable_links, anr_flag): + mzn_solution = solve(get_mzn_model(anr_flag), dzn_data) + + solution = {'pci': mzn_solution[0]['pci']} + + if anr_flag: + removables = defaultdict(list) + used_ignorables = mzn_solution[0]['used_ignorables'] + index = 0 + for i in ignorable_links: + if used_ignorables[index] > 0: + removables[i[0]].append(i[1]) + index += 1 + solution['removables'] = removables + return solution + + +def build_dzn_data(cell_info_list, ignorable_links, neighbor_edges, second_level_edges, anr_flag): + 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) + } + if anr_flag: + dzn_data['NUM_IGNORABLE_NEIGHBOR_LINKS'] = len(ignorable_links) + dzn_data['IGNORABLE_NEIGHBOR_LINKS'] = get_list(ignorable_links) + return dzn_data + + +def get_mzn_model(anr_flag): + if anr_flag: + mzn_model = os.path.join(BASE_DIR, 'min_confusion_inl.mzn') + else: + mzn_model = os.path.join(BASE_DIR, 'no_conflicts_no_confusion.mzn') + return mzn_model + + +def is_anr(request_json): + return 'pci-anr' in request_json["requestInfo"]["optimizers"] + + +def get_list(edge_list): + array_list = [] + for s in edge_list: + array_list.append([s[0], s[1]]) + return sorted(array_list) + + +def solve(mzn_model, dzn_data): + return pymzn.minizinc(mzn=mzn_model, data=dzn_data) + + +def get_neighbor_list(network_cell_info): + neighbor_list = set() + for cell in network_cell_info['cell_list']: + add_to_neighbor_list(network_cell_info, cell, neighbor_list) + return neighbor_list + + +def add_to_neighbor_list(network_cell_info, cell, neighbor_list): + for nbr in cell.get('nbr_list', []): + host_id = cell['id'] + nbr_id = get_id(network_cell_info, nbr['targetCellId']) + if nbr_id and host_id != nbr_id: + neighbor_list.add((host_id, nbr_id)) + + +def get_second_level_neighbor(network_cell_info): + second_neighbor_list = set() + for cell in network_cell_info['cell_list']: + comb_list = build_second_level_list(network_cell_info, cell) + for comb in comb_list: + if comb[0] and comb[1]: + second_neighbor_list.add((comb[0], comb[1])) + return sorted(second_neighbor_list) + + +def build_second_level_list(network_cell_info, cell): + second_nbr_list = [] + for nbr in cell.get('nbr_list', []): + second_nbr_list.append(get_id(network_cell_info, nbr['targetCellId'])) + return [list(elem) for elem in list(itertools.combinations(second_nbr_list, 2))] + + +def get_ignorable_links(network_cell_info, request_json): + ignorable_list = set() + anr_input_list = request_json["cellInfo"].get('anrInputList', []) + if anr_input_list: + for anr_info in anr_input_list: + cell_id = get_id(network_cell_info, anr_info['cellId']) + anr_removable = anr_info.get('removeableNeighbors', []) + for anr in anr_removable: + ignorable_list.add((cell_id, get_id(network_cell_info, anr))) + return ignorable_list diff --git a/apps/pci/optimizers/solver/pci_utils.py b/apps/pci/optimizers/solver/pci_utils.py new file mode 100644 index 0000000..04829cf --- /dev/null +++ b/apps/pci/optimizers/solver/pci_utils.py @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------- +# Copyright (c) 2018 AT&T Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# + + +def get_id(network_cell_info, cell_id): + for i in network_cell_info['cell_list']: + if i['cell_id'] == cell_id: + return i['id'] + return None + + +def get_cell_id(network_cell_info, id): + for i in network_cell_info['cell_list']: + if i['id'] == id: + return i['cell_id'] + return None + + +def get_pci_value(network_cell_info, id): + cell_id = get_cell_id(network_cell_info, id) + for i in network_cell_info['cell_list']: + for j in i['nbr_list']: + if cell_id == j['targetCellId']: + return j['pciValue'] + return None -- cgit 1.2.3-korg