mirror of https://github.com/openXC7/prjxray.git
timfuz leastsq: iteration print
Signed-off-by: John McMaster <johndmcmaster@gmail.com>
This commit is contained in:
parent
9e63d9ee55
commit
4fee67322f
|
|
@ -65,7 +65,23 @@ def run_corner(Anp, b, names, verbose=False, opts={}, meta={}, outfn=None):
|
||||||
if rows < cols:
|
if rows < cols:
|
||||||
raise Exception("rows must be >= cols")
|
raise Exception("rows must be >= cols")
|
||||||
|
|
||||||
|
tlast = [None]
|
||||||
|
iters = [0]
|
||||||
|
printn = [0]
|
||||||
|
def progress_print():
|
||||||
|
iters[0] += 1
|
||||||
|
if tlast[0] is None:
|
||||||
|
tlast[0]= time.time()
|
||||||
|
if time.time() - tlast[0] > 1.0:
|
||||||
|
sys.stdout.write('I:%d ' % iters[0])
|
||||||
|
tlast[0] = time.time()
|
||||||
|
printn[0] += 1
|
||||||
|
if printn[0] % 10 == 0:
|
||||||
|
sys.stdout.write('\n')
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
def func(params):
|
def func(params):
|
||||||
|
progress_print()
|
||||||
return (b - np.dot(Anp, params))
|
return (b - np.dot(Anp, params))
|
||||||
|
|
||||||
print('')
|
print('')
|
||||||
|
|
@ -75,8 +91,10 @@ def run_corner(Anp, b, names, verbose=False, opts={}, meta={}, outfn=None):
|
||||||
# starting at 0 completes quicky, but gives a solution near 0 with terrible results
|
# starting at 0 completes quicky, but gives a solution near 0 with terrible results
|
||||||
# maybe give a starting estimate to the smallest net delay with the indicated variable
|
# maybe give a starting estimate to the smallest net delay with the indicated variable
|
||||||
#x0 = np.array([1000.0 for _x in range(cols)])
|
#x0 = np.array([1000.0 for _x in range(cols)])
|
||||||
|
print('Creating x0 estimate')
|
||||||
x0 = mkestimate(Anp, b)
|
x0 = mkestimate(Anp, b)
|
||||||
#print('x0', x0)
|
#print('x0', x0)
|
||||||
|
|
||||||
if 0:
|
if 0:
|
||||||
x, cov_x, infodict, mesg, ier = optimize.leastsq(func, x0, args=(), full_output=True)
|
x, cov_x, infodict, mesg, ier = optimize.leastsq(func, x0, args=(), full_output=True)
|
||||||
print('x', x)
|
print('x', x)
|
||||||
|
|
@ -86,10 +104,13 @@ def run_corner(Anp, b, names, verbose=False, opts={}, meta={}, outfn=None):
|
||||||
print('ier', ier)
|
print('ier', ier)
|
||||||
print(' Solution found: %s' % (ier in (1, 2, 3, 4)))
|
print(' Solution found: %s' % (ier in (1, 2, 3, 4)))
|
||||||
else:
|
else:
|
||||||
|
print('Solving')
|
||||||
res = least_squares(func, x0, bounds=(0, float('inf')))
|
res = least_squares(func, x0, bounds=(0, float('inf')))
|
||||||
print(res)
|
if 0:
|
||||||
print('')
|
print(res)
|
||||||
print(res.x)
|
print('')
|
||||||
|
print(res.x)
|
||||||
|
print('Done')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
import argparse
|
import argparse
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue