mirror of https://github.com/openXC7/prjxray.git
solve_leastsq.py:mkestimate(): ignore 0 delay rows, assert non-trivial seed
Signed-off-by: John McMaster <johndmcmaster@gmail.com>
This commit is contained in:
parent
7f61ff99fd
commit
f023e0dcf0
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue