aboutsummaryrefslogtreecommitdiffstats
path: root/apps/pci/optimizers/solver/optimizer.py
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2020-09-14 19:15:25 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2020-09-17 14:48:46 +0530
commit716ad1f32fc10181d2826d1f345f5a8b81bd0106 (patch)
tree8bd569c1aa863a6cb439d4f250b143ebf14fde6c /apps/pci/optimizers/solver/optimizer.py
parent7b4619e523dbeb519eed3b141a0359108c614f55 (diff)
Add ML based optimization to PCI opt
Add DCAE DES adapter to the adapters Add a simple ML model in PCI opt app Issue-ID: OPTFRA-769 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: I144887e1be1ac6be4d27eeec22f9669c71f2c2bb
Diffstat (limited to 'apps/pci/optimizers/solver/optimizer.py')
-rw-r--r--apps/pci/optimizers/solver/optimizer.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/pci/optimizers/solver/optimizer.py b/apps/pci/optimizers/solver/optimizer.py
index 940f9f7..13298ed 100644
--- a/apps/pci/optimizers/solver/optimizer.py
+++ b/apps/pci/optimizers/solver/optimizer.py
@@ -1,5 +1,6 @@
# -------------------------------------------------------------------------
# Copyright (c) 2018 AT&T Intellectual Property
+# Copyright (C) 2020 Wipro Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,17 +17,21 @@
# -------------------------------------------------------------------------
#
+from collections import defaultdict
import itertools
import os
-from collections import defaultdict
import pymzn
-from .pci_utils import get_id,mapping
+from apps.pci.optimizers.solver.ml_model import MlModel
+from apps.pci.optimizers.solver.pci_utils import get_id
+from apps.pci.optimizers.solver.pci_utils import mapping
+from osdf.config.base import osdf_config
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)
@@ -37,10 +42,16 @@ def pci_optimize(network_cell_info, cell_info_list, request_json):
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, original_pcis, unchangeable_pcis)
+ dzn_data = build_dzn_data(cell_info_list, ignorable_links, neighbor_edges, second_level_edges, anr_flag,
+ original_pcis, unchangeable_pcis)
+
+ ml_enabled = osdf_config.core['PCI']['ml_enabled']
+ if ml_enabled:
+ MlModel().get_additional_inputs(dzn_data, network_cell_info)
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:
@@ -83,7 +94,8 @@ 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,original_pcis, unchangeable_pcis):
+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),