Skip to content

Commit

Permalink
version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Haotian Pang authored and gaborcsardi committed Jun 18, 2013
1 parent b155a9a commit fc74a18
Show file tree
Hide file tree
Showing 17 changed files with 781 additions and 132 deletions.
11 changes: 6 additions & 5 deletions DESCRIPTION
Expand Up @@ -2,17 +2,18 @@ Package: fastclime
Type: Package
Title: A fast solver for constrained l1 minimization approach to sparse
precision matrix estimation
Version: 1.0
Date: 2013-05-27
Version: 1.1
Date: 2013-06-18
Author: Haotian Pang, Han Liu and Robert Vanderbei
Maintainer: Haotian Pang <hpang@princeton.edu>
Depends: R (>= 2.15.0), lattice, igraph, MASS, Matrix
Description: The package "fastclime" provides a method of recover the
precision matrix efficiently by applying parametric simplex
method. The computation is based on a linear optimization
solver.
solver. It also contains a generic LP solver using parametric
simplex method.
License: GPL-2
Repository: CRAN
Packaged: 2013-05-30 01:18:20 UTC; haotian
Packaged: 2013-06-18 23:15:32 UTC; haotian
NeedsCompilation: yes
Date/Publication: 2013-05-30 07:28:53
Date/Publication: 2013-06-19 08:49:27
27 changes: 16 additions & 11 deletions MD5
@@ -1,16 +1,20 @@
9cf060786ef4a379037d344c0c367ccb *DESCRIPTION
da6215639f444276a1dee9f56f21ca35 *NAMESPACE
63c3fcc25c70598356142da9928fadaa *R/fastclime.R
f98c0c855f59d8cad467708e4c4a6338 *R/fastclime.generator.R
2515a63fb256adeb6922ae0acafad17a *R/fastclime.plot.R
9626c7b81af3309c76ded6266e870900 *R/fastclime.roc.R
ef9be5f3e5a7e6bcc107597a7e8fbf94 *DESCRIPTION
8b1385871523f9e979f7b0b69cc720a2 *NAMESPACE
aadbd9dcbf1b733d80f9961eff81e690 *R/fastclime.R
8ebabce6fbf0ec5a5cea556fb5d7ce58 *R/fastclime.generator.R
f7fe243272e90e5599a05566d39e2cc0 *R/fastclime.plot.R
546eeb0435048784d1ec66cb99c38d65 *R/fastclime.roc.R
c2c02d8b30ac90676fbe6179b213d98b *R/fastlp.R
ec90576375b24e35502847bdd1d85b6e *data/stockdata.rda
0d107bb6bb844e2e52ed16ad086bfe70 *inst/doc/vignette.pdf
18fca9443d532169d44c2d0dcd7fa8f5 *inst/doc/fastclime.pdf
9cf23fc8036ec97c902be03c40a08490 *inst/doc/vignette.Rnw
dfb9b711d987b84cc3523cf27a71b85b *inst/doc/vignette.pdf
457de96fcd3cfdc20abaee85fd75053e *man/fastclime-package.Rd
22c0b937c19895f44dfea922b26b279d *man/fastclime.Rd
c964cd215020211b41c9abdaec9a24b3 *man/fastclime.Rd
f13eef1099b8dad1091dd5764e6b6eb5 *man/fastclime.generator.Rd
64307ab02e80b23986e1f4446aa316c6 *man/fastclime.plot.Rd
05d72f126d24f37636432aa948c6f48a *man/fastclime.roc.Rd
35a34d4b383d8d9798b754ca6ebd808b *man/fastlp.Rd
4fede98f1e2ad5f3ee859ea58504be85 *man/plot.fastclime.Rd
a1d5732ba3621562c4e5d92cd57b1b31 *man/plot.roc.Rd
66a8b6d1673d092cb2d2e15434493e3e *man/plot.sim.Rd
Expand All @@ -19,14 +23,15 @@ b196c00bb421f420ddd428008f97458b *man/print.fastclime.Rd
fbb7265b9ba8567834e3a326c7b67247 *man/print.sim.Rd
f584effdd8752b5956fea4ac449e7e33 *man/stockdata.Rd
b10cd7a70f4a0772e49935ad349b56a8 *src/SFGen.c
af4266c8729629e28488ade6226ad8b7 *src/fastlp.c
3d21bc5d49dee6d81d869301b5adbcb0 *src/heap.c
ad5e9b747ce1895e811d2d2e8052eddc *src/heap.h
4e463f066d014e6ae6c911840f52668b *src/linalg.c
351664530c580760e76863240f846268 *src/linalg.h
c5217e444b843a5a358b905e6cb1c975 *src/linalg.c
73fc5b2f3cf1fd12dab5c3066e43f6d7 *src/linalg.h
7885ff8759cd54849b5888da3b1f0adb *src/lu.c
f27fb8d738a94ff945bf48498eeee3ab *src/lu.h
abc0a80ca8d0260b12e96ba9f9df608f *src/macros.h
e1be8277ecf906d37bc71e80fb591490 *src/myalloc.h
d6f83e0e72a27a6deb26c73669526fce *src/parametric.c
236bcdaa0532e3454d61fec79f0648d7 *src/parametric.c
38e9ff9c3d2f5b3b832010d120069caf *src/tree.c
ebd8db35929bc9a80f444621e0e0f909 *src/tree.h
3 changes: 2 additions & 1 deletion NAMESPACE
Expand Up @@ -6,7 +6,8 @@ export(fastclime,
fastclime.roc,
print.fastclime,plot.fastclime,
print.roc,plot.roc,
print.sim,plot.sim
print.sim,plot.sim,
fastlp
)

S3method("print","roc")
Expand Down
16 changes: 3 additions & 13 deletions R/fastclime.R
Expand Up @@ -3,10 +3,10 @@
# fastclime(): Main Function #
# Authors: Haotian Pang, Han Liu and Robert Vanderbei #
# Emails: <hpang@princeton.edu>, <hanliu@princeton.edu> and <rvdb@princetonedu> #
# Date: Mar 13th 2013 #
# Version: 0.9 #
# Date: Jun 18th 2013 #
# Version: 1.1 #
#-------------------------------------------------------------------------------#
fastclime <- function(x, lambda.min.ratio = NULL)
fastclime <- function(x, lambda.min.ratio = NULL, nlambda = 50)
{

gcinfo(FALSE)
Expand All @@ -24,16 +24,6 @@ fastclime <- function(x, lambda.min.ratio = NULL)
d<-dim(SigmaInput)[2]


if(d<=50){
nlambda=d
}
else if(d<=1000){
nlambda=50
}
else{
nlambda=15
}

cat("Allocating memory \n")
maxnlambda=0
mu_input<-matrix(0,nlambda,d)
Expand Down
4 changes: 2 additions & 2 deletions R/fastclime.generator.R
Expand Up @@ -3,8 +3,8 @@
# fastclime.generator(): Data generator #
# Authors: Haotian Pang, Han Liu and Robert Vanderbei #
# Emails: <hpang@princeton.edu>, <hanliu@princeton.edu> and <rvdb@princetonedu> #
# Date: Mar 13th 2013 #
# Version: 0.9 #
# Date: Jun 18th 2013 #
# Version: 1.1 #
#-------------------------------------------------------------------------------#

## Main function
Expand Down
4 changes: 2 additions & 2 deletions R/fastclime.plot.R
Expand Up @@ -3,8 +3,8 @@
# fastclime.generator(): graph visualization #
# Authors: Haotian Pang, Han Liu and Robert Vanderbei #
# Emails: <hpang@princeton.edu>, <hanliu@princeton.edu> and <rvdb@princetonedu> #
# Date: Mar 13th 2013 #
# Version: 0.9 #
# Date: Jun 18th 2013 #
# Version: 1.1 #
#-------------------------------------------------------------------------------#

fastclime.plot = function(G, epsflag = FALSE, graph.name = "default", cur.num = 1, location=NULL){
Expand Down
4 changes: 2 additions & 2 deletions R/fastclime.roc.R
Expand Up @@ -4,8 +4,8 @@
# The ground truth is required #
# Authors: Haotian Pang, Han Liu and Robert Vanderbei #
# Emails: <hpang@princeton.edu>, <hanliu@princeton.edu> and <rvdb@princetonedu> #
# Date: Mar 13th 2013 #
# Version: 0.9 #
# Date: Jun 18th 2013 #
# Version: 1.1 #
#-------------------------------------------------------------------------------#

fastclime.roc = function(path, theta, verbose = TRUE){
Expand Down
64 changes: 64 additions & 0 deletions R/fastlp.R
@@ -0,0 +1,64 @@
#-------------------------------------------------------------------------------#
# Package: fastclime #
# fastclp(): A parametric simplex LP solver #
# Authors: Haotian Pang, Han Liu and Robert Vanderbei #
# Emails: <hpang@princeton.edu>, <hanliu@princeton.edu> and <rvdb@princetonedu> #
# Date: Jun 18th 2013 #
# Version: 1.1 #
#-------------------------------------------------------------------------------#

fastlp <- function(obj, mat, rhs,lambda=0){

m<-length(rhs)
n<-length(obj)
m0<-dim(mat)[1]
n0<-dim(mat)[2]

opt<-rep(0,n)
status<-0
error<-0

if (m!=m0 || n!=n0){
cat("Dimensions do not match! \n")
error<-1
}

if (error==0){
str=.C("fastlp", as.double(obj), as.double(t(mat)), as.double(rhs), as.integer(m0), as.integer(n0), as.double(opt), as.integer(status), as.double(lambda), PACKAGE="fastclime")


opt<-unlist(str[6])
status<-unlist(str[7])

if (status==0){
cat("optimal solution found! \n")
return(opt)
}

else if(status ==1){
cat("The problem is infeasible! \n")
}

else if(status ==2){
cat("The problem is unbounded! \n")
}

}


}















Binary file added inst/doc/fastclime.pdf
Binary file not shown.
10 changes: 10 additions & 0 deletions inst/doc/vignette.Rnw
@@ -0,0 +1,10 @@
% \VignetteIndexEntry{vignette}
% \VignetteKeywords{keywords here}
% \VignettePackage{package name}

\documentclass[a4paper]{article}
\usepackage{hyperref}
\usepackage{pdfpages}
\begin{document}
\includepdf[fitpaper=true,pages=-]{fastclime.pdf}
\end{document}
Binary file modified inst/doc/vignette.pdf
Binary file not shown.
7 changes: 5 additions & 2 deletions man/fastclime.Rd
Expand Up @@ -10,7 +10,7 @@ A fast parametric simplex solver for constrainted l1 minimization approach to sp
}

\usage{
fastclime(x, lambda.min.ratio = NULL)
fastclime(x, lambda.min.ratio = NULL, nlambda = 50)
}

\arguments{
Expand All @@ -22,6 +22,9 @@ There are 2 options: (1) \code{x} is an \code{n} by \code{d} data matrix (2) a \
It is the largest sparsity of each column for estimated graphs. This program makes the sparsity level of the graph path increase from \code{0} to \code{lambda.min.ratio}.The default value is \code{0.1}. When you have a large data set, make sure the sparsity level is small enough, otherwise the program might take a long time.
}

\item{nlambda}{
It is the number of the path length one would like to achieve. The default length is 50. Note if d is large and nlambda is also large, it is possible that the program will fail to allocate memory for the path.
}
}

\details{
Expand All @@ -44,7 +47,7 @@ An indicator of the sample covariance.
The empirical covariance of the data. If cov.inpu is TRUE, sigmahat = data
}
\item{nlambda}{
The length of the path. The maximum value is 50 when d is small and it is 15 when d is large. The program will stop when it reaches this value
The length of the path. The default value is 50. The program will stop when it reaches this value
}
\item{lambda}{
The sequence of regularization parameters for each column, it is a \code{nlambda} by \code{d} matrix. It will
Expand Down
58 changes: 58 additions & 0 deletions man/fastlp.Rd
@@ -0,0 +1,58 @@
\name{fastlp}
\alias{fastlp}

\title{
A generic LP solver
}

\description{
A generic linear programming solver using parametric simplex method
}

\usage{
fastlp(obj,mat,rhs,lambda=0)
}

\arguments{
\item{obj}{
The objective vector of the coefficient with length n.
}
\item{mat}{
The constraint matrix of the linear programming with dimension m*n. Note this argument must be in matrix form even it is a vector.
}
\item{rhs}{
The right hand side vector of the constraint with length m.
}
\item{lambda}{
The parametric simplex method will stop when the calculated paramter is smaller than lambda. The default value is zero and it corresponds to the optimal value.
}
}

\details{
This function is used to solve a general linear programming in standard inequality form: "maximize obj*x, subject to: mat*x<=rhs, x>=0"
}

\note{
The linear programming should be in the form "maximize obj*x, subject to: mat*x<=rhs, x>=0". If the original problem is not in this form. The user has to convert it into this form. For example, the equality constrants can be separated into two inequality constraints.
}

\value{
The optimal value will be returned if it exists. Otherwise the function will indicate the problem is infeasible or unbounded.
}

\author{
Haotian Pang, Han Liu and Robert Vanderbei \cr
Maintainer: Haotan Pang<hpang@princeton.edu>
}

\seealso{
\code{\link{fastclime}} and \code{\link{fastclime-package}}
}

\examples{
#generate an LP problem and solve it
A=matrix(c(-1,-1,0,1,-2,1),nrow=3)
b=c(-1,-2,1)
c=c(-2,3)
fastlp(c,A,b)
}

0 comments on commit fc74a18

Please sign in to comment.