Skip to content

Commit 3b2309d

Browse files
committed
Add warning when using projections and get model increase in tr subproblem
1 parent 6c7e152 commit 3b2309d

File tree

14 files changed

+83
-71
lines changed

14 files changed

+83
-71
lines changed

dfols/controller.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'EXIT_INPUT_ERROR', 'EXIT_TR_INCREASE_ERROR', 'EXIT_LINALG_ERROR', 'EXIT_FALSE_SUCCESS_WARNING',
4444
'EXIT_AUTO_DETECT_RESTART_WARNING']
4545

46+
EXIT_TR_INCREASE_WARNING = 5 # warning, TR increase in proj constrained case - likely due to multiple active constraints
4647
EXIT_AUTO_DETECT_RESTART_WARNING = 4 # warning, auto-detected restart criteria
4748
EXIT_FALSE_SUCCESS_WARNING = 3 # warning, maximum fake successful steps reached
4849
EXIT_SLOW_WARNING = 2 # warning, maximum number of slow (successful) iterations reached
@@ -70,6 +71,8 @@ def message(self, with_stem=True):
7071
return "Warning (slow progress): " + self.msg
7172
elif self.flag == EXIT_MAXFUN_WARNING:
7273
return "Warning (max evals): " + self.msg
74+
elif self.flag == EXIT_TR_INCREASE_WARNING:
75+
return "Warning (trust region increase): " + self.msg
7376
elif self.flag == EXIT_INPUT_ERROR:
7477
return "Error (bad input): " + self.msg
7578
elif self.flag == EXIT_TR_INCREASE_ERROR:
@@ -82,7 +85,7 @@ def message(self, with_stem=True):
8285
return "Unknown exit flag: " + self.msg
8386

8487
def able_to_do_restart(self):
85-
if self.flag in [EXIT_TR_INCREASE_ERROR, EXIT_LINALG_ERROR, EXIT_SLOW_WARNING, EXIT_AUTO_DETECT_RESTART_WARNING]:
88+
if self.flag in [EXIT_TR_INCREASE_ERROR, EXIT_TR_INCREASE_WARNING, EXIT_LINALG_ERROR, EXIT_SLOW_WARNING, EXIT_AUTO_DETECT_RESTART_WARNING]:
8689
return True
8790
elif self.flag in [EXIT_MAXFUN_WARNING, EXIT_INPUT_ERROR]:
8891
return False
@@ -616,7 +619,10 @@ def calculate_ratio(self, current_iter, rvec_list, d, gopt, H):
616619
if min(sqrt(sumsq(d)), self.delta) > self.rho: # if ||d|| >= rho, successful!
617620
self.last_successful_iter = current_iter
618621
if pred_reduction < 0.0:
619-
exit_info = ExitInformation(EXIT_TR_INCREASE_ERROR, "Trust region step gave model increase")
622+
if len(self.model.projections) > 1: # if we are using multiple projections, only warn since likely due to constraint intersection
623+
exit_info = ExitInformation(EXIT_TR_INCREASE_WARNING, "Either multiple constraints are active or trust region step gave model increase")
624+
else:
625+
exit_info = ExitInformation(EXIT_TR_INCREASE_ERROR, "Either rust region step gave model increase")
620626

621627
ratio = actual_reduction / pred_reduction
622628
return ratio, exit_info
6 Bytes
Binary file not shown.
1.27 KB
Binary file not shown.

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The possible values of :code:`soln.flag` are defined by the following variables:
4848
* :code:`soln.EXIT_MAXFUN_WARNING` - maximum allowed objective evaluations reached. This is the most likely return value when using multiple restarts.
4949
* :code:`soln.EXIT_SLOW_WARNING` - maximum number of slow iterations reached.
5050
* :code:`soln.EXIT_FALSE_SUCCESS_WARNING` - DFO-LS reached the maximum number of restarts which decreased the objective, but to a worse value than was found in a previous run.
51+
* :code:`soln.EXIT_TR_INCREASE_WARNING` - model increase when solving the trust region subproblem with multiple arbitrary constraints.
5152
* :code:`soln.EXIT_INPUT_ERROR` - error in the inputs.
5253
* :code:`soln.EXIT_TR_INCREASE_ERROR` - error occurred when solving the trust region subproblem.
5354
* :code:`soln.EXIT_LINALG_ERROR` - linear algebra error, e.g. the interpolation points produced a singular linear system.
@@ -180,7 +181,7 @@ However, we also get a warning that our starting point was outside of the bounds
180181
181182
DFO-LS automatically fixes this, and moves :math:`x_0` to a point within the bounds, in this case :math:`x_0=(-1.2,0.85)`.
182183

183-
If we want more complex constraints, we can instead write
184+
If we want more complex constraints, we can instead write something like the following:
184185

185186
.. code-block:: python
186187
@@ -198,19 +199,20 @@ If we want more complex constraints, we can instead write
198199
# Call DFO-LS (with box and ball constraints)
199200
soln = dfols.solve(rosenbrock, x0, projections=[pball,pbox])
200201
201-
DFO-LS correctly finds the solution to this constrained problem too:
202+
DFO-LS correctly finds the solution to this constrained problem too. Note that we get a warning because the step computed in the trust region subproblem
203+
gave an increase in the model. This is common in the case where multiple constraints are active at the optimal point.
202204

203205
.. code-block:: none
204-
206+
205207
****** DFO-LS Results ******
206-
Solution xmin = [0.9 1.15358984]
207-
Residual vector = [3.43589838 0.1 ]
208-
Objective value f(xmin) = 11.81539771
208+
Solution xmin = [0.9 1.15359245]
209+
Residual vector = [3.43592448 0.1 ]
210+
Objective value f(xmin) = 11.81557703
209211
Needed 10 objective evaluations (at 10 points)
210212
Approximate Jacobian = [[-1.79826221e+01 1.00004412e+01]
211-
[-1.00000000e+00 6.81262102e-15]]
212-
Exit flag = 0
213-
Success: rho has reached rhoend
213+
[-1.00000000e+00 -1.81976605e-15]]
214+
Exit flag = 5
215+
Warning (trust region increase): Either multiple constraints are active or trust region step gave model increase
214216
****************************
215217
216218

docs/build/html/objects.inv

2 Bytes
Binary file not shown.

docs/build/html/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build/html/userguide.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ <h2>How to use DFO-LS<a class="headerlink" href="#how-to-use-dfo-ls" title="Perm
211211
<li><p><code class="code docutils literal notranslate"><span class="pre">soln.EXIT_MAXFUN_WARNING</span></code> - maximum allowed objective evaluations reached. This is the most likely return value when using multiple restarts.</p></li>
212212
<li><p><code class="code docutils literal notranslate"><span class="pre">soln.EXIT_SLOW_WARNING</span></code> - maximum number of slow iterations reached.</p></li>
213213
<li><p><code class="code docutils literal notranslate"><span class="pre">soln.EXIT_FALSE_SUCCESS_WARNING</span></code> - DFO-LS reached the maximum number of restarts which decreased the objective, but to a worse value than was found in a previous run.</p></li>
214+
<li><p><code class="code docutils literal notranslate"><span class="pre">soln.EXIT_TR_INCREASE_WARNING</span></code> - model increase when solving the trust region subproblem with multiple arbitrary constraints.</p></li>
214215
<li><p><code class="code docutils literal notranslate"><span class="pre">soln.EXIT_INPUT_ERROR</span></code> - error in the inputs.</p></li>
215216
<li><p><code class="code docutils literal notranslate"><span class="pre">soln.EXIT_TR_INCREASE_ERROR</span></code> - error occurred when solving the trust region subproblem.</p></li>
216217
<li><p><code class="code docutils literal notranslate"><span class="pre">soln.EXIT_LINALG_ERROR</span></code> - linear algebra error, e.g. the interpolation points produced a singular linear system.</p></li>
@@ -336,7 +337,7 @@ <h2>Adding Constraints and More Output<a class="headerlink" href="#adding-constr
336337
</div>
337338
</div></blockquote>
338339
<p>DFO-LS automatically fixes this, and moves <span class="math notranslate nohighlight">\(x_0\)</span> to a point within the bounds, in this case <span class="math notranslate nohighlight">\(x_0=(-1.2,0.85)\)</span>.</p>
339-
<p>If we want more complex constraints, we can instead write</p>
340+
<p>If we want more complex constraints, we can instead write something like the following:</p>
340341
<blockquote>
341342
<div><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Define the projection functions</span>
342343
<span class="k">def</span> <span class="nf">pball</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
@@ -354,17 +355,18 @@ <h2>Adding Constraints and More Output<a class="headerlink" href="#adding-constr
354355
</pre></div>
355356
</div>
356357
</div></blockquote>
357-
<p>DFO-LS correctly finds the solution to this constrained problem too:</p>
358+
<p>DFO-LS correctly finds the solution to this constrained problem too. Note that we get a warning because the step computed in the trust region subproblem
359+
gave an increase in the model. This is common in the case where multiple constraints are active at the optimal point.</p>
358360
<blockquote>
359361
<div><div class="highlight-none notranslate"><div class="highlight"><pre><span></span>****** DFO-LS Results ******
360-
Solution xmin = [0.9 1.15358984]
361-
Residual vector = [3.43589838 0.1 ]
362-
Objective value f(xmin) = 11.81539771
362+
Solution xmin = [0.9 1.15359245]
363+
Residual vector = [3.43592448 0.1 ]
364+
Objective value f(xmin) = 11.81557703
363365
Needed 10 objective evaluations (at 10 points)
364366
Approximate Jacobian = [[-1.79826221e+01 1.00004412e+01]
365-
[-1.00000000e+00 6.81262102e-15]]
366-
Exit flag = 0
367-
Success: rho has reached rhoend
367+
[-1.00000000e+00 -1.81976605e-15]]
368+
Exit flag = 5
369+
Warning (trust region increase): Either multiple constraints are active or trust region step gave model increase
368370
****************************
369371
</pre></div>
370372
</div>

docs/build/latex/DFOLS.aux

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
\newlabel{info:parameter-fitting}{{2.2}{5}{Parameter Fitting}{section.2.2}{}}
4747
\@writefile{toc}{\contentsline {section}{\numberline {2.3}Solving Nonlinear Systems of Equations}{6}{section.2.3}\protected@file@percent }
4848
\newlabel{info:solving-nonlinear-systems-of-equations}{{2.3}{6}{Solving Nonlinear Systems of Equations}{section.2.3}{}}
49-
\citation{info:cfmr2018}
49+
\citation{userguide:cfmr2018}
5050
\@writefile{toc}{\contentsline {section}{\numberline {2.4}Details of the DFO\sphinxhyphen {}LS Algorithm}{7}{section.2.4}\protected@file@percent }
5151
\newlabel{info:details-of-the-dfo-ls-algorithm}{{2.4}{7}{Details of the DFO\sphinxhyphen {}LS Algorithm}{section.2.4}{}}
5252
\@writefile{toc}{\contentsline {section}{\numberline {2.5}References}{7}{section.2.5}\protected@file@percent }
5353
\newlabel{info:references}{{2.5}{7}{References}{section.2.5}{}}
54-
\citation{info:cfmr2018}
54+
\citation{userguide:cfmr2018}
5555
\@writefile{toc}{\contentsline {chapter}{\numberline {3}Using DFO\sphinxhyphen {}LS}{9}{chapter.3}\protected@file@percent }
5656
\@writefile{lof}{\addvspace {10\p@ }}
5757
\@writefile{lot}{\addvspace {10\p@ }}
@@ -75,7 +75,7 @@
7575
\newlabel{userguide:example-solving-a-nonlinear-system-of-equations}{{3.8}{18}{Example: Solving a Nonlinear System of Equations}{section.3.8}{}}
7676
\@writefile{toc}{\contentsline {section}{\numberline {3.9}References}{19}{section.3.9}\protected@file@percent }
7777
\newlabel{userguide:references}{{3.9}{19}{References}{section.3.9}{}}
78-
\citation{info:cfmr2018}
78+
\citation{userguide:cfmr2018}
7979
\@writefile{toc}{\contentsline {chapter}{\numberline {4}Advanced Usage}{21}{chapter.4}\protected@file@percent }
8080
\@writefile{lof}{\addvspace {10\p@ }}
8181
\@writefile{lot}{\addvspace {10\p@ }}

docs/build/latex/DFOLS.fdb_latexmk

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Fdb version 3
2-
["makeindex DFOLS.idx"] 1533896586 "DFOLS.idx" "DFOLS.ind" "DFOLS" 1634440875
3-
"DFOLS.idx" 1634440874 0 d41d8cd98f00b204e9800998ecf8427e "pdflatex"
2+
["makeindex DFOLS.idx"] 1533896586 "DFOLS.idx" "DFOLS.ind" "DFOLS" 1635178686
3+
"DFOLS.idx" 1635178685 0 d41d8cd98f00b204e9800998ecf8427e "pdflatex"
44
(generated)
5-
"DFOLS.ind"
65
"DFOLS.ilg"
7-
["pdflatex"] 1634440872 "DFOLS.tex" "DFOLS.pdf" "DFOLS" 1634440875
6+
"DFOLS.ind"
7+
["pdflatex"] 1635178684 "DFOLS.tex" "DFOLS.pdf" "DFOLS" 1635178686
88
"/etc/texmf/web2c/texmf.cnf" 1624242784 475 c0e671620eb5563b2130f56340a5fde8 ""
99
"/usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc" 1165713224 4850 80dc9bab7f31fb78a000ccfed0e27cab ""
1010
"/usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map" 1577235249 3524 cb3e574dea2d1052e39280babc910dc8 ""
@@ -173,22 +173,22 @@
173173
"/usr/share/texmf/web2c/texmf.cnf" 1613593815 38841 799d1dd9682a55ce442e10c99777ecc1 ""
174174
"/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map" 1624243066 5160710 ecf427ae8fa19139d8691f526e47bb9b ""
175175
"/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1624243094 2569235 be2903e90bfe54d2770ce0f508f15937 ""
176-
"DFOLS.aux" 1634440874 14077 a57e9cbc321455cf71aa897afa283d2c "pdflatex"
176+
"DFOLS.aux" 1635178686 14092 9d9d9e97af3301fe1a6671e122c87eb2 "pdflatex"
177177
"DFOLS.ind" 1610358580 0 d41d8cd98f00b204e9800998ecf8427e "makeindex DFOLS.idx"
178-
"DFOLS.out" 1634440874 9566 4c15cb7f3428ba1015be450cf20ae095 "pdflatex"
179-
"DFOLS.tex" 1634440863 88436 83d524cb5461f8777e2e649ff2ddefdb ""
180-
"DFOLS.toc" 1634440874 4715 c361968e0fbff7dd069132047d694ae5 "pdflatex"
178+
"DFOLS.out" 1635178686 9566 4c15cb7f3428ba1015be450cf20ae095 "pdflatex"
179+
"DFOLS.tex" 1635178681 88954 c0e52f684f29b5b7b470a229b4c94cfb ""
180+
"DFOLS.toc" 1635178686 4715 c361968e0fbff7dd069132047d694ae5 "pdflatex"
181181
"data_fitting.png" 1610358580 29893 211bb1c28ea25d47c8c0990fbf39c55c ""
182182
"footnotehyper-sphinx.sty" 1610358580 8888 1bbd7bdeae8c8bed1d10d551bddb1cc9 ""
183183
"sphinx.sty" 1633985769 82020 a38700b8aa22dfd94a8a5b905e69be73 ""
184-
"sphinxhighlight.sty" 1634440869 8137 38a433148fcb7611515a989ff1750dd5 ""
184+
"sphinxhighlight.sty" 1635178681 8137 38a433148fcb7611515a989ff1750dd5 ""
185185
"sphinxmanual.cls" 1610358580 4236 124cd90deb92742b5d3922bfc2cd70c0 ""
186-
"sphinxmessages.sty" 1634440869 745 3f5fcd6cdd7964ed608767954a8ced6f ""
186+
"sphinxmessages.sty" 1635178681 745 3f5fcd6cdd7964ed608767954a8ced6f ""
187187
"sphinxmulticell.sty" 1610358580 14606 0b6edc2b1a83546ed92026d1f6a311b5 ""
188188
(generated)
189-
"DFOLS.aux"
190-
"DFOLS.log"
191189
"DFOLS.idx"
190+
"DFOLS.aux"
192191
"DFOLS.toc"
193192
"DFOLS.pdf"
193+
"DFOLS.log"
194194
"DFOLS.out"

docs/build/latex/DFOLS.log

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.6.21) 16 OCT 2021 23:21
1+
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.6.21) 25 OCT 2021 12:18
22
entering extended mode
33
restricted \write18 enabled.
44
%&-line parsing enabled.
@@ -698,52 +698,48 @@ File: ts1pcr.fd 2001/06/04 font definitions for TS1/pcr.
698698

699699
Package textcomp Warning: Symbol \textasciigrave not provided by
700700
(textcomp) font family pcr in TS1 encoding.
701-
(textcomp) Default family used instead on input line 756.
701+
(textcomp) Default family used instead on input line 760.
702702

703703
LaTeX Font Info: Trying to load font information for T1+cmtt on input line 7
704-
56.
704+
60.
705705
(/usr/share/texlive/texmf-dist/tex/latex/base/t1cmtt.fd
706706
File: t1cmtt.fd 2019/12/16 v2.5j Standard LaTeX font definitions
707707
)
708708
LaTeX Font Info: Trying to load font information for TS1+cmtt on input line
709-
756.
709+
760.
710710

711711
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmtt.fd
712712
File: ts1cmtt.fd 2019/12/16 v2.5j Standard LaTeX font definitions
713713
)
714714

715715
Package textcomp Warning: Symbol \textasciigrave not provided by
716716
(textcomp) font family pcr in TS1 encoding.
717-
(textcomp) Default family used instead on input line 756.
718-
719-
720-
Overfull \vbox (0.68164pt too high) detected at line 784
721-
[]
717+
(textcomp) Default family used instead on input line 760.
722718

723719
[15] [16]
724720
<data_fitting.png, id=424, 524.6802pt x 403.2666pt>
725721
File: data_fitting.png Graphic file (type png)
726722
<use data_fitting.png>
727-
Package pdftex.def Info: data_fitting.png used on input line 857.
723+
Package pdftex.def Info: data_fitting.png used on input line 861.
728724
(pdftex.def) Requested size: 352.31625pt x 270.79639pt.
729725
[17 <./data_fitting.png>] [18] [19] [20
730726

731727
]
732728
Chapter 4.
733729
[21] [22]
734-
Underfull \hbox (badness 10000) in paragraph at lines 1085--1086
730+
Underfull \hbox (badness 10000) in paragraph at lines 1089--1090
735731
[]\T1/pcr/m/n/10 regression.increase_num_extra_steps_with_restart \T1/ptm/m/n/1
736732
0 - The amount to in-crease
737733
[]
738734

739735

740-
Underfull \hbox (badness 10000) in paragraph at lines 1120--1121
736+
Underfull \hbox (badness 10000) in paragraph at lines 1124--1125
741737
[]\T1/pcr/m/n/10 restarts.hard.increase_ndirs_initial_amt \T1/ptm/m/n/10 - Amou
742738
nt to in-crease \T1/pcr/m/n/10 growing.
743739
[]
744740

745741
[23]
746-
Underfull \hbox (badness 8000) in paragraph at lines 1155--1156
742+
Underfull \hbox (badness 8000) in paragraph at lines 1159--1160
747743
\T1/ptm/m/n/10 De-fault is \T1/pcr/m/n/10 False \T1/ptm/m/n/10 if $\OML/cmm/m/i
748744
t/10 m \OMS/cmsy/m/n/10 ^^U \OML/cmm/m/it/10 n$ \T1/ptm/m/n/10 and \T1/pcr/m/n/
749745
10 True \T1/ptm/m/n/10 oth-er-wise (op-po-site to \T1/pcr/m/n/10 growing.full_r
@@ -773,7 +769,7 @@ Package rerunfilecheck Info: File `DFOLS.out' has not changed.
773769
Here is how much of TeX's memory you used:
774770
13946 strings out of 479304
775771
199409 string characters out of 5869779
776-
597748 words of memory out of 5000000
772+
604138 words of memory out of 5000000
777773
30696 multiletter control sequences out of 15000+600000
778774
452760 words of font info for 89 fonts, out of 8000000 for 9000
779775
1142 hyphenation exceptions out of 8191
@@ -799,7 +795,7 @@ exmf-dist/fonts/type1/urw/helvetic/uhvbo8a.pfb></usr/share/texlive/texmf-dist/f
799795
onts/type1/urw/times/utmb8a.pfb></usr/share/texlive/texmf-dist/fonts/type1/urw/
800796
times/utmr8a.pfb></usr/share/texlive/texmf-dist/fonts/type1/urw/times/utmri8a.p
801797
fb>
802-
Output written on DFOLS.pdf (37 pages, 321015 bytes).
798+
Output written on DFOLS.pdf (37 pages, 321478 bytes).
803799
PDF statistics:
804800
616 PDF objects out of 1000 (max. 8388607)
805801
543 compressed objects within 6 object streams

0 commit comments

Comments
 (0)