Skip to content

Commit

Permalink
Bugfix to stop crash when initialized at minimizer (fixes #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
lindonroberts committed Oct 29, 2024
1 parent 8d6a707 commit 5fdebab
Show file tree
Hide file tree
Showing 30 changed files with 117 additions and 67 deletions.
2 changes: 1 addition & 1 deletion dfols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals

# DFO-LS version
__version__ = '1.5.2'
__version__ = '1.5.3'

# Main solver & exit flags
from .solver import *
Expand Down
4 changes: 3 additions & 1 deletion dfols/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def solve_main(objfun, x0, argsf, xl, xu, projections, npt, rhobeg, rhoend, maxf
exit_info = ExitInformation(EXIT_SUCCESS, "Objective is sufficiently small")

if exit_info is not None:
return x0, r0_avg, sumsq(r0_avg), None, num_samples_run, nf, nx, nruns_so_far+1, exit_info, diagnostic_info
xmin_eval_num = 0
jacmin_eval_nums = np.array([0], dtype=int)
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

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

Expand Down
19 changes: 19 additions & 0 deletions dfols/tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,22 @@ def runTest(self):
self.assertTrue(array_compare(soln.resid, rosenbrock(soln.x), thresh=1e-10), "Wrong resid")
self.assertTrue(array_compare(soln.jacobian, rosenbrock_jacobian(soln.x), thresh=1e-2), "Wrong Jacobian")
self.assertTrue(abs(soln.obj - fmin) < 1e-4, "Wrong fmin")

class TestDiagnosticInto(unittest.TestCase):
# Return diagnostic info - minimal working example for issue #23
def runTest(self):
## Minimal working example for DFO-LS bug #23
objfun = lambda x: x
x0 = np.arange(3)
xmin = np.zeros(x0.shape)
soln = dfols.solve(objfun=objfun, x0=x0, user_params={"logging.save_diagnostic_info": True})
self.assertTrue(array_compare(soln.x, xmin, thresh=1e-2), "Wrong xmin")

class TestStartAtMin(unittest.TestCase):
# Start solver at solution - minimal working example for issue #24
def runTest(self):
objfun = lambda x: x
x0 = np.zeros(3)
xmin = x0.copy()
soln = dfols.solve(objfun=objfun, x0=x0, user_params={"logging.save_diagnostic_info": True})
self.assertTrue(array_compare(soln.x, xmin, thresh=1e-8), "Wrong xmin")
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/history.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/index.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 865700494aceade7d85c2a3d7b404b00
config: e27aac59f14e76a4142e0b9f9d374216
tags: 645f666f9bcd5a90fca523b33c5a78b7
4 changes: 4 additions & 0 deletions docs/build/html/_sources/history.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ Version 1.5.1 (10 Oct 2024)
Version 1.5.2 (28 Oct 2024)
---------------------------
* Bugfix for saving diagnostic info (bug introduced in v1.5.1)

Version 1.5.3 (30 Oct 2024)
---------------------------
* Bugfix when starting solver at problem minimizer (bug introduced in v1.5.1)
2 changes: 1 addition & 1 deletion docs/build/html/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const DOCUMENTATION_OPTIONS = {
VERSION: '1.5.2',
VERSION: '1.5.3',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
6 changes: 3 additions & 3 deletions docs/build/html/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

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

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Expand All @@ -38,7 +38,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down
6 changes: 3 additions & 3 deletions docs/build/html/contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

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

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand All @@ -36,7 +36,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down
6 changes: 3 additions & 3 deletions docs/build/html/diagnostic.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

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

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Expand All @@ -38,7 +38,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down
6 changes: 3 additions & 3 deletions docs/build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &mdash; DFO-LS v1.5.2 documentation</title>
<title>Index &mdash; DFO-LS v1.5.3 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />

Expand All @@ -14,7 +14,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand All @@ -34,7 +34,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down
13 changes: 10 additions & 3 deletions docs/build/html/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

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

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand All @@ -37,7 +37,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down Expand Up @@ -70,6 +70,7 @@
<li class="toctree-l2"><a class="reference internal" href="#version-1-5-0-11-sep-2024">Version 1.5.0 (11 Sep 2024)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#version-1-5-1-10-oct-2024">Version 1.5.1 (10 Oct 2024)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#version-1-5-2-28-oct-2024">Version 1.5.2 (28 Oct 2024)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#version-1-5-3-30-oct-2024">Version 1.5.3 (30 Oct 2024)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="contributors.html">Contributors</a></li>
Expand Down Expand Up @@ -206,6 +207,12 @@ <h2>Version 1.5.2 (28 Oct 2024)<a class="headerlink" href="#version-1-5-2-28-oct
<li><p>Bugfix for saving diagnostic info (bug introduced in v1.5.1)</p></li>
</ul>
</section>
<section id="version-1-5-3-30-oct-2024">
<h2>Version 1.5.3 (30 Oct 2024)<a class="headerlink" href="#version-1-5-3-30-oct-2024" title="Link to this heading"></a></h2>
<ul class="simple">
<li><p>Bugfix when starting solver at problem minimizer (bug introduced in v1.5.1)</p></li>
</ul>
</section>
</section>


Expand Down
11 changes: 6 additions & 5 deletions docs/build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DFO-LS: Derivative-Free Optimizer for Least-Squares Minimization &mdash; DFO-LS v1.5.2 documentation</title>
<title>DFO-LS: Derivative-Free Optimizer for Least-Squares Minimization &mdash; DFO-LS v1.5.3 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Expand All @@ -37,7 +37,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down Expand Up @@ -84,8 +84,8 @@

<section id="dfo-ls-derivative-free-optimizer-for-least-squares-minimization">
<h1>DFO-LS: Derivative-Free Optimizer for Least-Squares Minimization<a class="headerlink" href="#dfo-ls-derivative-free-optimizer-for-least-squares-minimization" title="Link to this heading"></a></h1>
<p><strong>Release:</strong> 1.5.2</p>
<p><strong>Date:</strong> 28 October 2024</p>
<p><strong>Release:</strong> 1.5.3</p>
<p><strong>Date:</strong> 30 October 2024</p>
<p><strong>Author:</strong> <a class="reference external" href="https://lindonroberts.github.io/">Lindon Roberts</a></p>
<p>DFO-LS is a flexible package for finding local solutions to nonlinear least-squares minimization problems (with optional regularizer and constraints), without requiring any derivatives of the objective. DFO-LS stands for Derivative-Free Optimizer for Least-Squares.</p>
<p>That is, DFO-LS solves</p>
Expand Down Expand Up @@ -191,6 +191,7 @@ <h1>DFO-LS: Derivative-Free Optimizer for Least-Squares Minimization<a class="he
<li class="toctree-l2"><a class="reference internal" href="history.html#version-1-5-0-11-sep-2024">Version 1.5.0 (11 Sep 2024)</a></li>
<li class="toctree-l2"><a class="reference internal" href="history.html#version-1-5-1-10-oct-2024">Version 1.5.1 (10 Oct 2024)</a></li>
<li class="toctree-l2"><a class="reference internal" href="history.html#version-1-5-2-28-oct-2024">Version 1.5.2 (28 Oct 2024)</a></li>
<li class="toctree-l2"><a class="reference internal" href="history.html#version-1-5-3-30-oct-2024">Version 1.5.3 (30 Oct 2024)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="contributors.html">Contributors</a><ul>
Expand Down
6 changes: 3 additions & 3 deletions docs/build/html/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

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

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Expand All @@ -38,7 +38,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down
6 changes: 3 additions & 3 deletions docs/build/html/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

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

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand All @@ -37,7 +37,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down
Binary file modified docs/build/html/objects.inv
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &mdash; DFO-LS v1.5.2 documentation</title>
<title>Search &mdash; DFO-LS v1.5.3 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand All @@ -37,7 +37,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="#" method="get">
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/searchindex.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/build/html/userguide.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

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

Expand All @@ -15,7 +15,7 @@

<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=73275c37"></script>
<script src="_static/documentation_options.js?v=d75fd82e"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Expand All @@ -38,7 +38,7 @@
DFO-LS
</a>
<div class="version">
1.5.2
1.5.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
Expand Down
2 changes: 2 additions & 0 deletions docs/build/latex/DFOLS.aux
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
\newlabel{history:version-1-5-1-10-oct-2024}{{6.14}{35}{Version 1.5.1 (10 Oct 2024)}{section.6.14}{}}
\@writefile{toc}{\contentsline {section}{\numberline {6.15}Version 1.5.2 (28 Oct 2024)}{35}{section.6.15}\protected@file@percent }
\newlabel{history:version-1-5-2-28-oct-2024}{{6.15}{35}{Version 1.5.2 (28 Oct 2024)}{section.6.15}{}}
\@writefile{toc}{\contentsline {section}{\numberline {6.16}Version 1.5.3 (30 Oct 2024)}{35}{section.6.16}\protected@file@percent }
\newlabel{history:version-1-5-3-30-oct-2024}{{6.16}{35}{Version 1.5.3 (30 Oct 2024)}{section.6.16}{}}
\@writefile{toc}{\contentsline {chapter}{\numberline {7}Contributors}{37}{chapter.7}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
Expand Down
Loading

0 comments on commit 5fdebab

Please sign in to comment.