Pivotal Knowledge Base


How to enable quadprog package in PLR


Product Version
Pivotal Greenplum (GPDB) All versions
OS:Red Hat Enterprise Linux (RHEL)   
quadprog  1.5-4


This article will explain how to enable quadprog package in PLR. 


1. Download the quadprog package source from this link.

The current latest version is 1.5-4 and it depends on R (>=2.12.0). So choose the suitable quadprog version according to R version that is already installed correctly. If you have not installed PLR before, refer to solution 15243.

For example, the quadprog package source is unzipped in the following directory:

[root@mdw quadprog]# pwd

2. Install the quadprog source package into R.

[root@mdw ~]# cd /root
[root@mdw ~]# R CMD INSTALL quadprog_1.5-4.tar.gz
* installing to library /usr/local/lib64/R/library
* installing *source* package quadprog...
** libs
gfortran  -fvisibility=hidden -fPIC  -g -O2 -c aind.f -o aind.o
gcc -std=gnu99 -I/usr/local/lib64/R/include  -I/usr/local/include    -fPIC  -g -O2 -fPIC -c init.c -o init.o
gfortran -fvisibility=hidden -fPIC -g -O2 -ffloat-store   -c -o solve.QP.compact.o solve.QP.compact.f
gfortran -fvisibility=hidden -fPIC -g -O2 -ffloat-store   -c -o solve.QP.o solve.QP.f
gfortran  -fvisibility=hidden -fPIC  -g -O2 -c util.f -o util.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o quadprog.so aind.o init.o solve.QP.compact.o solve.QP.o util.o -L/usr/local/lib64/R/lib -lRblas -lgfortran -lm -lgfortran -lm -L/usr/local/lib64/R/lib -lR
installing to /usr/local/lib64/R/library/quadprog/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded

* DONE (quadprog)

3. Test quadprog in R to confirm that it works.

[root@mdw ~]# R

R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(quadprog)
> Dmat  diag(Dmat)  dvec  Amat  bvec  solve.QP(Dmat,dvec,Amat,bvec=bvec)$solution
[1] 0.4761905 1.0476190 2.0952381

 4. Test the PLR function in the GPDB.

[gpadmin@mdw]$ psql
Timing is on.
psql (8.2.15)
Type "help" for help.

gpadmin=#CREATE OR REPLACE FUNCTION test_quadprog()
gpadmin-# RETURNS float8[] AS
gpadmin-# $$
gpadmin$# Dmat  


Powered by Zendesk