Skip to content

Commit 5fdebab

Browse files
committed
Bugfix to stop crash when initialized at minimizer (fixes #24)
1 parent 8d6a707 commit 5fdebab

30 files changed

+117
-67
lines changed

dfols/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from __future__ import absolute_import, division, print_function, unicode_literals
4040

4141
# DFO-LS version
42-
__version__ = '1.5.2'
42+
__version__ = '1.5.3'
4343

4444
# Main solver & exit flags
4545
from .solver import *

dfols/solver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ def solve_main(objfun, x0, argsf, xl, xu, projections, npt, rhobeg, rhoend, maxf
148148
exit_info = ExitInformation(EXIT_SUCCESS, "Objective is sufficiently small")
149149

150150
if exit_info is not None:
151-
return x0, r0_avg, sumsq(r0_avg), None, num_samples_run, nf, nx, nruns_so_far+1, exit_info, diagnostic_info
151+
xmin_eval_num = 0
152+
jacmin_eval_nums = np.array([0], dtype=int)
153+
return x0, r0_avg, sumsq(r0_avg), None, num_samples_run, nf, nx, nruns_so_far+1, exit_info, diagnostic_info, xmin_eval_num, jacmin_eval_nums
152154

153155
else: # have old r0 information (e.g. from previous restart), use this instead
154156

dfols/tests/test_solver.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,22 @@ def runTest(self):
210210
self.assertTrue(array_compare(soln.resid, rosenbrock(soln.x), thresh=1e-10), "Wrong resid")
211211
self.assertTrue(array_compare(soln.jacobian, rosenbrock_jacobian(soln.x), thresh=1e-2), "Wrong Jacobian")
212212
self.assertTrue(abs(soln.obj - fmin) < 1e-4, "Wrong fmin")
213+
214+
class TestDiagnosticInto(unittest.TestCase):
215+
# Return diagnostic info - minimal working example for issue #23
216+
def runTest(self):
217+
## Minimal working example for DFO-LS bug #23
218+
objfun = lambda x: x
219+
x0 = np.arange(3)
220+
xmin = np.zeros(x0.shape)
221+
soln = dfols.solve(objfun=objfun, x0=x0, user_params={"logging.save_diagnostic_info": True})
222+
self.assertTrue(array_compare(soln.x, xmin, thresh=1e-2), "Wrong xmin")
223+
224+
class TestStartAtMin(unittest.TestCase):
225+
# Start solver at solution - minimal working example for issue #24
226+
def runTest(self):
227+
objfun = lambda x: x
228+
x0 = np.zeros(3)
229+
xmin = x0.copy()
230+
soln = dfols.solve(objfun=objfun, x0=x0, user_params={"logging.save_diagnostic_info": True})
231+
self.assertTrue(array_compare(soln.x, xmin, thresh=1e-8), "Wrong xmin")
1.41 KB
Binary file not shown.

docs/build/doctrees/history.doctree

753 Bytes
Binary file not shown.

docs/build/doctrees/index.doctree

0 Bytes
Binary file not shown.

docs/build/html/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 865700494aceade7d85c2a3d7b404b00
3+
config: e27aac59f14e76a4142e0b9f9d374216
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/build/html/_sources/history.rst.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ Version 1.5.1 (10 Oct 2024)
7575
Version 1.5.2 (28 Oct 2024)
7676
---------------------------
7777
* Bugfix for saving diagnostic info (bug introduced in v1.5.1)
78+
79+
Version 1.5.3 (30 Oct 2024)
80+
---------------------------
81+
* Bugfix when starting solver at problem minimizer (bug introduced in v1.5.1)

docs/build/html/_static/documentation_options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const DOCUMENTATION_OPTIONS = {
2-
VERSION: '1.5.2',
2+
VERSION: '1.5.3',
33
LANGUAGE: 'en',
44
COLLAPSE_INDEX: false,
55
BUILDER: 'html',

docs/build/html/advanced.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
55

66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Advanced Usage &mdash; DFO-LS v1.5.2 documentation</title>
7+
<title>Advanced Usage &mdash; DFO-LS v1.5.3 documentation</title>
88
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
99
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
1010

@@ -15,7 +15,7 @@
1515

1616
<script src="_static/jquery.js?v=5d32c60e"></script>
1717
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
18-
<script src="_static/documentation_options.js?v=73275c37"></script>
18+
<script src="_static/documentation_options.js?v=d75fd82e"></script>
1919
<script src="_static/doctools.js?v=888ff710"></script>
2020
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
2121
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
@@ -38,7 +38,7 @@
3838
DFO-LS
3939
</a>
4040
<div class="version">
41-
1.5.2
41+
1.5.3
4242
</div>
4343
<div role="search">
4444
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">

0 commit comments

Comments
 (0)