Description Usage Arguments Examples
View source: R/lineSearch_APA.R
line searching algorithm used inside APA optimization algorithms.
1 2 3 4 5 6 7 8 9 10 | lineSearch_APA(
x_curr,
dk,
func,
grad_Fx = NULL,
precBits = 64,
stepMod = 0,
lineSearchMaxSteps = 100,
...
)
|
x_curr |
starting x value |
dk |
direction vector to search along |
func |
function to perform line search on |
grad_Fx |
(defaults to NULL) if not NULL, the gradient of func at x_curr |
precBits |
bits of precision |
lineSearchMaxSteps |
(defaults to 100) maximum number of iterations before stopping |
... |
extra parameters passed on to func |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # simple 1D quadratic function optimization
lineSearch_APA(x_curr = 1, dk = -0.2, lineSearchMaxSteps = 100, func = function(x, precBits) {Rmpfr::mpfr(x,precBits)^2})
lineSearch_APA(x_curr = 1, dk = -0.2, lineSearchMaxSteps = 100, func = function(x, precBits) {Rmpfr::mpfr(x-1,precBits)^2})
# simple 2D quadratic function optimization
func2 <- function(par, centerx=0, centery=0, precBits=64) {
par <- Rmpfr::mpfr(par, precBits)
(par[1]-centerx)^2+(par[2]-centery)^2
}
lineSearch_APA(x_curr = c(.015,-.015), dk = c(-0.2,0.2), func=func2)
lineSearch_APA(x_curr = c(2.06), dk = c(-0.2), func=function(x, precBits) {
l <- -1
for(xi in c(1,2,3)) {
l <- l * dpois_APA(xi, x, precBits)
}
return(l)
})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.