Next: moorepenrose() Up: Mathematical Macros Help File Previous: matsqrt()   Contents


minimizer(x0, fun [,params:params] [, method:M] [, goldsteps:ngold] \
  [, maxit:maxiter] [,minit:miniter] [,criteria:vector(nsigx, \
  nsigfun,dgrad)] [printwhen:d1] [,recordwhen:d2]), REAL vector x0,
  macro fun(x,i [,params]), CHARACTER scalar M (one of "bfs", "dfp",
  "broyden", integers ngold > 0, maxiter >= 0, miniter > 0, nsigx,
  nsigfun, d1 >= 0, d2 >= 0, dgrad REAL scalar

Keywords: minimize
Macro minimizer() uses a quasi-Newton variable metric algorithm to
minimize a function iteratively.  There is a choice of three methods,
Broyden-Fletcher-Shanno (method:"bfs"), Davidon-Fletcher-Powell
(method:"dfp") and Broyden's (method:"broyden").  For the first two a
golden mean line search is made at each step.  See Dahlquist and
Bjorck, Numerical methods, Prentice Hall, 1974, p. 441-444.

result <- minimizer(x0, fun [, params] [,optional keywords]) computes
the minimum of a real function F(x1,x2,...,xk) starting iteration at x
= x0 = vector(x01,x02,...,x0k), a REAL vector with no MISSING elements.
The Broyden-Fletcher-Shanno updating is used by default.

result <- minimizer(x0, fun [, params] , method:M [,optional
keywords]), where M is one of "bfs", "dfp", or "broyden", does the
same, using the Broyden-Fletcher-Shanno, Davidon-Fletcher-Powell or
Broyden update methods.

Optional argument params is a variable, possibly a structure, with
additional constant information used to compute F(x) and its gradient

fun is a macro such that fun(x,0 [,params]) returns F(x[1],x[2],
...,x[k]) and fun(x,1 [,params]) returns a length k REAL gradient
vector (vector of partial derivatives of F(x) with respect to the
elements of x).  fun() should ignore its third argument if not needed.

fun(x,-1 [,params]) should carry out any initialization needed.  If
starting values or elements of param are not appropriate, fun(x, -1,
[params]) should return MISSING.  Otherwise, any non-MISSING value
should be returned.

fun() can use either a formula for derivatives, when one is known, or
compute them by numerical differentiation.

result is structure(x:xmin, f:minVal, gradient:gradient, h:invhessian,
iterations:niter, status:N) where xmin is a REAL vector such that
minVal = F(xmin) is a local minimum, gradient is the length k gradient
vector at xmin, invhessian is a k by k approximation to the inverse of
the Hessian matrix (matrix of second order derivatives of F), niter is
the number of iterations taken and N is an integer indicating
convergence status; see below.

Optional keyword phrase criterion:vector(nsigx, nsigfun, dgrad) allows
control over how convergence is determined.  nsigx and nsigfun must be
integers and dgrad a small REAL scalar.  At least one of nsigx,
nsigfun and dgrad must be positive.  A value <= 0 is ignored.

Iteration ends when any of the following occurs
 1.  nsigx > 0 and all elements of x have relative change <=
 10^-nsigx.  For any x[i] with abs(x[i]) < .5, change is relative to

  2.  nsigfun > 0 and relative change in F(x) <= 10^-nsigfun.  When
  abs(f(x)) < .5, change is relative to .5.

  3.  dgrad > 0 and ||gradient|| < dgrad

The default value for 'criterion' is vector(8,5,-1).

Keyword phrases minit:miniter and maxit:maxiter specify no check for
convergence is made until iteration miniter and no more than maxiter
iterations will be done.  miniter >= 0 (default 0) and maxiter > 0
(default 30) are integers.

When N = 0 (value of component 'status' of the result), no convergence
criterion was satisfied.

When N < 0, iteration was terminated because an illegal value was

When N = 1 iteration ended by test using nsigx.

When N = 2 iteration ended by test using nsigfun.

When N = 3, iteration ended by test using dgrad.

  Cmd> result <- minimizer(x0, fun ..., maxit:n)

You can restart the iteration where it stopped by
  Cmd> result <- minimizer(result$x, fun, ..., h:result$h)

There other optional keyword phrases that can be arguments.

  h:invhessian      invhessian is a k by k REAL symmetric matrix
                    (default dmat(k,1)) used as starting approximation
                    to inverse Hessian matrix
  goldsteps:m       integer m >= 0 (default 5), the number of cycles
                    to be used in the golden mean linear search; with
                    m == 0 no linear search is done; ignored with
  printwhen:d1      Integer d1 >= 0.  When d1 > 0, current values of x,
                    F(x), and the gradient are printed on iterations
                    d1, 2*d1, 3*d1, ...
  recordwhen:d2     Integer d2 >= 0.  When d2 > 0, current values of
                    x, F(x) and the gradient on saved in components
                    'xvalx', 'funvals' and 'gradients' of side-
                    effect structure BFSRECORD, DJPRECORD or
                    BROYDNRECORD, depending on the method used.

See also bfs(), dfp(), broyden(), and neldermead()

Gary Oehlert 2003-01-15