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)
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)
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."
212 std::ofstream file(
"temp.cnf");
216 std::ofstream pbfile(
"temp.cnf.pb");
235 log.
status() <<
"PBS checker: system is SATISFIABLE";
249 int dimacs_lit = a.
dimacs();
252 std::cout << a <<
" / " << dimacs_lit <<
"=";
255 const bool neg = (dimacs_lit < 0);
257 dimacs_lit = -dimacs_lit;
259 std::set<int>::const_iterator f =
assigned.find(dimacs_lit);
266 std::cout <<
"FALSE\n";
273 std::cout <<
"TRUE\n";
283 std::cout <<
"FALSE\n";
290 std::cout <<
"TRUE\n";
virtual size_t no_variables() const override
virtual void write_dimacs_cnf(std::ostream &out) const
mstreamt & statistics() const
mstreamt & status() const
tvt l_get(literalt a) const override
resultt do_prop_solve(const bvt &assumptions) override
virtual void write_dimacs_pb(std::ostream &out)
std::map< literalt, unsigned > pb_constraintmap
std::vector< literalt > bvt
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
int sscanf(const char *restrict s, const char *restrict format,...)
char * getenv(const char *name)