aboutsummaryrefslogtreecommitdiffstats
path: root/apps/pci/optimizers/solver/ml_model.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/ml_model.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/ml_model.py')
-rw-r--r--apps/pci/optimizers/solver/ml_model.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/apps/pci/optimizers/solver/ml_model.py b/apps/pci/optimizers/solver/ml_model.py
new file mode 100644
index 0000000..3e12387
--- /dev/null
+++ b/apps/pci/optimizers/solver/ml_model.py
@@ -0,0 +1,69 @@
+# -------------------------------------------------------------------------
+# 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.
+# 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.
+#
+# -------------------------------------------------------------------------
+#
+
+from osdf.adapters.dcae import des
+from osdf.adapters.dcae.des import DESException
+from osdf.config.base import osdf_config
+from osdf.logging.osdf_logging import error_log
+
+
+class MlModel(object):
+ def __init__(self):
+ self.config = osdf_config.core['PCI']
+
+ def get_additional_inputs(self, dzn_data, network_cell_info):
+ """Add/update additional info to the existing models.
+
+ The method returns nothing. Instead, it modifies the dzn_data
+ :params: dzn_data: map with data for the optimization
+ """
+ self.compute_ml_model(dzn_data, network_cell_info)
+
+ def compute_ml_model(self, dzn_data, network_cell_info):
+ average_ho_threshold = self.config['ML']['average_ho_threshold']
+ latest_ho_threshold = self.config['ML']['latest_ho_threshold']
+
+ fixed_cells = set()
+ for cell in network_cell_info['cell_list']:
+ cell_id = cell['cell_id']
+ average_ho, latest_ho = self.get_ho_details(cell['cell_id'])
+ if average_ho > average_ho_threshold or latest_ho > latest_ho_threshold:
+ fixed_cells.add(cell_id)
+
+ fixed_cells.update(dzn_data.get('PCI_UNCHANGEABLE_CELLS', []))
+ dzn_data['PCI_UNCHANGEABLE_CELLS'] = list(fixed_cells)
+
+ def get_ho_details(self, cell_id):
+ service_id = self.config['DES']['service_id']
+ request_data = self.config['DES']['filter']
+ request_data['cell_id'] = cell_id
+ try:
+ result = des.extract_data(service_id, request_data)
+ except DESException as e:
+ error_log.error("Error while calling DES {}".format(e))
+ return 0, 0
+
+ if not result:
+ return 0, 0
+
+ ho_list = []
+ for pm_data in result:
+ ho = sum([int(meas['hashMap']['InterEnbOutAtt_X2HO']) for meas in pm_data['additionalMeasurements']])
+ ho_list.append(ho)
+
+ return sum(ho_list) / len(ho_list), ho_list[0]