1

Consider the following example of nonlinear optimization problem. The procedure is too slow to apply in simulation studies. For example, in case of my studies, it takes 2.5 hours for only one replication. How to speed up the process so that the processing time could also be optimized?

library(mvtnorm)
library(alabama)

n = 200
X <- matrix(0, nrow = n, ncol = 2)
X[,1:2] <- rmvnorm(n = n, mean = c(0,0), sigma = matrix(c(1,1,1,4),
                                                          ncol = 2))
x0 = matrix(c(X[1,1:2]), nrow = 1)
y0 = x0 - 0.5 * log(n) * (colMeans(X) - x0)
X = rbind(X, y0)

x01 = y0[1]
x02 = y0[2]
x1 = X[,1]
x2 = X[,2]

pInit = matrix(rep(0.1, n + 1), nrow = n + 1)

outopt = list(kkt2.check=FALSE, "trace" = FALSE)
f1 <- function(p) sum(sqrt(pmax(0, p)))/sqrt(n+1)
heq1 <- function(p) c(sum(x1 * p) - x01, sum(x2 * p) - x02, sum(p) - 1)
hin1 <- function(p) p - 1e-06
sol <- alabama::auglag(pInit, fn = function(p) -f1(p), 
                       heq = heq1, hin = hin1,
                       control.outer = outopt)
-1 * sol$value
Hans W.
  • 1,799
  • 9
  • 16
Jafer
  • 33
  • 5
  • 1
    Usually, providing better starting values can speed up numeric optimization. – Roland Nov 05 '18 at 15:27
  • See [error-in-nonlinear-optimization-problem](https://stackoverflow.com/questions/53130611/error-in-nonlinear-optimization-problem-infinite-or-missing-values-in-x/) where I have, in the ADDENDUM, reformulated this problem as a convex optimization problem. Applying a convex optimization solver such as ECOS, the process will be accellerated by a factor of 100 or more. – Hans W. Nov 08 '18 at 08:24

0 Answers0