Skip to content

Commit

Permalink
fix: adding option to use mkl
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Feb 8, 2022
1 parent d780300 commit 22883ba
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions LoopStructural/interpolators/discrete_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def build_matrix(self, square=True, damp=0.0, ie=False):
return ATA, ATB, Aie.T.dot(Aie), Aie.T.dot(uie), Aie.T.dot(lie)
return ATA, ATB

def _solve_osqp(self, P, A, q, l, u):
def _solve_osqp(self, P, A, q, l, u,mkl=False):

try:
import osqp
Expand Down Expand Up @@ -527,7 +527,16 @@ def _solve_osqp(self, P, A, q, l, u):

# Setup workspace
# osqp likes csc matrices
prob.setup(P.tocsc(), np.array(q), A.tocsc(), np.array(u), np.array(l))
linsys_solver='qdldl'
if mkl:
linsys_solver='mkl pardiso'

try:
prob.setup(P.tocsc(), np.array(q), A.tocsc(), np.array(u), np.array(l),linsys_solver=linsys_solver)
except ValueError:
if mkl:
logger.error('MKL solver library path not correct. Please add to LD_LIBRARY_PATH')
raise LoopImportError("Cannot import MKL pardiso")
res = prob.solve()
return res.x

Expand Down

0 comments on commit 22883ba

Please sign in to comment.