GenSAmodified: Extension of the GenSA function available in the CRAN package...

Description Usage Arguments Examples

Description

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.

Usage

1
GenSAmodified(par = NULL, fn, lower, upper, control = list(), ...)

Arguments

par

Vector. Initial values for the components to be optimized. Default is NULL, in which case, default values will be generated automatically.

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 par. Lower bounds for components.

upper

Vector with length of par. Upper bounds for components.

control

The argument is a list that can be used to control the behavior of the algorithm:

maxit

Integer. Maximum number of iterations of the algorithm.

threshold.stop

Numeric. The program will stop when the expected objective function value threshold.stop is reached. Default value is NULL

nb.stop.improvement

Integer. The program will stop when there is no any improvement in nb.stop.improvement steps.

smooth

Logical.TRUE when the objective function is smooth, or differentiable almost everywhere in the region of par, FALSE otherwise. Default value is TRUE.

max.call

Integer. Maximum number of call of the objective function. Default is set to 1e7.

max.time

Numeric. Maximum running time in seconds.

temperature

Numeric. Initial value for temperature.

visiting.param

Numeric. Parameter for visiting distribution.

acceptance.param

Numeric. Parameter for acceptance distribution.

verbose

Logical. TRUE means that messages from the algorithm are shown. Default is FALSE.

simple.function

Logical. FALSE means that the objective function has only a few local minima. Default is FALSE which means that the objective function is complicated with many local minima.

trace.mat

Logical. Default is TRUE which means that the trace matrix will be available in the returned value of GenSA call.

...

allows the user to pass additional arguments to the function fn.

Examples

 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

cmottet/RobustTail documentation built on May 13, 2019, 8:44 p.m.