Skip to content

Commit 0615832

Browse files
committed
fix
1 parent 0f20448 commit 0615832

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

ortools/sat/sat_runner.cc

+14-11
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,24 @@ bool LoadProblem(const std::string& filename, absl::string_view hint_file,
163163
default:
164164
break;
165165
}
166-
std::string line;
167-
for (int i = 0; i < num_variables; ++i) {
168-
if (r.solution(i)) {
169-
absl::StrAppend(&line, "x", i + 1, " ");
170-
} else {
171-
absl::StrAppend(&line, "-x", i + 1, " ");
166+
if (r.status() == CpSolverStatus::OPTIMAL ||
167+
r.status() == CpSolverStatus::FEASIBLE) {
168+
std::string line;
169+
for (int i = 0; i < num_variables; ++i) {
170+
if (r.solution(i)) {
171+
absl::StrAppend(&line, "x", i + 1, " ");
172+
} else {
173+
absl::StrAppend(&line, "-x", i + 1, " ");
174+
}
175+
if (line.size() >= 75) {
176+
std::cout << "v " << line << std::endl;
177+
line.clear();
178+
}
172179
}
173-
if (line.size() >= 75) {
180+
if (!line.empty()) {
174181
std::cout << "v " << line << std::endl;
175-
line.clear();
176182
}
177183
}
178-
if (!line.empty()) {
179-
std::cout << "v " << line << std::endl;
180-
}
181184
};
182185
}
183186
} else if (absl::EndsWith(filename, ".cnf") ||

0 commit comments

Comments
 (0)