Permalink
Browse files

optimization.py: try another approach with the zero-derivative-noninv…

…ertable-hessian-approximation problem
  • Loading branch information...
1 parent 4ea5766 commit da173ca7277432ea64279741b57a7a58fd6bfd64 @mattloper committed Mar 12, 2015
Showing with 4 additions and 7 deletions.
  1. +4 −7 optimization.py
View
@@ -365,13 +365,10 @@ def call_cb():
100. * J.nnz / (J.shape[0] * J.shape[1])))
if g.size > 1:
- with warnings.catch_warnings():
- warnings.filterwarnings('error')
- try:
- d_gn = col(solve(A, g))
- except:
- from scipy.sparse.linalg import lsqr
- d_gn = col(lsqr(A, g)[0])
+ d_gn = col(solve(A, g))
+ if np.any(np.isnan(d_gn)) or np.any(np.isinf(d_gn)):
+ from scipy.sparse.linalg import lsqr
+ d_gn = col(lsqr(A, g)[0])
else:
d_gn = np.atleast_1d(g.ravel()[0]/A[0,0])
pif('sparse solve...done in %.2fs' % (time.time() - tm))

0 comments on commit da173ca

Please sign in to comment.