From: Dileep Ranganathan Date: Tue, 11 Sep 2018 15:11:11 +0000 (-0700) Subject: Invert HPA Score for minimizing objective function X-Git-Tag: 1.2.2~16 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=ed0d638fa01566ab5f9d71c1035e29ee5661f8ea;p=optf%2Fhas.git Invert HPA Score for minimizing objective function Score for each hpa constraint is entered in policy as positive value. Higher the HPA score the better. So inorder to minimize the objective function inverted HPA Score by inverting the sign of hpa_score value. Change-Id: Iaedb03ccc5f87d5e7b41509924289bb598a09139 Issue-ID: OPTFRA-313 Signed-off-by: Dileep Ranganathan --- diff --git a/conductor/conductor/solver/request/objective.py b/conductor/conductor/solver/request/objective.py index f255330..d957581 100755 --- a/conductor/conductor/solver/request/objective.py +++ b/conductor/conductor/solver/request/objective.py @@ -110,8 +110,17 @@ class Operand(object): value += float(candidate_info['cost']) elif self.function.func_type == "hpa_score": + # Currently only minimize objective goal is supported + # Higher the HPA score the better. + # Invert HPA Score if goal is minimize + invert = -1 + + # + # if self.function.goal == "max": + # invert = 1 + for demand_name, candidate_info in _decision_path.decisions.items(): - hpa_score = float(candidate_info.get('hpa_score', 0)) + hpa_score = invert * float(candidate_info.get('hpa_score', 0)) value += hpa_score if self.operation == "product":