2016-08-18 82 views

回答

0

如果跳不給你一個選擇捕捉求解器的標準輸出,那麼目前還沒有辦法做到這一點無需修改源。 如果你可以修改源,那麼這裏是一個簡單的補丁來獲取輸出到文件foo.txt的另外:

--- a/interfaces/ampl/src/cmain.c 
+++ b/interfaces/ampl/src/cmain.c 
@@ -43,6 +43,8 @@ SCIP_RETCODE run(

    /* setup SCIP and print version information */ 
    SCIP_CALL(SCIPcreate(&scip)); 
+ 
+ SCIPsetMessagehdlrLogfile(scip, "foo.txt"); 

    SCIPprintVersion(scip, NULL); 
    SCIPinfoMessage(scip, NULL, "\n"); 
+0

謝謝。我使用了帶有JuMP的'AmplNLWriter'軟件包,它創建一個.nl文件,然後使用AMPL兼容的SCIP可執行文件。它支持通過scip.set文件傳遞SCIP選項。 有沒有一種簡單的方法來修改SCIP源接受輸出文件的文件名(替換_foo.txt_)作爲輸入? –

0

該補丁會增加一個選項「顯示/日誌文件」設置的名稱日誌文件。儘管如此,您還沒有將日誌的最開始部分(SCIP版本和外部代碼)放到該文件中。如果你需要這個,只需對cmain.c進行相應的重新排序。

--- a/interfaces/ampl/src/cmain.c 
+++ b/interfaces/ampl/src/cmain.c 
@@ -38,6 +38,7 @@ SCIP_RETCODE run(
    SCIP* scip; 
    char buffer[SCIP_MAXSTRLEN]; 
    SCIP_Bool printstat; 
+ char* logfile = NULL; 

    assert(nlfile != NULL); 

@@ -57,6 +58,11 @@ SCIP_RETCODE run(
     "whether to print statistics on a solve", 
     NULL, FALSE, FALSE, NULL, NULL)); 

+ SCIP_CALL(SCIPaddStringParam(scip, "display/logfile", 
+  "file to additionally write log to", 
+  &logfile, FALSE, "", NULL, NULL)); 
+ assert(logfile != NULL); 
+ 
    SCIPprintExternalCodes(scip, NULL); 
    SCIPinfoMessage(scip, NULL, "\n"); 

@@ -65,6 +71,8 @@ SCIP_RETCODE run(
    { 
     SCIP_CALL(SCIPreadParams(scip, setfile)); 
    } 
+ if(*logfile) 
+  SCIPsetMessagehdlrLogfile(scip, logfile); 

    SCIP_CALL(SCIPgetBoolParam(scip, "display/statistics", &printstat)); 
相關問題