Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b155a9a
commit fc74a18
Showing
17 changed files
with
781 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Oops, something went wrong.