
gr
prefix.
The dimension is determined by the length of the input vector.genTestfn(fname)
fn
the function and gr
its
gradient. If an analytical gradient is not available, a function computing
the gradient numerically will be provided.Rosenbrock -- Rosenbrock's famous valley function from 1960. It can
also be regarded as a least-squares problem:
Nesterov -- Nesterov's smooth adaptation of Rosenbrock, based on the
idea of Chebyshev polynomials. This function is even more difficult to
optimize than Rosenbrock's:
Rastrigin -- Rastrigin's function is a famous, non-convex example from 1989 for global optimization. It is a typical example of a multimodal function with many local minima:
Hald -- Hald's function is a typical example of a non-smooth test
function, from Hald and Madsen in 1981.
Shor -- Shor's function is another typical example of a non-smooth test function, a benchmark for Shor's R-algorithm.
x <- runif(5)
hald <- genTestfn("Hald")
fn <- hald$fn; gr <- hald$gr
fn(x); gr(x)
# How is the Rastrigin function defined?
rast <- genTestfn("rastrigin")
rast$fn
# Compare analytical and numerical gradient
shor <- genTestfn("Shor")
a_gr <- shor$gr
n_gr <- function(x) adagio:::ns.grad(shor$fn, x) # internal gradient
a_gr(x); n_gr(x)
Run the code above in your browser using DataLab