These function extract success or failure information from optimization objects.
The returnCode
gives a numeric code, and returnMessage
a
brief description about the success or
failure of the optimization, and point to the problems occured (see
documentation for the
corresponding functions).
returnCode(x, ...)
# S3 method for default
returnCode(x, ...)
# S3 method for maxLik
returnCode(x, ...)
returnMessage(x, ...)
# S3 method for maxim
returnMessage(x, ...)
# S3 method for maxLik
returnMessage(x, ...)
object, usually an optimization result
further arguments for other methods
Integer for returnCode
, character for returnMessage
.
Different optimization routines may define it in a different way.
returnMessage
and returnCode
are a generic functions, with methods
for various optimisation algorithms.
The message should either describe
the convergence (stopping condition),
or the problem.
# NOT RUN {
## maximise the exponential bell
f1 <- function(x) exp(-x^2)
a <- maxNR(f1, start=2)
returnCode(a) # should be success (1 or 2)
returnMessage(a)
## Now try to maximise log() function
a <- maxNR(log, start=2)
returnCode(a) # should give a failure (4)
returnMessage(a)
# }
Run the code above in your browser using DataLab