comparison main/optim/inst/mdsmax.m @ 9930:d30cfca46e8a octave-forge

optim: upgrade license to GPLv3+ and mention on DESCRIPTION the other package licenses
author carandraug
date Fri, 30 Mar 2012 15:14:48 +0000
parents b11b5363d680
children
comparison
equal deleted inserted replaced
9929:df50d0ae107f 9930:d30cfca46e8a
1 function [x, fmax, nf] = mdsmax(fun, x, stopit, savit, varargin) 1 %% Copyright (C) 2002 N.J.Higham
2 %MDSMAX Multidirectional search method for direct search optimization. 2 %% Copyright (C) 2003 Andy Adler <adler@ncf.ca>
3 % [x, fmax, nf] = MDSMAX(FUN, x0, STOPIT, SAVIT) attempts to 3 %%
4 % maximize the function FUN, using the starting vector x0. 4 %% This program is free software; you can redistribute it and/or modify it under
5 % The method of multidirectional search is used. 5 %% the terms of the GNU General Public License as published by the Free Software
6 % Output arguments: 6 %% Foundation; either version 3 of the License, or (at your option) any later
7 % x = vector yielding largest function value found, 7 %% version.
8 % fmax = function value at x, 8 %%
9 % nf = number of function evaluations. 9 %% This program is distributed in the hope that it will be useful, but WITHOUT
10 % The iteration is terminated when either 10 %% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 % - the relative size of the simplex is <= STOPIT(1) 11 %% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 % (default 1e-3), 12 %% details.
13 % - STOPIT(2) function evaluations have been performed 13 %%
14 % (default inf, i.e., no limit), or 14 %% You should have received a copy of the GNU General Public License along with
15 % - a function value equals or exceeds STOPIT(3) 15 %% this program; if not, see <http://www.gnu.org/licenses/>.
16 % (default inf, i.e., no test on function values). 16
17 % The form of the initial simplex is determined by STOPIT(4): 17 %%MDSMAX Multidirectional search method for direct search optimization.
18 % STOPIT(4) = 0: regular simplex (sides of equal length, the default), 18 %% [x, fmax, nf] = MDSMAX(FUN, x0, STOPIT, SAVIT) attempts to
19 % STOPIT(4) = 1: right-angled simplex. 19 %% maximize the function FUN, using the starting vector x0.
20 % Progress of the iteration is not shown if STOPIT(5) = 0 (default 1). 20 %% The method of multidirectional search is used.
21 % If a non-empty fourth parameter string SAVIT is present, then 21 %% Output arguments:
22 % `SAVE SAVIT x fmax nf' is executed after each inner iteration. 22 %% x = vector yielding largest function value found,
23 % NB: x0 can be a matrix. In the output argument, in SAVIT saves, 23 %% fmax = function value at x,
24 % and in function calls, x has the same shape as x0. 24 %% nf = number of function evaluations.
25 % MDSMAX(fun, x0, STOPIT, SAVIT, P1, P2,...) allows additional 25 %% The iteration is terminated when either
26 % arguments to be passed to fun, via feval(fun,x,P1,P2,...). 26 %% - the relative size of the simplex is <= STOPIT(1)
27 27 %% (default 1e-3),
28 % This implementation uses 2n^2 elements of storage (two simplices), where x0 28 %% - STOPIT(2) function evaluations have been performed
29 % is an n-vector. It is based on the algorithm statement in [2, sec.3], 29 %% (default inf, i.e., no limit), or
30 % modified so as to halve the storage (with a slight loss in readability). 30 %% - a function value equals or exceeds STOPIT(3)
31 %% (default inf, i.e., no test on function values).
32 %% The form of the initial simplex is determined by STOPIT(4):
33 %% STOPIT(4) = 0: regular simplex (sides of equal length, the default),
34 %% STOPIT(4) = 1: right-angled simplex.
35 %% Progress of the iteration is not shown if STOPIT(5) = 0 (default 1).
36 %% If a non-empty fourth parameter string SAVIT is present, then
37 %% `SAVE SAVIT x fmax nf' is executed after each inner iteration.
38 %% NB: x0 can be a matrix. In the output argument, in SAVIT saves,
39 %% and in function calls, x has the same shape as x0.
40 %% MDSMAX(fun, x0, STOPIT, SAVIT, P1, P2,...) allows additional
41 %% arguments to be passed to fun, via feval(fun,x,P1,P2,...).
42 %%
43 %% This implementation uses 2n^2 elements of storage (two simplices), where x0
44 %% is an n-vector. It is based on the algorithm statement in [2, sec.3],
45 %% modified so as to halve the storage (with a slight loss in readability).
46 %%
47 %% References:
48 %% [1] V. J. Torczon, Multi-directional search: A direct search algorithm for
49 %% parallel machines, Ph.D. Thesis, Rice University, Houston, Texas, 1989.
50 % [2] V. J. Torczon, On the convergence of the multidirectional search
51 %% algorithm, SIAM J. Optimization, 1 (1991), pp. 123-145.
52 %% [3] N. J. Higham, Optimization by direct search in matrix computations,
53 %% SIAM J. Matrix Anal. Appl, 14(2): 317-333, 1993.
54 %% [4] N. J. Higham, Accuracy and Stability of Numerical Algorithms,
55 %% Second edition, Society for Industrial and Applied Mathematics,
56 %% Philadelphia, PA, 2002; sec. 20.5.
31 57
32 % From Matrix Toolbox 58 % From Matrix Toolbox
33 % Copyright (C) 2002 N.J.Higham 59 % Copyright (C) 2002 N.J.Higham
34 % www.maths.man.ac.uk/~higham/mctoolbox 60 % www.maths.man.ac.uk/~higham/mctoolbox
35 % distributed under the terms of the GNU General Public License
36 %
37 % Modifications for octave by A.Adler 2003 61 % Modifications for octave by A.Adler 2003
38 % $Id$ 62
39 63 function [x, fmax, nf] = mdsmax(fun, x, stopit, savit, varargin)
40 % References:
41 % [1] V. J. Torczon, Multi-directional search: A direct search algorithm for
42 % parallel machines, Ph.D. Thesis, Rice University, Houston, Texas, 1989.
43 % [2] V. J. Torczon, On the convergence of the multidirectional search
44 % algorithm, SIAM J. Optimization, 1 (1991), pp. 123-145.
45 % [3] N. J. Higham, Optimization by direct search in matrix computations,
46 % SIAM J. Matrix Anal. Appl, 14(2): 317-333, 1993.
47 % [4] N. J. Higham, Accuracy and Stability of Numerical Algorithms,
48 % Second edition, Society for Industrial and Applied Mathematics,
49 % Philadelphia, PA, 2002; sec. 20.5.
50 64
51 x0 = x(:); % Work with column vector internally. 65 x0 = x(:); % Work with column vector internally.
52 n = length(x0); 66 n = length(x0);
53 67
54 mu = 2; % Expansion factor. 68 mu = 2; % Expansion factor.