SA.info: Simulated-Annealing Information

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/SAopt.R

Description

The function can be called from the objective and neighbourhood function during a run of SAopt; it provides information such as the current iteration, the current solution, etc.

Usage

1
  SA.info(n = 0L)

Arguments

n

generational offset; see Details.

Details

This function is still experimental.

The function can be called in the neighbourhood function or the objective function during a run of SAopt. It evaluates to a list with information about the state of the optimisation run, such as the current iteration or the currently best solution.

SA.info relies on parent.frame to retrieve its information. If the function is called within another function within the neighbourhood or objective function, the argument n needs to be increased.

Value

A list

calibration

logical: whether the algorithm is calibrating the acceptance probability

iteration

current iteration

step

current step for the given temperature level

temperature

current temperature (the number, not the value)

xbest

the best solution found so far

Author(s)

Enrico Schumann

References

Gilli, M., Maringer, D. and Schumann, E. (2011) Numerical Methods and Optimization in Finance. Elsevier. http://www.elsevierdirect.com/product.jsp?isbn=9780123756626

Schumann, E. (2017) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

See Also

SAopt, TA.info

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
### MINIMAL EXAMPLE for SAopt

## the objective function evaluates to a constant
fun <- function(x)
    0

## the neighbourhood function does not even change
## the solution; it only reports information
nb <- function(x) {
    info <- SA.info()
    cat("current step ",        info$step,
        "| current iteration ", info$iteration, "\n")
    x
}

## run SA
algo <- list(nS = 5, nT = 2, nD = 10,
             initT = 1,
             x0 = rep(0, 5),
             neighbour = nb,
             printBar = FALSE)
ignore <- SAopt(fun, algo)

enricoschumann/NMOF documentation built on Feb. 14, 2019, 2:21 p.m.