+++ /dev/null
-// Files included\r
-#include "Input.h"\r
-#include "SolverInterface.h"\r
-#include "Timer.h"\r
-\r
-\r
-/*============================================================================//\r
- SolverInterface.cpp: Implementation of SolverInterface.\r
-\r
- Implementation: Shane J. Neph, June 2004, University of Washington\r
-\r
- Special Note: Using "ulimit -t" option below for system call to solver.\r
- The time limit works as expected with the exception that the return\r
- value does not indicate a timeout (WIFSIGNALED() returns false). There\r
- does not appear to be signal handlers which ignore the timeouts and return \r
- with a special exit code either. Not sure what's going on with that. I\r
- inserted an instance of a Timer to catch/enforce timeouts so everything\r
- works as needed (the timeout *does* actually occur in the system call).\r
-//============================================================================*/\r
-\r
-void SolverInterface::checkRtn(int rtn) {\r
- if ( WIFSIGNALED(rtn) ) {\r
- int tmpRtn = WTERMSIG(rtn);\r
- Assert<CE::UserAbort>(tmpRtn != SIGQUIT, "user abort");\r
- Assert<CE::UserAbort>(tmpRtn != SIGINT, "user abort");\r
- std::string err = "memory or time limit exceeded";\r
- Assert<CE::TimeOut>(tmpRtn != SIGXCPU, "timeout");\r
- Assert<CE::MemoryLimit>(tmpRtn != SIGXFSZ, "memory exhausted");\r
- Assert<CE::MemoryLimit>(tmpRtn != SIGSEGV, "memory exhausted");\r
- err = convert<std::string>(tmpRtn);\r
- err = "Unchecked Signal Generated (# " + err + ") ...aborting";\r
- Assert<AbortedMission>(false, err);\r
- }\r
-}\r
-\r
-//=============\r
-// RunSolver()\r
-//=============\r
-void SolverInterface::RunSolver(const Input& input) {\r
- toRemove_ = cleanFiles(); // get cleanup information: used upon destruction\r
- RenameSolution(""); // remove any file left from previous run\r
-\r
- // Define 'toRun' --> call to SAT solver\r
- std::string toRun;\r
- if ( input.ProgramOptions().empty() )\r
- toRun = getExeNameAndArgs(input.ExeDirectory(), input.CNF(), \r
- input.Rand());\r
- else\r
- toRun = getExeNameAndArgs(input.ExeDirectory(), input.CNF(), \r
- input.ProgramOptions());\r
-\r
- std::string time = "ulimit -t ";\r
- time += convert<std::string>(input.LevelTimeOut());\r
- toRun = time + std::string(";") + toRun;\r
-\r
- // Run solver and check status information\r
- Timer timer;\r
- timer.Start();\r
- int rtn = std::system(toRun.c_str());\r
- checkRtn(rtn);\r
- timer.Stop();\r
- Assert<CE::TimeOut>(timer.UserTime() <= input.LevelTimeOut(), "timeout");\r
-\r
- // Let solver evaluate return value\r
- bool isOK = evaluateReturn(WEXITSTATUS(rtn));\r
- Assert<AbortedMission>(isOK, "Aborted Solver");\r
-}\r
-\r