From f023e0dcf0edf278a8b44f70c8317b8507ed5be5 Mon Sep 17 00:00:00 2001 From: John McMaster Date: Wed, 3 Oct 2018 16:26:41 -0700 Subject: [PATCH] solve_leastsq.py:mkestimate(): ignore 0 delay rows, assert non-trivial seed Signed-off-by: John McMaster --- fuzzers/007-timing/solve_leastsq.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fuzzers/007-timing/solve_leastsq.py b/fuzzers/007-timing/solve_leastsq.py index 8f01b54e..3e6f5742 100644 --- a/fuzzers/007-timing/solve_leastsq.py +++ b/fuzzers/007-timing/solve_leastsq.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from timfuz import Benchmark, load_sub, corner_s2i, acorner2csv +from timfuz import Benchmark, load_sub import timfuz import numpy as np import math @@ -22,11 +22,20 @@ def mkestimate(Anp, b): x0 = np.array([1e3 for _x in range(cols)]) for row_np, row_b in zip(Anp, b): for coli, val in enumerate(row_np): - if val: - # Scale by number occurances - ub = row_b / val - if ub >= 0: - x0[coli] = min(x0[coli], ub) + # favor non-trivial values + if val <= 0: + continue + # Scale by number occurances + ub = row_b / val + if ub <= 0: + continue + if x0[coli] == 0: + x0[coli] = ub + else: + x0[coli] = min(x0[coli], ub) + # reject solutions that don't provide a seed value + # these lead to bad optimizations + assert sum(x0) != 0 return x0