subplex: Minimization of a function by the subplex algorithm

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

subplex minimizes a function.

Usage

1
subplex(par, fn, control = list(), hessian = FALSE, ...)

Arguments

par

Initial guess of the parameters to be optimized over.

fn

The function to be minimized. Its first argument must be the vector of parameters to be optimized over. It should return a scalar result.

control

A list of control parameters, consisting of some or all of the following:

reltol

The relative optimization tolerance for par. This must be a positive number. The default value is .Machine$double.eps.

maxit

Maximum number of function evaluations to perform before giving up. The default value is 10000.

parscale

The scale and initial stepsizes for the components of par. This must either be a single scalar, in which case the same scale is used for all parameters, or a vector of length equal to the length of par. The default value is 1.

hessian

If hessian=TRUE, the Hessian of the objective at the estimated optimum will be numerically computed.

...

Additional arguments to be passed to the function fn.

Details

The convergence codes are as follows:

-2

invalid input

-1

number of function evaluations needed exceeds maxnfe

0

success: tolerance tol satisfied

1

limit of machine precision reached

2

fstop reached. Currently, the option to use fstop is not implemented.

For more details, see the source code.

Value

subplex returns a list containing the following:

par

Estimated parameters that minimize the function.

value

Minimized value of the function.

count

Number of function evaluations required.

convergence

Convergence code (see Details).

message

A character string giving a diagnostic message from the optimizer, or 'NULL'.

hessian

Hessian matrix.

Author(s)

Aaron A. King kingaa@umich.edu

References

T. Rowan, “Functional Stability Analysis of Numerical Algorithms”, Ph.D. thesis, Department of Computer Sciences, University of Texas at Austin, 1990.

See Also

optim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
rosen <- function (x) {   ## Rosenbrock Banana function
  x1 <- x[1]
  x2 <- x[2]
  100*(x2-x1*x1)^2+(1-x1)^2
}
subplex(par=c(11,-33),fn=rosen)

rosen2 <- function (x) {
  X <- matrix(x,ncol=2) 
  sum(apply(X,1,rosen))
}
subplex(par=c(-33,11,14,9,0,12),fn=rosen2,control=list(maxit=30000))

ripple <- function (x) {
  r <- sqrt(sum(x^2))
  1-exp(-r^2)*cos(10*r)^2
}
subplex(par=c(1),fn=ripple,hessian=TRUE)
subplex(par=c(0.1,3),fn=ripple,hessian=TRUE)
subplex(par=c(0.1,3,2),fn=ripple,hessian=TRUE)

rosen <- function (x, g = 0, h = 0) {   ## Rosenbrock Banana function (using names)
  x1 <- x['a']
  x2 <- x['b']-h
  100*(x2-x1*x1)^2+(1-x1)^2+g
}
subplex(par=c(b=11,a=-33),fn=rosen,h=22,control=list(abstol=1e-9,parscale=5),hessian=TRUE)

Example output

$par
[1] 1 1

$value
[1] 9.034923e-28

$counts
[1] 659

$convergence
[1] 0

$message
NULL

$hessian
NULL

$par
[1] 1 1 1 1 1 1

$value
[1] 1.434691e-27

$counts
[1] 23697

$convergence
[1] 1

$message
[1] "limit of machine precision reached"

$hessian
NULL

$par
[1] 0

$value
[1] 0

$counts
[1] 157

$convergence
[1] 0

$message
NULL

$hessian
     [,1]
[1,]  202

$par
[1] -7.334164e-10  3.492460e-10

$value
[1] 0

$counts
[1] 323

$convergence
[1] 0

$message
NULL

$hessian
              [,1]          [,2]
[1,]  2.020000e+02 -1.513864e-06
[2,] -1.513864e-06  2.020000e+02

$par
[1] 0.4593216 1.1039981 0.3440788

$value
[1] 0.7906068

$counts
[1] 435

$convergence
[1] 0

$message
NULL

$hessian
          [,1]     [,2]      [,3]
[1,]  5.852392 14.06646  4.384038
[2,] 14.066459 33.80930 10.537214
[3,]  4.384038 10.53721  3.284092

$par
 b  a 
23  1 

$value
[1] 6.660402e-27

$counts
[1] 557

$convergence
[1] 1

$message
[1] "limit of machine precision reached"

$hessian
     b    a
b  200 -400
a -400  802

subplex documentation built on May 2, 2019, 5:23 p.m.