Mercurial > octave
changeset 26138:804e18e3e320
Reenable query of optimization options (bugs #54952 and #55089).
* scripts/optimization/__all_opts__.m: Improve documentation of query mechanism.
* scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m,
scripts/optimization/fminunc.m, scripts/optimization/fsolve.m,
scripts/optimization/fzero.m, scripts/optimization/lsqnonneg.m,
scripts/optimization/pqpnonneg.m, default/scripts/optimization/qp.m:
Return a struct without double-check by optimset. The sanity of the values is
always checked at Octave startup by the PKG_ADD invoked interplay of
"__all_opts__" and "optimset".
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Sun, 25 Nov 2018 15:39:23 +0100 |
parents | 1ae11ca7dceb |
children | 198902f24ef6 |
files | scripts/optimization/__all_opts__.m scripts/optimization/fminbnd.m scripts/optimization/fminsearch.m scripts/optimization/fminunc.m scripts/optimization/fsolve.m scripts/optimization/fzero.m scripts/optimization/lsqnonneg.m scripts/optimization/pqpnonneg.m scripts/optimization/qp.m |
diffstat | 9 files changed, 28 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/optimization/__all_opts__.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/__all_opts__.m Sun Nov 25 15:39:23 2018 +0100 @@ -18,14 +18,16 @@ ## -*- texinfo -*- ## @deftypefn {} {@var{names} =} __all_opts__ (@dots{}) -## Undocumented internal function. -## @end deftypefn - +## Internal function. +## ## Query all options from all known optimization functions and return a ## list of possible values. +## @end deftypefn function names = __all_opts__ (varargin) + ## This variable is filled by the auto-generated PKG_ADD script at + ## Octave startup. persistent saved_names = {}; ## do not clear this function @@ -39,7 +41,7 @@ elseif (nargin == 0) names = saved_names; else - ## query all options from all known functions. These will call optimset, + ## Query all options from all known functions. These will call optimset, ## which will in turn call us, but we won't answer. recursive = true; names = saved_names;
--- a/scripts/optimization/fminbnd.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/fminbnd.m Sun Nov 25 15:39:23 2018 +0100 @@ -85,9 +85,9 @@ ## Get default options if requested. if (nargin == 1 && ischar (fun) && strcmp (fun, "defaults")) - x = optimset ("Display", "notify", "FunValCheck", "off", - "MaxFunEvals", 500, "MaxIter", 500, - "OutputFcn", [], "TolX", 1e-4); + x = struct ("Display", "notify", "FunValCheck", "off", + "MaxFunEvals", 500, "MaxIter", 500, + "OutputFcn", [], "TolX", 1e-4); return; endif
--- a/scripts/optimization/fminsearch.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/fminsearch.m Sun Nov 25 15:39:23 2018 +0100 @@ -128,10 +128,10 @@ ## Get default options if requested. if (nargin == 1 && ischar (varargin{1}) && strcmp (varargin{1}, "defaults")) - x = optimset ("Display", "notify", "FunValCheck", "off", - "MaxFunEvals", [], "MaxIter", [], - "OutputFcn", [], - "TolFun", 1e-4, "TolX", 1e-4); + x = struct ("Display", "notify", "FunValCheck", "off", + "MaxFunEvals", [], "MaxIter", [], + "OutputFcn", [], + "TolFun", 1e-4, "TolX", 1e-4); return; endif
--- a/scripts/optimization/fminunc.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/fminunc.m Sun Nov 25 15:39:23 2018 +0100 @@ -113,10 +113,10 @@ ## Get default options if requested. if (nargin == 1 && strcmp (fcn, "defaults")) - x = optimset ("AutoScaling", "off", "FunValCheck", "off", - "FinDiffType", "forward", "GradObj", "off", - "MaxFunEvals", [], "MaxIter", 400, "OutputFcn", [], - "TolFun", 1e-6, "TolX", 1e-6, "TypicalX", []); + x = struct ("AutoScaling", "off", "FunValCheck", "off", + "FinDiffType", "forward", "GradObj", "off", + "MaxFunEvals", [], "MaxIter", 400, "OutputFcn", [], + "TolFun", 1e-6, "TolX", 1e-6, "TypicalX", []); return; endif
--- a/scripts/optimization/fsolve.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/fsolve.m Sun Nov 25 15:39:23 2018 +0100 @@ -172,11 +172,11 @@ ## Get default options if requested. if (nargin == 1 && ischar (fcn) && strcmp (fcn, "defaults")) - x = optimset ("AutoScaling", "off", "ComplexEqn", "off", - "FunValCheck", "off", "FinDiffType", "forward", - "Jacobian", "off", "MaxFunEvals", [], "MaxIter", 400, - "OutputFcn", [], "Updating", "off", "TolFun", 1e-6, - "TolX", 1e-6, "TypicalX", []); + x = struct ("AutoScaling", "off", "ComplexEqn", "off", + "FunValCheck", "off", "FinDiffType", "forward", + "Jacobian", "off", "MaxFunEvals", [], "MaxIter", 400, + "OutputFcn", [], "Updating", "off", "TolFun", 1e-6, + "TolX", 1e-6, "TypicalX", []); return; endif
--- a/scripts/optimization/fzero.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/fzero.m Sun Nov 25 15:39:23 2018 +0100 @@ -123,9 +123,9 @@ ## Get default options if requested. if (nargin == 1 && ischar (fun) && strcmp (fun, "defaults")) - x = optimset ("Display", "notify", "FunValCheck", "off", - "MaxFunEvals", Inf, "MaxIter", Inf, - "OutputFcn", [], "TolX", eps); + x = struct ("Display", "notify", "FunValCheck", "off", + "MaxFunEvals", Inf, "MaxIter", Inf, + "OutputFcn", [], "TolX", eps); return; endif
--- a/scripts/optimization/lsqnonneg.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/lsqnonneg.m Sun Nov 25 15:39:23 2018 +0100 @@ -82,7 +82,7 @@ ## Special case: called to find default optimization options if (nargin == 1 && ischar (c) && strcmp (c, "defaults")) - x = optimset ("MaxIter", 1e5); + x = struct ("MaxIter", 1e5); return; endif
--- a/scripts/optimization/pqpnonneg.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/pqpnonneg.m Sun Nov 25 15:39:23 2018 +0100 @@ -84,7 +84,7 @@ ## Special case: called to find default optimization options if (nargin == 1 && ischar (c) && strcmp (c, "defaults")) - x = optimset ("MaxIter", 1e5); + x = struct ("MaxIter", 1e5); return; endif
--- a/scripts/optimization/qp.m Sun Nov 25 21:15:51 2018 -0800 +++ b/scripts/optimization/qp.m Sun Nov 25 15:39:23 2018 +0100 @@ -120,7 +120,7 @@ function [x, obj, INFO, lambda] = qp (x0, H, varargin) if (nargin == 1 && ischar (x0) && strcmp (x0, "defaults")) - x = optimset ("MaxIter", 200); + x = struct ("MaxIter", 200); return; endif