diff options
author | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2018-09-11 08:11:11 -0700 |
---|---|---|
committer | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2018-09-11 08:11:11 -0700 |
commit | ed0d638fa01566ab5f9d71c1035e29ee5661f8ea (patch) | |
tree | 3400edb8bf8015c4af41e7fdc486ee92ff075024 | |
parent | 6ec674c56f4965606a4f865ac327c30d3ce4a53e (diff) |
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 <dileep.ranganathan@intel.com>
-rwxr-xr-x | conductor/conductor/solver/request/objective.py | 11 |
1 files changed, 10 insertions, 1 deletions
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": |