funcheck: Run tests, where possible, on functions to be optimized

Description Usage Arguments Details Value Note Author(s) Examples

Description

There are two functions provided, funcheck and funtest.

funcheck works on a source code file containing several functions with a common root to their name. Thus, a file 'hobbs.R' may contain code for several functions:

hobbs.f

the objective function to be minimized or maximized. This takes as arguments a vector of parameters and local variables specified via the "..." inputs.

hobbs.g

the gradient of that function

hobbs.h

the hessian of that funciton

hobbs.res

if hobbs.f is formed as a sum of squares, then this function returns a vector of residuals such that the sum of their squares is the function value

hobbs.jac

to compute the Jacobian of the residuals above

hobbs.rsd

to compute the second derivatives of the residuals above

hobbs.setup

to provide starting values and bounds for the functions above

For funtest, the functions are specified explicitly.

Usage

1
2
funcheck(xpar, fname, lower=NULL, upper=NULL, cctrl=list(trace=1), ... )
funtest(xpar, fn, gr=NULL, hess=NULL, res=NULL, jac=NULL, rsd=NULL, lower=NULL, upper=NULL, cctrl=list(trace=1), ... )

Arguments

xpar

a matrix with rows each being a vector giving the numerical values of an initial point where the function should be tested.

fname

the base name (as a character string) of a file of type .R that contains functions fname.f to compute the scalar objective function value at a given set of parameters in the vector x, where x is of length n, with (optionally) fname.g for the gradient, fname.res for residuals in the case that the scalar objective function is a sum of m squared elements, fname.jac for the Jacobian of these residuals, fname.setup to set up the xset, as well as lower and upper bounds and the bounds and masks indicator (integer) vector bdmsk, and fname.h for the Hessian.

fn

explicit name for the objective function

gr

explicit name for the gradient function

hess

explicit name for the Hessian function

res

explicit name for the residual function

jac

explicit name for the Jacobian function

rsd

explicit name for the residual second derivative function

lower

a matrix whose rows are sets of lower bounds on the parameters to the function

upper

a matrix whose rows are sets of upper bounds on the parameters to the function

cctrl

list of control parameters.
There are two elements currently:
trace: set >0 to provide output from funcheck to the console, 0 otherwise

...

optional arguments passed to the objective function.

Details

Package: funcheck
Depends: R (>= 2.6.1)
License: GPL Version 2.

Algorithm

funcheck assumes that the user supplies functions in the file fname.R that is accessible from the global environment.

funtest assumes that the functions called are already in the current environment.

Value

A list of lists, one list for each set of parameters (each row) of xset. Each sublist has the following components:

fname

The name of the test function file.

ipoint

An index counter for the test points.

par

The numerical values of the n elements of the supplied parameters..

lower

Lower bounds for the parameters in this case.

upper

Lower bounds for the parameters in this case.

bstate

A character vector telling whether each parameter is Out of Bounds Low, In Bounds, or Out of Bounds High.

grd

The max. abs. relative difference with denominator augmented by 10. for the gradient.

Jrd

The max. abs. relative difference with denominator augmented by 10. for the Jacobian.

jsdrd

The max. abs. relative difference with denominator augmented by 10. for the Jacobian second derivatives.

Hrd

The max. abs. relative difference with denominator augmented by 10. for the Hessian.

Note

These versions of funcheck and funtest are not optimized.

The following code must be stored in file tryfun.R and available to the tests. ??how?? ??where??

Author(s)

John C. Nash

Examples

1
2
3
## the file tryfun.R must be available in the current directory
#don't execute --   ans<-funcheck(xpar = rep(10.0,10), fname="tryfun") 
# The above example is in the tests

funcheck documentation built on May 2, 2019, 4:13 p.m.

Related to funcheck in funcheck...