Skip to content

Commit 126290f

Browse files
committed
Allow linear solve to handle multiple RHS
1 parent b4e9240 commit 126290f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pybobyqa/model.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,17 @@ def factorise_interp_matrix(self):
250250
return
251251

252252
def solve_system(self, rhs):
253+
# To do preconditioning below, we will need to scale each column of A elementwise by the entries of some vector
254+
col_scale = lambda A, scale: (A.T * scale).T # Uses the trick that A*x scales the 0th column of A by x[0], etc.
255+
253256
if self.factorisation_current:
254257
# A(preconditioned) = diag(left_scaling) * A(original) * diag(right_scaling)
255258
# Solve A(original)\rhs
256-
return LA.lu_solve((self.lu, self.piv), rhs * self.left_scaling) * self.right_scaling
259+
return col_scale(LA.lu_solve((self.lu, self.piv), col_scale(rhs, self.left_scaling)), self.right_scaling)
257260
else:
258261
logging.warning("model.solve_system not using factorisation")
259262
A, left_scaling, right_scaling = self.interpolation_matrix()
260-
return LA.solve(A, rhs * left_scaling) * right_scaling
263+
return col_scale(LA.solve(A, col_scale(rhs, left_scaling)), right_scaling)
261264

262265
def interpolate_model(self, verbose=False, min_chg_hess=True, get_norm_model_chg=False):
263266
if verbose:

0 commit comments

Comments
 (0)