Description Usage Arguments Examples
This function is an extension of the function GenSA defined in the package GenSA available on CRAN. The only difference with the existing version is that GenSAmodified allows the user to pass lower bounds and upper bounds with equal values. Though this is a trivial scenario in which case the optimal solution should be lower = upper, the current version of GenSA crashes.
1 | GenSAmodified(par = NULL, fn, lower, upper, control = list(), ...)
|
par |
Vector. Initial values for the components to be optimized. Default is |
fn |
A function to be minimized, with first argument the vector of parameters over which minimization is to take place. It should return a scalar result. |
lower |
Vector with length of |
upper |
Vector with length of |
control |
The argument is a list that can be used to control the behavior of the algorithm:
|
... |
allows the user to pass additional arguments to the function |
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 27 28 29 30 31 | # Test GenSAmodified in the univariate case
fn1 <- function(x) x
bound <- RobustTail:::GenSAmodified(fn = fn1,par = 1,lower = 1,upper = 1)
bound
GenSA::GenSA(fn = fn1,par = 1,lower = 1,upper = 1) # This crashes
# Test GenSAmodified in the bivariate case with one lower bound equal to the upper bound
fn2 <- function(x) x[1] + x[2]
bound <- RobustTail:::GenSAmodified(fn = fn2,par = c(1,2),lower = c(1,1),upper = c(1,3))
bound$par
bound$value
GenSA::GenSA(fn = fn2,par = c(1,2),lower = c(1,1),upper = c(1,3))# This crashes
# Test GenSAmodified in the bivariate case with both lower bound are equal to the upper bounds
bound <- RobustTail:::GenSAmodified(fn = fn2,par = c(1,1),lower = c(1,1),upper = c(1,1))
bound$par
bound$value
GenSA::GenSA(fn = fn2,par = c(1,1),lower = c(1,1),upper = c(1,1)) # This crashes
# Let's check that when the lower bounds are strictly smaller than the upper bounds,
# all goes well
outGenSAmodified <- RobustTail:::GenSAmodified(fn = fn2,par = c(1,2),lower = c(1,2),upper = c(2,3))
outGenSA <- GenSA::GenSA(fn = fn2,par = c(1,2),lower = c(1,2),upper = c(2,3))
# Check that they have the same optimal solution
all(outGenSAmodified$par == outGenSA$par)
# Check that they have the same optimal objective value
outGenSAmodified$value == outGenSA$value
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.