Description Usage Arguments Value Author(s) References See Also Examples
Intended for nonconvex functions that are continuous everywhere and for which the gradient can be computed at most points, but which are known to be nondifferentiable at some points, typically including minimizers.
1 2 3 4 5 6 |
fn |
A function to be minimized. fn(x) takes input as a vector of parameters over which minimization is to take place. fn() returns a scaler. |
gr |
A function to return the gradient for fn(x). |
nvar |
Number of parameters that fn() takes. |
x0 |
Initial guess of x. |
upper |
upper bound for the initial value |
lower |
lower bound for the initial value |
f0 |
fn(x0). Optional, is taken as input to reduce computation. |
g0 |
gr(x0). Optional, is taken as input to reduce computation. |
samprad |
vector of sampling radii. |
maxit |
number of maximum iterations |
normtol |
stopping tolerance for norm(d) |
ngrad |
number of sampled gradients per iterate. |
fvalquit |
quit, if f reaches this value. |
prtlevel |
prints messages if this is 1 |
Returns a list containing the following fields:
x |
a matrix with k'th column containing final value of x obtained from k'th column of x0. |
f |
a vector of final obtained minimum values of fn() at the initial points. |
g |
matrix with k'th column as the gradient of fn at x[,k] |
dnorm |
dnorm(k) is the norm of a vector in the convex hull of gradients of the function evaluated at points near x(:,k) |
X |
a list containing points where gradients were evalueated |
G |
a list with gradients of correspoding elements from X |
w |
vectors of weights needed for dnorm |
message |
any warnings / use it to know about termination condition |
Copyright (c) 2010 Michael Overton for Matlab code and documentation, with permission converted to R by Abhirup Mallik (and Hans W Borchers).
J.V. Burke, A.S. Lewis and M.L. Overton, A Robust Gradient Sampling Algorithm for Nonsmooth, Nonconvex Optimization SIAM J. Optimization, 2005
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 | fr <- function(x) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
grr <- function(x) { ## Gradient of 'fr'
x1 <- x[1]
x2 <- x[2]
c(-400 * x1 * (x2 - x1 * x1) - 2 * (1 - x1),
200 * (x2 - x1 * x1))
}
#x0 <- matrix(rnorm(12),2,6)
x0 <- c(1.2,1)
tmp <- gradsamp(fr,grr,x0=x0,maxit=100)
tmp
#using Nesterov's function
# example not run
#fnNesterov1 <- function(x) {
# n <- length(x)
# x2 <- x[2:n]; x1 <- x[1:(n-1)]
# 1/4*(x[1]-1)^2 + sum(abs(x2-2*x1^2+1))
#}
#res=gradsamp(fnNesterov1,nvar=2,rep(1,2),maxit=10)
#res
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.