From ed0d638fa01566ab5f9d71c1035e29ee5661f8ea Mon Sep 17 00:00:00 2001 From: Dileep Ranganathan Date: Tue, 11 Sep 2018 08:11:11 -0700 Subject: 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 --- conductor/conductor/solver/request/objective.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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": -- cgit 1.2.3-korg