24 std::cout <<
"enter: No Lit.=" <<
no_variables() <<
"\n";
28 d_sum += lit_entry.second;
32 out <<
"# PBType: E" <<
"\n";
33 out <<
"# PBGoal: " <<
goal <<
"\n";
37 out <<
"# PBType: SE" <<
"\n";
38 out <<
"# PBGoal: " << d_sum <<
"\n";
39 out <<
"# PBObj : MIN" <<
"\n";
43 out <<
"# PBType: GE" <<
"\n";
44 out <<
"# PBGoal: " << 0 <<
"\n";
45 out <<
"# PBObj : MAX" <<
"\n";
52 const int dimacs_lit = lit_entry.first.dimacs();
53 out <<
"v" << dimacs_lit <<
" c" << lit_entry.second <<
"\n";
64 std::cout <<
"solve: No Lit.=" <<
no_variables() <<
"\n";
72 if(command.substr(command.length(), 1) !=
"/")
79 std::cout <<
"PBS COMMAND IS: " << command <<
"\n";
82 if (!(getenv(
"PBS_PATH")==NULL))
84 command=getenv(
"PBS_PATH");
88 error (
"Unable to read PBS_PATH environment variable.\n");
93 command +=
" -f temp.cnf";
100 command +=
" -S 1000 -D 1 -H -I -a";
105 std::cout <<
"NO BINARY SEARCH"
108 command +=
" -S 1000 -D 1 -I -a";
113 command +=
" -S 1000 -D 1 -a";
119 command +=
" -a > temp.out";
121 const int res = system(command.c_str());
124 std::ifstream file(
"temp.out");
127 bool satisfied =
false;
137 while(file && !file.eof())
139 std::getline(file, line);
141 strstr(line.c_str(),
"Variable Assignments Satisfying CNF Formula:") !=
145 std::cout <<
"Reading assignments...\n";
156 std::cout << v <<
" ";
163 std::cout <<
"Finished reading assignments.\n";
166 else if(strstr(line.c_str(),
"SAT... SUM") !=
nullptr)
171 sscanf(line.c_str(),
"%*s %*s %*s %d", &
opt_sum);
173 else if(strstr(line.c_str(),
"SAT - All implied") !=
nullptr)
180 "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %d",
183 else if(strstr(line.c_str(),
"SAT... Solution") !=
nullptr)
188 sscanf(line.c_str(),
"%*s %*s %*s %d", &
opt_sum);
190 else if(strstr(line.c_str(),
"Optimal Soln") !=
nullptr)
195 if(strstr(line.c_str(),
"time out") !=
nullptr)
197 log.
status() <<
"WARNING: TIMED OUT. SOLUTION MAY BE INCORRECT."
201 sscanf(line.c_str(),
"%*s %*s %*s %d", &
opt_sum);
210 std::ofstream file(
"temp.cnf");
214 std::ofstream pbfile(
"temp.cnf.pb");
233 log.
status() <<
"PBS checker: system is SATISFIABLE";
247 int dimacs_lit = a.
dimacs();
250 std::cout << a <<
" / " << dimacs_lit <<
"=";
253 const bool neg = (dimacs_lit < 0);
255 dimacs_lit = -dimacs_lit;
257 std::set<int>::const_iterator f =
assigned.find(dimacs_lit);
264 std::cout <<
"FALSE\n";
271 std::cout <<
"TRUE\n";
281 std::cout <<
"FALSE\n";
288 std::cout <<
"TRUE\n";