I am not very familiar with the optim function, and I wanted to get this information from its results: a) how many iterations were needed to achieve the result? and b) construct a sequence of particular solutions, i.e. solution obtained at the end of each iteration.
My code so far looks like this:
f1 <- function(x) {
x1 <- x[1]
x2 <- x[2]
x1^2 + 3*x2^2
}
res <- optim(c(1,1), f1, method="CG")
How can I improve it to get more information?
Thanks in advance
source
share