### 1.8 A multidirectional search algorithm

#### Helptext:

    MDSMAX  Multidirectional search method for direct search optimization.
           [x, fmax, nf] = MDSMAX(FUN, x0, STOPIT, SAVIT) attempts to
           maximize the function FUN, using the starting vector x0.
           The method of multidirectional search is used.
           Output arguments:
                  x    = vector yielding largest function value found,
                  fmax = function value at x,
                  nf   = number of function evaluations.
           The iteration is terminated when either
                  - the relative size of the simplex is <= STOPIT(1)
                    (default 1e-3),
                  - STOPIT(2) function evaluations have been performed
                    (default inf, i.e., no limit), or
                  - a function value equals or exceeds STOPIT(3)
                    (default inf, i.e., no test on function values).
           The form of the initial simplex is determined by STOPIT(4):
             STOPIT(4) = 0: regular simplex (sides of equal length, the default),
             STOPIT(4) = 1: right-angled simplex.
           Progress of the iteration is not shown if STOPIT(5) = 0 (default 1).
           If a non-empty fourth parameter string SAVIT is present, then
           `SAVE SAVIT x fmax nf' is executed after each inner iteration.
           NB: x0 can be a matrix.  In the output argument, in SAVIT saves,
               and in function calls, x has the same shape as x0.
           MDSMAX(fun, x0, STOPIT, SAVIT, P1, P2,...) allows additional
           arguments to be passed to fun, via feval(fun,x,P1,P2,...).

    This implementation uses 2n^2 elements of storage (two simplices), where x0
    is an n-vector.  It is based on the algorithm statement in [2, sec.3],
    modified so as to halve the storage (with a slight loss in readability).

    References:
    [1] V. J. Torczon, Multi-directional search: A direct search algorithm for
        parallel machines, Ph.D. Thesis, Rice University, Houston, Texas, 1989.
    [2] V. J. Torczon, On the convergence of the multidirectional search
        algorithm, SIAM J. Optimization, 1 (1991), pp. 123-145.
    [3] N. J. Higham, Optimization by direct search in matrix computations,
        SIAM J. Matrix Anal. Appl, 14(2): 317-333, 1993.
    [4] N. J. Higham, Accuracy and Stability of Numerical Algorithms,
           Second edition, Society for Industrial and Applied Mathematics,
           Philadelphia, PA, 2002; sec. 20.5.