Skip to content

Commit

Permalink
Bugfix: step calculation for linear models without box constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
lindonroberts committed Jul 8, 2021
1 parent 84bf1e6 commit 58ab2ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion trustregion/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def solve(g, H, delta, sl=None, su=None, verbose_output=False):
crvmin = 0.0 if delta <= ZERO_THRESH else -1.0
elif linear and not box_constrained:
# Minimise linear function inside a ball - analytic solution
s = g * (delta / np.linalg.norm(g))
s = -g * (delta / np.linalg.norm(g))
crvmin = 0.0
elif linear:
# Linear with box constraints - TRSLIN
Expand Down
2 changes: 1 addition & 1 deletion trustregion/tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def runTest(self):
delta = 5.0
for H in [None, np.zeros((len(g), len(g)))]:
x = trustregion.solve(g, H, delta)
xtrue = delta * g / np.linalg.norm(g)
xtrue = -delta * g / np.linalg.norm(g)
self.assertTrue(np.max(np.abs(x - xtrue)) < 1e-10, msg='Wrong step')
self.assertTrue(np.linalg.norm(x) <= delta + BALL_EPS, msg='Ball constraint violated')

Expand Down

0 comments on commit 58ab2ee

Please sign in to comment.