2013-06-24 5 views
3

R에서 lpSolve를 사용하고 있습니다. 내 모델 (데이터 포락 분석)이 MAC에서 잘 실행되지만 UNIX 클러스터에서 실행하려고 시도 할 때 많은 모델이 퇴화되는 것으로 밝혀졌습니다. lp.control 옵션은 두 시스템에서 동일합니다. 나는 presolve 및 anti.degen 옵션을 사용하여 퇴행 횟수를 줄이지 만 줄일 수있었습니다.lpSolve를 사용할 때의 세대 축소

동일한 선형 프로그래밍 모델을 해결하기 위해 미리 빌드 된 R 패키지 (벤치마킹, nonparaeff)를 사용할 때 똑같은 문제가 발생한다는 점에 유의하십시오.

누가 유닉스 클러스터의 왜곡 오류를 아는 사람이 있습니까?

건배,

사람이 다음과 같이 코드가 관심이 있다면

피터. 기본적으로 300 개의 에이전트 각각에 대해 선형 프로그래밍 모델을 생성하고이 문제를 해결합니다. 내 Mac에서 모든 문제가 잘 해결되지만, 클러스터에있는 문제의 90 %는 퇴화로 발견된다 : 당신이 (매우 본래 크기의 타락이다 (300) 작은 문제를 해결하는 것 같은

library(lpSolveAPI) 
set.seed(198302) 

##############Create data 
x=matrix(rnorm(1200,5,3),300,4) 
y1=x%*%c(.4,.2,.7,.8)+rnorm(300,4,.5) 
y2=x%*%c(.5,.8,.2,.3)+rnorm(300,4,.5) 
y=cbind(y1,y2) 

##############Write DEA function 
xref=x 
yref=y 

##Define dimensions 
mx<-ncol(xref) 
my<-ncol(yref) 
nref<-nrow(xref) 
nobs<-nrow(x) 

##Define empty matrices for efficiency scores, lambdas and slacks 
eff<-rep(0,nobs) 
lambda<-matrix(0,nobs,nref) 
slacks<-matrix(0,nobs,mx) 

##Start the model, noting that there will be as many constraints as there are inputs, outputs and one additional constraint on lambda. And as many decision variables as there are producers (lambdas) + one (efficiency score) 
deamodel<-make.lp(nrow=mx+my+1,ncol=nref+1) 
    ## For each input and output set the row as a constraint 
    for (h in 1:mx) set.row(deamodel, h, c(0, -xref[, h])) 
    for (h in 1:my) set.row(deamodel, mx + h, c(0, yref[, h])) 
    ##Set a single objective function 
    set.objfn(deamodel, 1, 1) 
    ##Set the type of constraints. Inputs and outputs are all greater than, lambdas is equal to 
    set.constr.type(deamodel, c(rep(">=", mx + my),"=")) 
    ##Set another row as a constraint on lambdas 
    set.row(deamodel, (mx+my+1), c(0,rep(1,nref))) 
    set.rhs(deamodel, 1, mx+my+1) 

##In a loop create a lp model for each producer 
for (k in 1:nobs){ 
    ##Set the right hand side equal to output of the individual producer 
    set.rhs(deamodel, c(rep(0,mx), y[k, ]), 1:(mx + my)) 
    ##Set first column equal to input of producer 
    set.column(deamodel, 1, c(1,x[k,]), 0:mx) 
    ##Set some presolve options 
    lp.control(deamodel, presolve=c("rows", "columns","rowdominate","coldominate","bounds")) 
    ##Solve the model 
    a=solve(deamodel) 
    if (a==0){ 
     eff[k]<-get.objective(deamodel) 
     lambda[k,]<-get.variables(deamodel)[-1] 
     slacks[k,]<-get.constraints(deamodel)[1:mx]} 
    if (a!=0){ 
     eff[k]<-NA 
     lambda[k,]<-NA 
     slacks[k,]<-NA 
    }} 

eff 
+0

아마도 당신은 당신의 Mac과 더 개인적인 관계가 있으며 단지 당신을 더 사랑한다는 것입니까? –

+0

관련 항목 : http://stackoverflow.com/questions/13447373/set-seed-in-mac-vs-windows – flodel

답변

1

같습니다 301 변수, 7 제약). Presolve와 anti.degen은 지금까지만 당신을 데려 갈 수 있습니다. lpSolve FAQ에서

:이 코드와

주요 문제는 스케일링, 명시 적으로 역수의 사용 reinversion의 부족, 그리고 타락의 취급과 관련이있다. 아픈 조건이나 타락한 작은 문제라도 대부분의이 tableau 코드를 무릎 꿇게 가져올 수 있습니다.

퇴화 솔루션을 식별하는 Unix 클러스터의 lpSolve 구현은 Mac (R에서 호출 한)과 다른 것으로 보입니다.

첫 번째 테스트 : 300 MIPS의 (write.lp)를 밖으로 쓰기가 R에 당신의 유닉스 클러스터에 동일한를하는 경우를 참조하십시오. (당신이 높은 타락한 문제의 일부를 던질 수 rnorm 심지어 아주 작은 반올림을 사용하고 있습니다.)

당신의 목표는 퇴화을 제거하는 것입니다 경우, 우, 특히 당신의 목적 함수를 교란하려고합니다.

당신이 정말로 두 시스템이을 변경할 이유의 루트에 얻고 싶은 경우에, 나는 *이 .c 파일은, 자신이 (here 참조) lpSolve를 컴파일 및 R에서뿐만 아니라 유닉스 클러스터에서 해당 버전을 호출 제안 결과에 여전히 변화가 있는지 확인하십시오.

앞으로 나아갈 수있는 희망.