2014-11-17 4 views
2

이차 최적화 문제SCIP을 사용하여 해결하고자하는 선형 제약이 있습니다. 최소화하고자하는 최적화 행렬은 양의 준결 정 (정확하게는 특정 변수의 분산 임)입니다. 나는 CPLEX LP 형식의 파일에 문제가 내가 SCIP에 최적화 때, 나는 그래서 SCIP 시작 최적화 행렬이 부정하고 많은 시간을 소요 가정 메시지scip 최적화를위한 lapack 라이브러리

Quadratic constraint handler does not have LAPACK for eigenvalue computation. Will assume 
that matrices (with size > 2x2) are indefinite. 

를 얻을. LAPACK을 설치했으며 SCIP 소스와 바이너리가 있고 다시 설치되는 lib 폴더에 liblapack.a 파일을 복사했습니다. SCIP. 그러나 나는 위의 메시지를 계속 얻는다.

LAPACK 라이브러리를 사용하는 방법이 있습니까? SCIP 행렬이 양의 반 정량체라는 것을 알아낼 수 있다면 최적화가 실제로 빨라질 것이라고 저는 믿습니다.

답변

4

전체 Ipopt를 제공하지 않고 Lapack 라이브러리를 사용하기 위해 SCIP을 패치하는 느낌이 든다면 (* nix에서 빌드하기가 상대적으로 쉽고 성능이 향상 될 수 있지만 mattmilten이 지적한 바와 같이) 시도해 볼 수 있습니다 :

diff --git a/src/scip/cons_quadratic.c b/src/scip/cons_quadratic.c 
index 93ba359..795bade 100644 
--- a/src/scip/cons_quadratic.c 
+++ b/src/scip/cons_quadratic.c 
@@ -46,7 +46,7 @@ 
#include "scip/heur_trysol.h" 
#include "scip/debug.h" 
#include "nlpi/nlpi.h" 
-#include "nlpi/nlpi_ipopt.h" 
+/*#include "nlpi/nlpi_ipopt.h" */ 

/* constraint handler properties */ 
#define CONSHDLR_NAME   "quadratic" 
@@ -4257,6 +4257,71 @@ void checkCurvatureEasy(
     *determined = FALSE; 
} 

+#define F77_FUNC(a,A) a##_ 
+ 
+ /** LAPACK Fortran subroutine DSYEV */ 
+ void F77_FUNC(dsyev,DSYEV)(
+  char*     jobz,    /**< 'N' to compute eigenvalues only, 'V' to compute eigenvalues and eigenvectors */ 
+  char*     uplo,    /**< 'U' if upper triangle of A is stored, 'L' if lower triangle of A is stored */ 
+  int*     n,     /**< dimension */ 
+  double*    A,     /**< matrix A on entry; orthonormal eigenvectors on exit, if jobz == 'V' and info == 0; if jobz == 'N', then the matrix data is destroyed */ 
+  int*     ldA,    /**< leading dimension, probably equal to n */ 
+  double*    W,     /**< buffer for the eigenvalues in ascending order */ 
+  double*    WORK,    /**< workspace array */ 
+  int*     LWORK,    /**< length of WORK; if LWORK = -1, then the optimal workspace size is calculated and returned in WORK(1) */ 
+  int*     info    /**< == 0: successful exit; < 0: illegal argument at given position; > 0: failed to converge */ 
+  ); 
+ 
+/** Calls Lapacks Dsyev routine to compute eigenvalues and eigenvectors of a dense matrix. 
+ */ 
+static 
+SCIP_RETCODE LapackDsyev(
+ SCIP_Bool    computeeigenvectors,/**< should also eigenvectors should be computed ? */ 
+ int     N,     /**< dimension */ 
+ SCIP_Real*   a,     /**< matrix data on input (size N*N); eigenvectors on output if computeeigenvectors == TRUE */ 
+ SCIP_Real*   w     /**< buffer to store eigenvalues (size N) */ 
+ ) 
+{ 
+ int  INFO; 
+ char JOBZ = computeeigenvectors ? 'V' : 'N'; 
+ char UPLO = 'L'; 
+ int  LDA = N; 
+ double* WORK = NULL; 
+ int  LWORK; 
+ double WORK_PROBE; 
+ int  i; 
+ 
+ /* First we find out how large LWORK should be */ 
+ LWORK = -1; 
+ F77_FUNC(dsyev,DSYEV)(&JOBZ, &UPLO, &N, a, &LDA, w, &WORK_PROBE, &LWORK, &INFO); 
+ if(INFO != 0) 
+ { 
+  SCIPerrorMessage("There was an error when calling DSYEV. INFO = %d\n", INFO); 
+  return SCIP_ERROR; 
+ } 
+ 
+ LWORK = (int) WORK_PROBE; 
+ assert(LWORK > 0); 
+ 
+ SCIP_ALLOC(BMSallocMemoryArray(&WORK, LWORK)); 
+ 
+ for(i = 0; i < LWORK; ++i) 
+  WORK[i] = i; 
+ 
+ F77_FUNC(dsyev,DSYEV)(&JOBZ, &UPLO, &N, a, &LDA, w, WORK, &LWORK, &INFO); 
+ 
+ BMSfreeMemoryArray(&WORK); 
+ 
+ if(INFO != 0) 
+ { 
+  SCIPerrorMessage("There was an error when calling DSYEV. INFO = %d\n", INFO); 
+  return SCIP_ERROR; 
+ } 
+ 
+ return SCIP_OKAY; 
+} 
+ 
+ 
/** checks a quadratic constraint for convexity and/or concavity */ 
static 
SCIP_RETCODE checkCurvature(
@@ -4343,7 +4408,7 @@ SCIP_RETCODE checkCurvature(
     return SCIP_OKAY; 
    } 

- if(SCIPisIpoptAvailableIpopt()) 
+ if(TRUE) 
    { 
     for(i = 0; i < consdata->nbilinterms; ++i) 
     { 
@@ -4479,7 +4544,7 @@ SCIP_RETCODE checkFactorable(
     return SCIP_OKAY; 

    /* need routine to compute eigenvalues/eigenvectors */ 
- if(!SCIPisIpoptAvailableIpopt()) 
+ if(!TRUE) 
     return SCIP_OKAY; 

    SCIP_CALL(consdataSortQuadVarTerms(scip, consdata)); 
@@ -9395,7 +9460,7 @@ SCIP_DECL_CONSINITSOL(consInitsolQuadratic) 
     SCIP_CALL(SCIPcatchEvent(scip, SCIP_EVENTTYPE_SOLFOUND, eventhdlr, (SCIP_EVENTDATA*)conshdlr, &conshdlrdata->newsoleventfilterpos)); 
    } 

- if(nconss != 0 && !SCIPisIpoptAvailableIpopt() && !SCIPisInRestart(scip)) 
+ if(nconss != 0 && !TRUE && !SCIPisInRestart(scip)) 
    { 
     SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "Quadratic constraint handler does not have LAPACK for eigenvalue computation. Will assume that matrices (with size > 2x2) are indefinite.\n"); 
    } 

USRLDFLAGS="-llapack -lblas"과 함께 사용하십시오.

+0

고마워요! 그것은 나를 위해 일했습니다. 나는 우분투에서 ipopt를 설치하는 것이 너무 많은 번거 로움을 발견했다. USRLDFLAGS = "- llapack -lblas -lgfortran"으로 scip을 설치하는 gfortran 라이브러리에 링크하는 것만 변경되었습니다. –

3

현재 SCIP은 Ipopt을 통해서만 LAPACK을 사용할 수 있습니다. SCIP이 Ipopt 지원으로 컴파일 될 때 일반적으로 비선형 문제에 더 나은 성능이 있기 때문에 반드시 권장됩니다. 실행

make IPOPT=true 

그리고 Ipopt가 미리 설치되어 있는지 확인하십시오.

+0

고맙습니다. 그러나 ipopt를 설치하는 것은 너무 번거롭던 것 같습니다. 다른 해결책이 나를 위해 일했습니다. –

관련 문제