Skip to content

Commit 61adf12

Browse files
committed
[CP-SAT] more optimizations on lrat
1 parent 7950e22 commit 61adf12

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

ortools/sat/lrat_proof_handler.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -518,22 +518,25 @@ bool LratMerger::WriteInferredClause(
518518
return LratError();
519519
}
520520
}
521-
merged_proof_file_ << inferred_clause.clause_id();
521+
std::string& clause_str = tmp_clause_str_;
522+
clause_str.clear();
523+
absl::StrAppend(&clause_str, inferred_clause.clause_id());
522524
for (const int lit : inferred_clause.literals()) {
523-
merged_proof_file_ << " " << Literal(LiteralIndex(lit)).SignedValue();
525+
absl::StrAppend(&clause_str, " ", Literal(LiteralIndex(lit)).SignedValue());
524526
}
525-
merged_proof_file_ << " 0";
527+
absl::StrAppend(&clause_str, " 0");
526528
for (const int rup_clause_id : inferred_clause.rup_clause_ids()) {
527-
merged_proof_file_ << " " << rup_clause_id;
529+
absl::StrAppend(&clause_str, " ", rup_clause_id);
528530
}
529531
for (const LratInferredClause::RatInfo& rat_info :
530532
inferred_clause.rat_infos()) {
531-
merged_proof_file_ << " " << -rat_info.resolvant_id();
533+
absl::StrAppend(&clause_str, " ", -rat_info.resolvant_id());
532534
for (const int rup_clause_id : rat_info.rup_clause_ids()) {
533-
merged_proof_file_ << " " << rup_clause_id;
535+
absl::StrAppend(&clause_str, " ", rup_clause_id);
534536
}
535537
}
536-
merged_proof_file_ << " 0\n";
538+
absl::StrAppend(&clause_str, " 0\n");
539+
merged_proof_file_ << clause_str;
537540
last_written_global_id_ = GlobalId(inferred_clause.clause_id());
538541
return true;
539542
}

ortools/sat/lrat_proof_handler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class LratMerger {
135135
std::vector<Literal> tmp_literals_;
136136
std::vector<ClausePtr> tmp_proof_;
137137
std::vector<LratChecker::RatClauses> tmp_rat_clauses_;
138+
std::string tmp_clause_str_;
138139
};
139140

140141
// Handles the LRAT proof of a SAT problem by either checking it incrementally

0 commit comments

Comments
 (0)