tao: R bindings for the TAO optimization library.

Description Usage Arguments Value Examples

Description

Various optimization routines from the TAO optimization library. See the TAO documentation for a complete listing.

Usage

1
2
3
tao(par, fn, gr = NULL, hs = NULL, method = c("lmvm", "nls", "ntr", "ntl",
  "cg", "tron", "blmvm", "gpcg", "nm", "pounders"), control = list(),
  n = NULL, lb = NULL, ub = NULL)

Arguments

par

Initial values for the parameters to be optimized over.

fn

A function to be minimized (or maximized), with first argument the vector of parameters over which minimization is to take place. It should return a scalar result.

gr

A function to return the gradient, if using a gradient-based optimization method.

hs

A function to return the hessian, if using an algorithm which uses the hessian.

method

The method to be used. See 'Details'.

control

A list of control parameters. See 'Details'.

n

The number of elements of objfun (optional).

lb

A vector with lower variable bounds (optional)

ub

A vector with upper variable bounds (optional)

Value

A list with final parameter values, the objective function, and information on why the optimizer stopped.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
# Gradient-free method
objfun = function(x) c((x[1] - 3), (x[2] + 1))
ret = tao(c(1, 2), 
                objfun,
                method = "pounders",
                control = list(tao_pounders_delta=0.1))
ret$x

# Gradient-based method: Limited memory variable metric method
objfun = function(x) (x[1] - 3)^2 + (x[2] + 1)^2
grafun = function(x) c(2*(x[1] - 3), 2*(x[2] + 1))
    
ret = tao(c(1, 2), 
                objfun,
                gr = grafun,
                method = "lmvm")
ret$x

# Gradient-based method: Limited memory variable metric method with bounds
objfun = function(x) (x[1] - 3)^2 + (x[2] + 1)^2
grafun = function(x) c(2*(x[1] - 3), 2*(x[2] + 1))
inequal = function(x) c(x[1] - 2, x[2] - 2)
    
ret = tao(c(1, 2), 
                objfun,
                gr = grafun,
                method = "blmvm")
ret$x

# Hessian (Newton Trust Region)
objfun = function(x) (x[1] - 3)^2 + (x[2] + 1)^2
grafun = function(x) c(2*(x[1] - 3), 2*(x[2] + 1))
hesfun = function(x) matrix(c(2, 0, 0, 2), nrow = 2, ncol = 2)
    
ret = tao(c(1, 2), 
                objfun,
                gr = grafun,
                hs = hesfun,
                method = "ntr")
ret$x

jtilly/taoR documentation built on May 20, 2019, 3:13 a.m.