4

I recently dusted off a script which calls solve.QP from the quadprog package (I currently have version 1.5-5). Now it generates the error "object '.QP_qpgen2' not found". I don't understand why.

This object is not created by me but by the solve.QP function in quadprog. On Github Quadprog.R has the code (line 117):

 res1 <- .Fortran(.QP_qpgen2,
               as.double(Dmat), dvec=as.double(dvec),
               as.integer(n), as.integer(n),
               sol=as.double(sol), lagr=as.double(lagr),
               crval=as.double(crval),
               as.double(Amat), as.double(bvec), as.integer(n),
               as.integer(q), as.integer(meq),
               iact=as.integer(iact), nact=as.integer(nact),
               iter=as.integer(iter), work=as.double(work),
               ierr=as.integer(factorized))

The error can be generated from the code taken from the documentation for solve.QP:

##
## Assume we want to minimize: -(0 5 0) %*% b + 1/2 b^T b
## under the constraints:      A^T b >= b0
## with b0 = (-8,2,0)^T
## and      (-4  2  0) 
##      A = (-3  1 -2)
##          ( 0  0  1)
## we can use solve.QP as follows:
##
Dmat       <- matrix(0,3,3)
diag(Dmat) <- 1
dvec       <- c(0,5,0)
Amat       <- matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3)
bvec       <- c(-8,2,0)
solve.QP(Dmat,dvec,Amat,bvec=bvec)

I am using R v3.4.1 if that helps.

rmacey
  • 599
  • 3
  • 22
  • 1
    I am having the same issues. As far as I can tell, R 3.4 has a new method to register routines in Fortran (see https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines). The quadprog package has not been updated yet. – pbr142 Jul 12 '17 at 09:28

2 Answers2

5

As stated in my comment, R 3.4 has a new method to register external routines. Quadprog relies on Fortran routines. To solve this, you need to build the package from source in R 3.4 using the current Rtools. You need to have the Rtools installed and setup (A google search will get you to a guide how to set-up Rtools for whatever system you are using). Then, go to CRAN page of the quadprog package and download the source file quadprog.tar.gz. Finally, run the command

install.packages("PATH_TO_FILE/quadprog_1.5-5.tar.gz", repos = NULL, type="source", INSTALL_opts = "--merge-multiarch")

Alternatively, you can wait a few days. I'm sure, the package on CRAN will be updated soon.

pbr142
  • 166
  • 2
1

As I keep getting e-mails about this issue:

Use packageDescription("quadprog") to see under which version of R your installed package was built.

If the version is R 3.3.x (or earlier), use update.packages(checkBuilt=TRUE) to update your version to a version that was built under R 3.4.x.

Philip John
  • 5,275
  • 10
  • 43
  • 68
Berwin
  • 11
  • 1