TA.info {NMOF} | R Documentation |
Threshold-Accepting Information
Description
The function can be called from the objective and neighbourhood
function during a run of TAopt
; it provides information
such as the current iteration, the current solution, etc.
Usage
TA.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 TAopt
. It evaluates
to a list with the state of the optimisation run, such as the current
iteration.
TA.info
relies on parent.frame
to retrieve its
information. If the function is called within another function in the
neighbourhood or objective function, the argument n
needs to be
increased.
Value
A list
OF.sampling |
logical: if |
iteration |
current iteration |
step |
current step (i.e. for a given threshold) |
threshold |
current threshold (the number, not the value) |
xbest |
the best solution found so far |
OF.xbest |
objective function value of best solution |
Author(s)
Enrico Schumann
References
Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. doi:10.1016/C2017-0-01621-X
Schumann, E. (2023) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual
See Also
Examples
### MINIMAL EXAMPLE for TAopt
## objective function evaluates to a constant
fun <- function(x)
0
## neighbourhood function does not even change the solution,
## but it reports information
nb <- function(x) {
tmp <- TA.info()
cat("current threshold ", tmp$threshold,
"| current step ", tmp$step,
"| current iteration ", tmp$iteration, "\n")
x
}
## run TA
algo <- list(nS = 5,
nT = 2,
nD = 3,
x0 = rep(0, 5),
neighbour = nb,
printBar = FALSE,
printDetail = FALSE)
ignore <- TAopt(fun, algo)
## printed output:
## current threshold NA | current step 1 | current iteration NA
## current threshold NA | current step 2 | current iteration NA
## current threshold NA | current step 3 | current iteration NA
## current threshold 1 | current step 1 | current iteration 1
## current threshold 1 | current step 2 | current iteration 2
## current threshold 1 | current step 3 | current iteration 3
## current threshold 1 | current step 4 | current iteration 4
## current threshold 1 | current step 5 | current iteration 5
## current threshold 2 | current step 1 | current iteration 6
## current threshold 2 | current step 2 | current iteration 7
## current threshold 2 | current step 3 | current iteration 8
## current threshold 2 | current step 4 | current iteration 9
## current threshold 2 | current step 5 | current iteration 10