slsqp in R seems quite slow. Does anyone have some suggestion as how to speed up
this?
-----Original Message-----
From: Hans W Borchers [mailto:hwborchers at gmail.com]
Sent: Wednesday, August 26, 2015 10:11 AM
To: r-help at stat.math.ethz.ch
Cc: Wang, Xue, Ph.D.
Subject: Re: [R] lsqlin in R package pracma
I am a strong advocate of the *nloptr* package; and "sequential quadratic
programming", i.e. slsqp(), should be a good choice for least-squares
problems. Note that you still have to provide a starting point.
BUT: this point does not need to lie in the interior of the feasible region.
So you can start with a point that solves the problem on the boundary (with
lsqlin()) and then continue with slsqp().
For the example mentioned above, it looks like this:
library(pracma)
x0 <- lsqlin(C, d, A, b) # starting point on the boundary
library(nloptr)
f <- function(x) sum((C %*% x - d)^2) # objective
hin <- function(x) -A %*% x + b # constraint, w/ A x >= 0 !
slsqp(x0, f, hin = hin)
# $par
# [1] 0.1298620 -0.5756944 0.4251035 0.2438448
#
# $value
# [1] 0.01758538
# ...
The solution is slightly better than the MATLAB one or the constrOptim one.
Of course, all these can be improved by changing some optional parameters.
On Wed, Aug 26, 2015 at 2:18 PM, Wang, Xue, Ph.D. <Wang.Xue at mayo.edu>
wrote:> Hi Hans,
>
> Thanks for your comments!
>
> I need the linear inequality constraints so nlsLM is not a candidate.
>
> I am also looking at the functions mma and slsqp in R package nloptr.
Compared with constrOptim(), which approach would you recommend?
>
> Thanks,
>
> Xue