1 # -------------------------------------------------------------------------
2 # Copyright (C) 2020 Wipro Limited.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # -------------------------------------------------------------------------
19 from osdf.adapters.dcae import des
20 from osdf.adapters.dcae.des import DESException
21 from osdf.config.base import osdf_config
22 from osdf.logging.osdf_logging import error_log
25 class MlModel(object):
27 self.config = osdf_config.core['PCI']
29 def get_additional_inputs(self, dzn_data, network_cell_info):
30 """Add/update additional info to the existing models.
32 The method returns nothing. Instead, it modifies the dzn_data
33 :params: dzn_data: map with data for the optimization
35 self.compute_ml_model(dzn_data, network_cell_info)
37 def compute_ml_model(self, dzn_data, network_cell_info):
38 average_ho_threshold = self.config['ML']['average_ho_threshold']
39 latest_ho_threshold = self.config['ML']['latest_ho_threshold']
42 for cell in network_cell_info['cell_list']:
43 cell_id = cell['cell_id']
44 average_ho, latest_ho = self.get_ho_details(cell['cell_id'])
45 if average_ho > average_ho_threshold or latest_ho > latest_ho_threshold:
46 fixed_cells.add(cell_id)
48 fixed_cells.update(dzn_data.get('PCI_UNCHANGEABLE_CELLS', []))
49 dzn_data['PCI_UNCHANGEABLE_CELLS'] = list(fixed_cells)
51 def get_ho_details(self, cell_id):
52 service_id = self.config['DES']['service_id']
53 request_data = self.config['DES']['filter']
54 request_data['cell_id'] = cell_id
56 result = des.extract_data(service_id, request_data)
57 except DESException as e:
58 error_log.error("Error while calling DES {}".format(e))
65 for pm_data in result:
66 ho = sum([int(meas['hashMap']['InterEnbOutAtt_X2HO']) for meas in pm_data['additionalMeasurements']])
69 return sum(ho_list) / len(ho_list), ho_list[0]