Skip to content

Commit

Permalink
reconfigure build system
Browse files Browse the repository at this point in the history
  • Loading branch information
kingaa committed Sep 22, 2018
1 parent 911bc60 commit c2e2a4c
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 96 deletions.
8 changes: 6 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: subplex
Version: 1.5-6
Date: 2018-09-21
Date: 2018-09-22
Title: Unconstrained Optimization using the Subplex Algorithm
Authors@R: c(person(given=c("Aaron","A."),family="King",
role=c("aut","trl","cre"),email="kingaa@umich.edu"),
Expand All @@ -10,4 +10,8 @@ Depends: R(>= 2.5.1)
URL: https://github.com/kingaa/subplex/
BugReports: https://github.com/kingaa/subplex/issues/
Description: The subplex algorithm for unconstrained optimization, developed by Tom Rowan <http://www.netlib.org/opt/subplex.tgz>.

Encoding: UTF-8
RoxygenNote: 6.1.0
Collate:
'subplex-package.R'
'subplex.R'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ INSTALL = install
PKG = $(shell perl -ne 'print $$1 if /Package:\s+((\w+[-\.]?)+)/;' DESCRIPTION)
VERSION = $(shell perl -ne 'print $$1 if /Version:\s+((\d+[-\.]?)+)/;' DESCRIPTION)
PKGVERS = $(PKG)_$(VERSION)
SOURCE=$(shell ls R/*R src/* man/*Rd data/* tests/*R)
SOURCE=$(shell ls R/*R src/* man/*Rd tests/*R)

default:
@echo $(PKGVERS)
Expand Down
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
useDynLib(subplex,.registration=TRUE)
# Generated by roxygen2: do not edit by hand

export(subplex)
useDynLib(subplex, .registration = TRUE)
30 changes: 30 additions & 0 deletions R/subplex-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
##' Subplex unconstrained optimization algorithm
##'
##' The \pkg{subplex} package implements Tom Rowan's subspace-searching simplex
##' algorithm for unconstrained minimization of a function.
##'
##' Subplex is a subspace-searching simplex method for the unconstrained
##' optimization of general multivariate functions. Like the Nelder-Mead simplex
##' method it generalizes, the subplex method is well suited for optimizing
##' noisy objective functions. The number of function evaluations required for
##' convergence typically increases only linearly with the problem size, so for
##' most applications the subplex method is much more efficient than the simplex
##' method.
##'
##' Subplex was written in FORTRAN by Tom Rowan (Oak Ridge National Laboratory).
##' The FORTRAN source code is maintained on the netlib repository (netlib.org).
##'
##' @name subplex-package
##' @docType package
##' @author Aaron A. King (kingaa at umich dot edu)
##' @seealso \code{\link{subplex}}, \code{\link{optim}}
##' @references T. Rowan, "Functional Stability Analysis of Numerical
##' Algorithms", Ph.D. thesis, Department of Computer Sciences, University of
##' Texas at Austin, 1990.
##' @keywords optimize
##' @useDynLib subplex, .registration = TRUE
##'
NULL



88 changes: 83 additions & 5 deletions R/subplex.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,88 @@
##' Minimization of a function by the subplex algorithm
##'
##' \code{subplex} minimizes a function.
##'
##' The convergence codes are as follows: \describe{ \item{-2}{invalid input}
##' \item{-1}{number of function evaluations needed exceeds \code{maxnfe}}
##' \item{0}{success: tolerance \code{tol} satisfied} \item{1}{limit of machine
##' precision reached} }
##'
##' For more details, see the source code.
##'
##' @name subplex
##' @rdname subplex
##' @include subplex-package.R
##'
##' @param par Initial guess of the parameters to be optimized over.
##' @param 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.
##' @param control A list of control parameters, consisting of some or all of
##' the following: \describe{ \item{reltol}{ The relative optimization tolerance
##' for \code{par}. This must be a positive number. The default value is
##' \code{.Machine$double.eps}. } \item{maxit}{ Maximum number of function
##' evaluations to perform before giving up. The default value is \code{10000}.
##' } \item{parscale}{ The scale and initial stepsizes for the components of
##' \code{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 \code{par}. For \code{parscale} to be valid, it must not be too small
##' relative to \code{par}: if \code{par + parscale = par} in any component,
##' \code{parscale} is too small. The default value is \code{1}. } }
##' @param hessian If \code{hessian=TRUE}, the Hessian of the objective at the
##' estimated optimum will be numerically computed.
##' @param \dots Additional arguments to be passed to the function \code{fn}.
##' @return \code{subplex} returns a list containing the following:
##' \item{par}{Estimated parameters that minimize the function.}
##' \item{value}{Minimized value of the function.} \item{count}{Number of
##' function evaluations required.} \item{convergence}{Convergence code (see
##' Details).} \item{message}{ A character string giving a diagnostic message
##' from the optimizer, or 'NULL'. } \item{hessian}{Hessian matrix.}
##' @author Aaron A. King \email{kingaa@@umich.edu}
##' @seealso \code{\link{optim}}
##' @references T. Rowan, ``Functional Stability Analysis of Numerical
##' Algorithms'', Ph.D. thesis, Department of Computer Sciences, University of
##' Texas at Austin, 1990.
##' @keywords optimize
##' @examples
##'
##' 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))
##' ## compare with optim:
##' optim(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)
##'
##' @export subplex
subplex <- function (par, fn, control = list(), hessian = FALSE, ...) {
## set default control parameters
## set default control parameters
con <- list(
reltol = .Machine$double.eps,
maxit = 10000,
parscale = 1
)
reltol = .Machine$double.eps,
maxit = 10000,
parscale = 1
)
namc <- names(control)[names(control)%in%names(con)]
con[namc] <- control[namc]
fn <- match.fun(fn)
Expand Down
46 changes: 27 additions & 19 deletions man/subplex-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 52 additions & 67 deletions man/subplex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion subplex.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageInstallArgs: --no-multiarch --with-keep.source --library=~/library
PackageBuildArgs: --force --no-manual --resave-data --compact-vignettes=both --md5
PackageBuildBinaryArgs: --library=~/library
PackageRoxygenize: rd,collate,namespace

0 comments on commit c2e2a4c

Please sign in to comment.