Skip to content

Commit dc229d2

Browse files
committed
Bug fix in trust region subproblem - upgrade to version 1.0.1
1 parent ce35d07 commit dc229d2

File tree

9 files changed

+44
-24
lines changed

9 files changed

+44
-24
lines changed

README.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
==================================================================
22
DFO-LS: Derivative-Free Optimizer for Least-Squares |PyPI Version|
33
==================================================================
4-
DFO-LS is a flexible package for solving nonlinear least-squares minimisation, without requiring derivatives of the objective.
4+
DFO-LS is a flexible package for solving nonlinear least-squares minimisation, without requiring derivatives of the objective. It is particularly useful when evaluations of the objective function are expensive and/or noisy.
55

6-
This is an implementation of the algorithm from our paper: C. Cartis, J. Fiala, B. Marteau and L. Roberts, Improving the Flexibility and Robustness of Model-Based Derivative-Free Optimization Solvers, technical report, University of Oxford, (2018).
6+
This is an implementation of the algorithm from our paper: C. Cartis, J. Fiala, B. Marteau and L. Roberts, Improving the Flexibility and Robustness of Model-Based Derivative-Free Optimization Solvers, technical report, University of Oxford, (2018). DFO-LS is more flexible version of `DFO-GN <https://github.com/numericalalgorithmsgroup/dfogn>`_.
7+
8+
If you are interested in solving general optimization problems (without a least-squares structure), you may wish to try `Py-BOBYQA <https://github.com/numericalalgorithmsgroup/pybobyqa>`_, which has many of the same features as DFO-LS.
79

810
Documentation
911
-------------
@@ -23,7 +25,7 @@ Additionally, the following python packages should be installed (these will be i
2325

2426
Installation using pip
2527
----------------------
26-
For easy installation, use *pip* (http://www.pip-installer.org/) as root::
28+
For easy installation, use `pip <http://www.pip-installer.org/>`_ as root::
2729

2830
$ [sudo] pip install DFO-LS
2931

dfols/tests/test_trust_region.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def runTest(self):
9292
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, hess, Delta)
9393
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
9494
self.assertTrue(np.all(gnew == g + hess.vec_mul(d)), 'Wrong gnew')
95-
self.assertAlmostEqual(crvmin, -1.0, 'Wrong crvmin')
95+
print(crvmin)
96+
self.assertAlmostEqual(crvmin, 1.2, 'Wrong crvmin')
9697

9798

9899
class TestUncBdry(unittest.TestCase):
@@ -210,7 +211,8 @@ def runTest(self):
210211
# print(d)
211212
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
212213
self.assertTrue(np.all(gnew == g + hess.vec_mul(d)), 'Wrong gnew')
213-
self.assertAlmostEqual(crvmin, 1.5, 'Wrong crvmin')
214+
print(crvmin)
215+
self.assertAlmostEqual(crvmin, -1.0, 'Wrong crvmin')
214216

215217

216218
class TestConBdry(unittest.TestCase):
@@ -233,7 +235,8 @@ def runTest(self):
233235
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt_box(g, hess, Delta, sl - xopt, su - xopt)
234236
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
235237
self.assertTrue(np.max(np.abs(gnew - g - hess.vec_mul(d))) < 1e-10, 'Wrong gnew')
236-
self.assertAlmostEqual(crvmin, 1.0, 'Wrong crvmin')
238+
print(crvmin)
239+
self.assertAlmostEqual(crvmin, -1.0, 'Wrong crvmin')
237240
# self.assertAlmostEqual(crvmin, crvmin_cauchy, 'Wrong crvmin')
238241

239242

dfols/trust_region.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def trsbox(xopt, g, hess, sl, su, delta):
153153

154154
# Reduce STPLEN if necessary in order to preserve the simple bounds,
155155
# letting IACT be the index of the new constrained variable.
156-
iact = -1
156+
iact = None
157157
for i in range(n):
158158
if s[i] != 0.0:
159159
temp = (su[i] - xopt[i] - d[i] if s[i] > 0.0 else sl[i] - xopt[i] - d[i]) / s[i]
@@ -166,8 +166,8 @@ def trsbox(xopt, g, hess, sl, su, delta):
166166
if stplen > 0.0:
167167
iterc += 1
168168
temp = shs / stepsq
169-
if iact == 0 and temp > 0.0:
170-
crvmin = (min(crvmin, temp) if crvmin != -1.0 else temp)
169+
if iact is None and temp > 0.0:
170+
crvmin = min(crvmin, temp) if crvmin != -1.0 else temp
171171
ggsav = gredsq
172172
gnew += stplen * hs
173173
d += stplen * s
@@ -176,7 +176,7 @@ def trsbox(xopt, g, hess, sl, su, delta):
176176
qred += sdec
177177

178178
# Restart the conjugate gradient method if it has hit a new bound.
179-
if iact > -1:
179+
if iact is not None:
180180
nact += 1
181181
xbdi[iact] = (1 if s[iact] >= 0.0 else -1)
182182
delsq = delsq - d[iact] ** 2
@@ -253,7 +253,7 @@ def alt_trust_step(n, xopt, hess, sl, su, d, xbdi, nact, gnew, qred):
253253
# bound, there is a branch back to label 100 after fixing that variable.
254254
free_variable_reached_bound = False
255255
angbd = 1.0
256-
iact = -1
256+
iact = None
257257
for i in range(n):
258258
if xbdi[i] == 0:
259259
tempa = xopt[i] + d[i] - sl[i]
@@ -347,7 +347,7 @@ def alt_trust_step(n, xopt, hess, sl, su, d, xbdi, nact, gnew, qred):
347347
hred = cth * hred + sth * hs
348348

349349
qred += sdec
350-
if iact > -1 and isav == iu - 1:
350+
if iact is not None and isav == iu - 1:
351351
nact += 1
352352
xbdi[iact] = xsav
353353
restart_alt_loop = True

dfols/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
2323
"""
2424

25-
__version__ = '1.0'
25+
__version__ = '1.0.1'

docs/history.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Version History
2+
===============
3+
This section lists the different versions of DFO-LS and the updates between them.
4+
5+
Version 1.0 (6 Feb 2018)
6+
------------------------
7+
* Initial release of DFO-LS
8+
9+
Version 1.0.1 (20 Feb 2018)
10+
---------------------------
11+
* Minor bug fix to trust region subproblem solver (the output :code:`crvmin` is calculated correctly) - this has minimal impact on the performance of DFO-LS.
12+

docs/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ That is, DFO-LS solves
2020
\min_{x\in\mathbb{R}^n} &\quad f(x) := \sum_{i=1}^{m}r_{i}(x)^2 \\
2121
\text{s.t.} &\quad a \leq x \leq b
2222
23-
Full details of the DFO-LS algorithm are given in our paper: C. Cartis, J. Fiala, B. Marteau and L. Roberts, Improving the Flexibility and Robustness of Model-Based Derivative-Free Optimization Solvers, technical report, University of Oxford, (2018).
23+
Full details of the DFO-LS algorithm are given in our paper: C. Cartis, J. Fiala, B. Marteau and L. Roberts, Improving the Flexibility and Robustness of Model-Based Derivative-Free Optimization Solvers, technical report, University of Oxford, (2018). DFO-LS is a more flexible version of `DFO-GN <https://github.com/numericalalgorithmsgroup/dfogn>`_.
24+
25+
If you are interested in solving general optimization problems (without a least-squares structure), you may wish to try `Py-BOBYQA <https://github.com/numericalalgorithmsgroup/pybobyqa>`_, which has many of the same features as DFO-LS.
2426

2527
DFO-LS is released under the GNU General Public License. Please `contact NAG <http://www.nag.com/content/worldwide-contact-information>`_ for alternative licensing.
2628

@@ -33,6 +35,7 @@ DFO-LS is released under the GNU General Public License. Please `contact NAG <ht
3335
userguide
3436
advanced
3537
diagnostic
38+
history
3639

3740
Acknowledgements
3841
----------------

docs/userguide.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ DFO-LS correctly finds the solution to the constrained problem:
162162
Solution xmin = [ 0.9 0.81]
163163
Residual vector = [ 0. 0.1]
164164
Objective value f(xmin) = 0.01
165-
Needed 64 objective evaluations (at 64 points)
165+
Needed 65 objective evaluations (at 65 points)
166166
Approximate Jacobian = [[ -1.79999998e+01 9.99999990e+00]
167-
[ -1.00000000e+00 -1.26970349e-09]]
167+
[ -9.99999998e-01 -2.53940698e-09]]
168168
Exit flag = 0
169169
Success: rho has reached rhoend
170170
****************************
@@ -196,8 +196,8 @@ And we can now see each evaluation of :code:`objfun`:
196196
Function eval 2 at point 2 has f = 14.337296 at x = [-1.08 0.85]
197197
Function eval 3 at point 3 has f = 55.25 at x = [-1.2 0.73]
198198
...
199-
Function eval 63 at point 63 has f = 0.0100000029949496 at x = [ 0.89999999 0.81 ]
200-
Function eval 64 at point 64 has f = 0.00999999999999993 at x = [ 0.9 0.81]
199+
Function eval 64 at point 64 has f = 0.0100000029949496 at x = [ 0.89999999 0.81 ]
200+
Function eval 65 at point 65 has f = 0.00999999999999993 at x = [ 0.9 0.81]
201201
Did a total of 1 run(s)
202202
203203
If we wanted to save this output to a file, we could replace the above call to :code:`logging.basicConfig()` with
@@ -453,11 +453,11 @@ The output of this is
453453
454454
****** DFO-LS Results ******
455455
Solution xmin = [ 0.09777309 -2.32510588]
456-
Residual vector = [ -3.16191517e-13 -3.58602037e-12]
457-
Objective value f(xmin) = 1.295951917e-23
458-
Needed 17 objective evaluations (at 17 points)
459-
Approximate Jacobian = [[ 3.32510506 0.9022256 ]
460-
[ 10.22775528 -1.00001417]]
456+
Residual vector = [ 2.89990254e-13 3.31557004e-12]
457+
Objective value f(xmin) = 1.107709904e-23
458+
Needed 18 objective evaluations (at 18 points)
459+
Approximate Jacobian = [[ 3.32510429 0.90222738]
460+
[ 10.22774647 -0.9999939 ]]
461461
Exit flag = 0
462462
Success: Objective is sufficiently small
463463
****************************

manual.pdf

2.42 KB
Binary file not shown.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
author='Lindon Roberts',
3636
author_email='[email protected]',
3737
url='https://github.com/numericalalgorithmsgroup/dfols/',
38-
download_url='https://github.com/numericalalgorithmsgroup/dfols/archive/v1.0.tar.gz',
38+
download_url='https://github.com/numericalalgorithmsgroup/dfols/archive/v1.0.1.tar.gz',
3939
packages=['dfols'],
4040
license='GNU GPL',
4141
keywords = 'mathematics derivative free optimization nonlinear least squares',

0 commit comments

Comments
 (0)