1 ## Copyright (C) 2002 Etienne Grossmann <etienne@egdn.net>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
16 ## opt = optimset_compat (...) - manipulate m*tlab-style options structure
18 ## This function returns a m*tlab-style options structure that can be used
19 ## with the fminunc() function. 'optimset_compat' has been deprecated in
20 ## favor of 'optimset', which is now part of core Octave. This function
21 ## will possibly be removed from future versions of the 'optim' package.
23 ## INPUT : Input consist in one or more structs followed by option-value
24 ## pairs. The option that can be passed are those of m*tlab's 'optimset'.
25 ## Whether fminunc() accepts them is another question (see fminunc()).
27 ## Two extra options are supported which indicate how to use directly octave
28 ## optimization tools (such as minimize() and other backends):
30 ## "MinEquiv", [on|off] : Tell 'fminunc()' not to minimize 'fun', but
31 ## instead return the option passed to minimize().
33 ## "Backend", [on|off] : Tell 'fminunc()' not to minimize 'fun', but
34 ## instead return the [backend, opt], the name of the
35 ## backend optimization function that is used and the
36 ## optional arguments that will be passed to it. See
37 ## the 'backend' option of minimize().
39 function opt = optimset_compat (varargin)
41 ## Diagnostics , ["on"|{"off"}] :
42 ## DiffMaxChange, [scalar>0] : N/A (I don't know what it does)
43 ## DiffMinChange, [scalar>0] : N/A (I don't know what it does)
44 ## Display , ["off","iter","notify","final"]
47 persistent warned = false;
50 warning ("Octave:deprecated-function",
51 "`optimset_compat' has been deprecated, and will be removed in the future. Use `optimset' from Octave core instead.");
58 # Integrate all leading structs
60 while length (args) && isstruct (o = args{1})
62 args = args(2:length(args)); # Remove 1st element of args
64 for [v,k] = o, opt = setfield (opt,k,v); end
68 op1 = [" DerivativeCheck Diagnostics DiffMaxChange DiffMinChange",\
69 " Display GoalsExactAchieve GradConstr GradObj Hessian HessMult",\
70 " HessPattern HessUpdate Jacobian JacobMult JacobPattern",\
71 " LargeScale LevenbergMarquardt LineSearchType MaxFunEvals MaxIter",\
72 " MaxPCGIter MeritFunction MinAbsMax PrecondBandWidth TolCon",\
73 " TolFun TolPCG TolX TypicalX ",\
74 " MinEquiv Backend "];
76 opt = read_options (args, "op1",op1, "default",opt,"prefix",1,"nocase",1);