Skip to content

Commit 7018ab4

Browse files
Clean up commented out code
1 parent 2529211 commit 7018ab4

File tree

1 file changed

+59
-21
lines changed

1 file changed

+59
-21
lines changed

src/solvers/sat/pbs_dimacs_cnf.cpp

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ Author: Alex Groce
1111
#include <cstdlib>
1212
#include <cstring>
1313
#include <fstream>
14+
15+
#ifdef DEBUG
1416
#include <iostream>
17+
#endif
1518

1619
void pbs_dimacs_cnft::write_dimacs_pb(std::ostream &out)
1720
{
1821
double d_sum = 0;
1922

20-
// std::cout << "enter: No Lit.=" << no_variables () << "\n";
23+
#ifdef DEBUG
24+
std::cout << "enter: No Lit.=" << no_variables() << "\n";
25+
#endif
2126

2227
for(std::map<literalt, unsigned>::const_iterator it =
2328
pb_constraintmap.begin();
@@ -51,12 +56,16 @@ void pbs_dimacs_cnft::write_dimacs_pb(std::ostream &out)
5156
out << "v" << dimacs_lit << " c" << lit_entry.second << "\n";
5257
}
5358

54-
// std::cout << "exit: No Lit.=" << no_variables () << "\n";
59+
#ifdef DEBUG
60+
std::cout << "exit: No Lit.=" << no_variables() << "\n";
61+
#endif
5562
}
5663

5764
bool pbs_dimacs_cnft::pbs_solve()
5865
{
59-
// std::cout << "solve: No Lit.=" << no_variables () << "\n";
66+
#ifdef DEBUG
67+
std::cout << "solve: No Lit.=" << no_variables() << "\n";
68+
#endif
6069

6170
std::string command;
6271

@@ -69,8 +78,10 @@ bool pbs_dimacs_cnft::pbs_solve()
6978

7079
command += "pbs";
7180

72-
// std::cout << "PBS COMMAND IS: " << command << "\n";
73-
/*
81+
#ifdef DEBUG
82+
std::cout << "PBS COMMAND IS: " << command << "\n";
83+
#endif
84+
#if 0
7485
if (!(getenv("PBS_PATH")==NULL))
7586
{
7687
command=getenv("PBS_PATH");
@@ -80,7 +91,7 @@ bool pbs_dimacs_cnft::pbs_solve()
8091
error ("Unable to read PBS_PATH environment variable.\n");
8192
return false;
8293
}
83-
*/
94+
#endif
8495

8596
command += " -f temp.cnf";
8697

@@ -93,7 +104,10 @@ bool pbs_dimacs_cnft::pbs_solve()
93104
}
94105
else
95106
{
96-
// std::cout << "NO BINARY SEARCH" << "\n";
107+
#ifdef DEBUG
108+
std::cout << "NO BINARY SEARCH"
109+
<< "\n";
110+
#endif
97111
command += " -S 1000 -D 1 -I -a";
98112
}
99113
}
@@ -130,43 +144,57 @@ bool pbs_dimacs_cnft::pbs_solve()
130144
strstr(line.c_str(), "Variable Assignments Satisfying CNF Formula:") !=
131145
nullptr)
132146
{
133-
// print ("Reading assignments...\n");
134-
// std::cout << "No literals: " << no_variables() << "\n";
147+
#ifdef DEBUG
148+
std::cout << "Reading assignments...\n";
149+
std::cout << "No literals: " << no_variables() << "\n";
150+
#endif
135151
satisfied = true;
136152
assigned.clear();
137153
for(size_t i = 0; (file && (i < no_variables())); ++i)
138154
{
139155
file >> v;
140156
if(v > 0)
141157
{
142-
// std::cout << v << " ";
158+
#ifdef DEBUG
159+
std::cout << v << " ";
160+
#endif
143161
assigned.insert(v);
144162
}
145163
}
146-
// std::cout << "\n";
147-
// print ("Finished reading assignments.\n");
164+
#ifdef DEBUG
165+
std::cout << "\n";
166+
std::cout << "Finished reading assignments.\n";
167+
#endif
148168
}
149169
else if(strstr(line.c_str(), "SAT... SUM") != nullptr)
150170
{
151-
// print (line);
171+
#ifdef DEBUG
172+
std::cout << line;
173+
#endif
152174
sscanf(line.c_str(), "%*s %*s %*s %d", &opt_sum);
153175
}
154176
else if(strstr(line.c_str(), "SAT - All implied") != nullptr)
155177
{
156-
// print (line);
178+
#ifdef DEBUG
179+
std::cout << line;
180+
#endif
157181
sscanf(
158182
line.c_str(),
159183
"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %d",
160184
&opt_sum);
161185
}
162186
else if(strstr(line.c_str(), "SAT... Solution") != nullptr)
163187
{
164-
// print(line);
188+
#ifdef DEBUG
189+
std::cout << line;
190+
#endif
165191
sscanf(line.c_str(), "%*s %*s %*s %d", &opt_sum);
166192
}
167193
else if(strstr(line.c_str(), "Optimal Soln") != nullptr)
168194
{
169-
// print(line);
195+
#ifdef DEBUG
196+
std::cout << line;
197+
#endif
170198
if(strstr(line.c_str(), "time out") != nullptr)
171199
{
172200
status() << "WARNING: TIMED OUT. SOLUTION MAY BE INCORRECT." << eom;
@@ -220,7 +248,9 @@ tvt pbs_dimacs_cnft::l_get(literalt a) const
220248
{
221249
int dimacs_lit = a.dimacs();
222250

223-
// std::cout << a << " / " << dimacs_lit << "=";
251+
#ifdef DEBUG
252+
std::cout << a << " / " << dimacs_lit << "=";
253+
#endif
224254

225255
bool neg = (dimacs_lit < 0);
226256
if(neg)
@@ -232,25 +262,33 @@ tvt pbs_dimacs_cnft::l_get(literalt a) const
232262
{
233263
if(f == assigned.end())
234264
{
235-
// std::cout << "FALSE" << "\n";
265+
#ifdef DEBUG
266+
std::cout << "FALSE\n";
267+
#endif
236268
return tvt(false);
237269
}
238270
else
239271
{
240-
// std::cout << "TRUE" << "\n";
272+
#ifdef DEBUG
273+
std::cout << "TRUE\n";
274+
#endif
241275
return tvt(true);
242276
}
243277
}
244278
else
245279
{
246280
if(f != assigned.end())
247281
{
248-
// std::cout << "FALSE" << "\n";
282+
#ifdef DEBUG
283+
std::cout << "FALSE\n";
284+
#endif
249285
return tvt(false);
250286
}
251287
else
252288
{
253-
// std::cout << "TRUE" << "\n";
289+
#ifdef DEBUG
290+
std::cout << "TRUE\n";
291+
#endif
254292
return tvt(true);
255293
}
256294
}

0 commit comments

Comments
 (0)