354 trail_(model->GetOrCreate<
Trail>()),
355 time_limit_(model->GetOrCreate<
TimeLimit>()) {}
360 int NumClausesContaining(
Literal l);
361 void UpdatePriorityQueue(BooleanVariable var);
362 bool CrossProduct(BooleanVariable var);
363 void DeleteClause(
SatClause* sat_clause);
364 void DeleteAllClausesContaining(
Literal literal);
365 void AddClause(absl::Span<const Literal> clause);
374 template <
bool score_only,
bool with_binary_only>
375 bool ResolveAllClauseContaining(
Literal lit);
385 int propagation_index_;
388 int64_t num_inspected_literals_ = 0;
389 int64_t num_simplifications_ = 0;
390 int64_t num_blocked_clauses_ = 0;
391 int64_t num_eliminated_variables_ = 0;
392 int64_t num_literals_diff_ = 0;
393 int64_t num_clauses_diff_ = 0;
396 int64_t score_threshold_;
400 std::vector<Literal> resolvant_;
404 struct VariableWithPriority {
409 int Index()
const {
return var.value(); }
410 bool operator<(
const VariableWithPriority& o)
const {
411 return priority < o.priority;
414 IntegerPriorityQueue<VariableWithPriority> queue_;
417 util_intops::StrongVector<BooleanVariable, bool> in_need_to_be_updated_;
418 std::vector<BooleanVariable> need_to_be_updated_;
424 util_intops::StrongVector<ClauseIndex, SatClause*> clauses_;
425 util_intops::StrongVector<LiteralIndex, std::vector<ClauseIndex>>
427 util_intops::StrongVector<LiteralIndex, int> literal_to_num_clauses_;
451 sat_solver_(model->GetOrCreate<
SatSolver>()),
452 trail_(model->GetOrCreate<
Trail>()),
459 time_limit_(model->GetOrCreate<
TimeLimit>()) {}
471 : gates_type(t), gates_inputs(g) {}
472 std::size_t operator()(GateId gate_id)
const {
473 return absl::HashOf((*gates_type)[gate_id], (*gates_inputs)[gate_id]);
476 const CompactVectorVector<GateId, LiteralIndex>* gates_inputs;
480 explicit GateEq(util_intops::StrongVector<GateId, int>* t,
481 CompactVectorVector<GateId, LiteralIndex>* g)
482 : gates_type(t), gates_inputs(g) {}
483 bool operator()(GateId gate_a, GateId gate_b)
const {
484 if (gate_a == gate_b)
return true;
487 return ((*gates_type)[gate_a] == (*gates_type)[gate_b]) &&
488 ((*gates_inputs)[gate_a] == (*gates_inputs)[gate_b]);
490 const util_intops::StrongVector<GateId, int>* gates_type;
491 const CompactVectorVector<GateId, LiteralIndex>* gates_inputs;
504 void ExtractAndGatesAndFillShortTruthTables(PresolveTimer& timer);
508 void ExtractShortGates(PresolveTimer& timer);
512 int ProcessTruthTable(
513 absl::Span<const BooleanVariable> inputs,
SmallBitset truth_table,
514 absl::Span<const TruthTableId> ids_for_proof,
515 absl::Span<
const std::pair<Literal, Literal>> binary_used);
519 void AddToTruthTable(SatClause* clause,
520 absl::flat_hash_map<std::array<BooleanVariable, arity>,
525 int CanonicalizeShortGate(GateId
id);
527 const VariablesAssignment& assignment_;
528 SatSolver* sat_solver_;
530 BinaryImplicationGraph* implication_graph_;
531 ClauseManager* clause_manager_;
532 ClauseIdGenerator* clause_id_generator_;
533 LratProofHandler* lrat_proof_handler_;
534 SharedStatistics* shared_stats_;
535 SolverLogger* logger_;
536 TimeLimit* time_limit_;
538 SparseBitset<LiteralIndex> marked_;
539 SparseBitset<LiteralIndex> seen_;
540 SparseBitset<LiteralIndex> next_seen_;
558 static constexpr int kAndGateType = -1;
559 util_intops::StrongVector<GateId, LiteralIndex> gates_target_;
560 util_intops::StrongVector<GateId, int> gates_type_;
561 CompactVectorVector<GateId, LiteralIndex> gates_inputs_;
562 CompactVectorVector<GateId, const SatClause*> gates_clauses_;
570 absl::flat_hash_map<std::array<BooleanVariable, 2>,
SmallBitset> ids2_;
578 absl::flat_hash_map<std::array<BooleanVariable, 3>, TruthTableId> ids3_;
579 absl::flat_hash_map<std::array<BooleanVariable, 4>, TruthTableId> ids4_;
580 absl::flat_hash_map<std::array<BooleanVariable, 5>, TruthTableId> ids5_;
581 CompactVectorVector<TruthTableId, BooleanVariable> truth_tables_inputs_;
582 util_intops::StrongVector<TruthTableId, SmallBitset> truth_tables_bitset_;
583 CompactVectorVector<TruthTableId, SatClause*> truth_tables_clauses_;
586 std::vector<TruthTableId> tmp_ids_;
587 std::vector<SatClause*> tmp_clauses_;
591 std::vector<std::unique_ptr<SatClause>> tmp_binary_clauses_;
594 double total_dtime_ = 0.0;
595 double total_wtime_ = 0.0;
596 int64_t total_num_units_ = 0;
597 int64_t total_gates_ = 0;
598 int64_t total_equivalences_ = 0;
void AddClauseWithSpecialLiteral(Literal literal, absl::Span< const Literal > clause)