Dear all,
  I am dealing with a Linear Programming problem which involve intensive
 caculation and my code seems quite inefficient: it take 10 to 30 minutes to
 finish a single optimization. I wonder can anyone give me some advice on
how
 to improve it. Any suggestions as to packages or code that will work
 efficiently for my problem would be much appreciated.
 Thanks!
 Here are my code:
 data: rmat is a time series object with s row and n column(or s*n
matrix,s=130,n=30)
 memory.limit(12000)
 require(Rsymphony)

 P.risk_parameter<-c(106,44,4,3)
 # parameter

 PRAF10<-
function(p,risk_parameter=P.risk_parameter[2]){risk_parameter*(1-p)^(risk_parameter-1)}
 # function

 Amat.function<-function(rmat,RFR=0){
 n = ncol(rmat)
 s = nrow(rmat)
 # construct constraint matrix
 A<-matrix(0,2*s*s+3,s*s+s+n+1)
 A[1,1:n]<-                              colMeans(rmat)
 A[1,s*s+s+n+1]<-                        -RFR
 A[2,1:n]<-                              1
 A[2,s*s+s+n+1]<-                        -1
 for(i in 1:s)(A[(3+(i-1)*s):(i*s+2),1:n]<-rmat )
 for(i in 1:s)(A[(3+(i-1)*s):(i*s+2),n+i]<- -1)
 A[3:(s*s+2),(n+s+1):(s*s+s+n)]<-        diag(s*s)
 A[(3+s*s):(2*s*s+2),(n+s+1):(s*s+s+n)]<-diag(s*s)
 A[3:(2*s*s+2),s*s+s+n+1]<-              -RFR
 A[2*s*s+3,s*s+s+n+1]<-                   1
 return(A)
 }

	[[alternative HTML version deleted]]

