Fix goal in _minmax() logic
Make sure we trigger failure when goals aren't met
Take abs of value before comparing with goal
Add log message when goals aren't met
@@ -2235,7 +2235,6 @@ class Chip:
# Keeping track of the steps/indexes that have goals met
failed = {}
- goals_met = False
for step, _ in steplist:
failed[step] = {}
for index in self.getkeys('flowgraph', step):
@@ -2247,10 +2246,11 @@ class Chip:
if 'goal' in self.getkeys('metric', step, index, metric):
goal = self.get('metric', step, index, metric, 'goal')
real = self.get('metric', step, index, metric, 'real')
- if bool(real > goal):
+ if abs(real) > goal:
+ self.logger.warning(f"Step {step}{index} failed "
+ f"because it didn't meet goals for '{metric}' "
+ "metric.")
failed[step][index] = True
- if not failed[step][index]:
- goals_met = True
# Calculate max/min values for each metric
max_val = {}
@@ -2274,6 +2274,9 @@ class Chip:
min_score = float("inf")
#TODO: why not run for all stepindex inputs?
for index in self.getkeys('flowgraph', step):
+ if failed[step][index]:
+ continue
+
if not self.get('flowstatus', step, index, 'error'):
score = 0.0
for metric in self.getkeys('flowgraph', step, index, 'weight'):
@@ -2289,7 +2292,7 @@ class Chip:
scaled = max_val[step][metric]
score = score + scaled * weight
- if (score < min_score) & (not (failed[step][index] & goals_met)):
+ if score < min_score:
min_score = score
winner = (step,index)
