2013-10-22 5 views
0

저는 COLE/OSI 인터페이스 (OsiCpxSolverInterface)를 통해 CPLEX를 실행하고 있습니다. 일부 대형 LP의 경우 오류 메시지가 표시됩니다. CPX0000 CPLEX Error 1001: Out of memory. 오류 메시지에도 불구하고 예외 (CoinError)가 발생하지 않습니다. source code of OsiCpxSolverInterface을 보면 CPXlpopt의 리턴 코드가 0이어야합니다.CPLEX에 예외없이 메모리가 부족합니다.

분명히 : 제 질문은 메모리 부족 문제를 피하는 방법이 아닙니다. 나는 내 프로그램에서 그것을 탐지 할 수있는 방법을 찾고있다.

답변

0

나를 위해 작동하는 해킹을 발견했습니다. 오류 핸들러 로그 레벨을 0으로 설정하면 오류 메시지가 전달됩니다. MessageHandler의 print 메소드를 덮어 쓰면 오류에 대응할 수 있습니다. 이 해결 방법은 확실히 해킹입니다. 누구든지 더 좋은 제안이 있으면 다른 대답을 기꺼이 받아 들일 것입니다.

class ErrorCatchingCoinMessageHandler: public CoinMessageHandler { 
public: 
    ErrorCatchingCoinMessageHandler() 
     : CoinMessageHandler() { 
     // Would be nice to also overwrite setLogLevel to avoid later changes 
     // but its not virtual 
     setLogLevel(0); 
    } 

    virtual int print() __attribute__((noreturn)) { 
     CoinMessageHandler::print(); 
     abort(); // or throw a CoinError 
    } 
}; 

// Use it like this 

lp_solver->passInMessageHandler(new ErrorCatchingCoinMessageHandler()); 
관련 문제