annotate scripts/optimization/__all_opts__.m @ 8647:06f5dd901f30

implement registering of optimization options
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 30 Jan 2009 21:24:29 +0100
parents
children b93f17317ca3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8647
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
1 ## Copyright (C) 2009 VZLU Prague
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2 ##
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
3 ## This file is part of Octave.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
4 ##
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 ## your option) any later version.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 ##
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 ## General Public License for more details.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
14 ##
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19 ## -*- texinfo -*-
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20 ## @deftypefn {Function File} {} __all_opts__ ()
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21 ## internal function. Queries all options from all known optimization
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22 ## functions and returns a list of possible values.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
23 ## @end deftypefn
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
24
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25 function names = __all_opts__ (varargin)
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27 persistent saved_names = {};
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29 ## guard against recursive calls.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
30 persistent recursive = false;
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 if (nargin == 0)
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 names = saved_names;
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34 else
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 ## query all options from all known functions. These will call optimset,
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36 ## which will in turn call us, but we won't answer.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 names = saved_names;
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38 for i = 1:nargin
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39 try
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
40 opts = optimset (varargin{i});
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
41 fn = fieldnames (opts).';
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
42 names = [names, fn];
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43 catch
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44 # throw the error as a warning.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45 warning (lasterr ());
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 end_try_catch
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47 endfor
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
48 names = unique (names);
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
49 lnames = unique (tolower (names));
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 if (length (lnames) < length (names))
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51 ## This is bad.
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 error ("__all_opts__: duplicate options with inconsistent case.");
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53 endif
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 saved_names = names;
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55 endif
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57 endfunction
06f5dd901f30 implement registering of optimization options
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
58