81 absl::Span<const Literal> enforcement,
86 std::vector<Literal>* reason)
const;
91 EnforcementId
id, absl::Span<const Literal> literal_reason,
92 absl::Span<const IntegerLiteral> integer_reason);
102 if (
id < 0)
return {};
107 absl::Span<Literal> GetSpan(EnforcementId
id);
108 absl::Span<const Literal> GetSpan(EnforcementId
id)
const;
113 LiteralIndex ProcessIdOnTrue(
Literal watched, EnforcementId
id);
125 std::vector<Literal> buffer_;
133 std::vector<std::pair<EnforcementId, EnforcementStatus>> untrail_stack_;
134 int rev_stack_size_ = 0;
135 int64_t rev_stamp_ = 0;
141 std::vector<Literal> temp_literals_;
142 std::vector<Literal> temp_reason_;
144 std::vector<EnforcementId> ids_to_fix_until_next_root_level_;
316 bool AddConstraint(absl::Span<const Literal> enforcement_literals,
317 absl::Span<const IntegerVariable> vars,
318 absl::Span<const IntegerValue> coeffs,
319 IntegerValue upper_bound);
322 void Explain(
int id, IntegerValue propagation_slack,
323 IntegerVariable var_to_explain,
int trail_index,
324 std::vector<Literal>* literals_reason,
325 std::vector<int>* trail_indices_reason)
final;
335 struct ConstraintInfo {
336 unsigned int enf_status : 2;
338 unsigned int all_coeffs_are_one : 1;
339 unsigned int initial_size : 29;
341 EnforcementId enf_id;
344 IntegerValue rev_rhs;
347 static_assert(
sizeof(ConstraintInfo) == 24,
348 "ERROR_ConstraintInfo_is_not_well_compacted");
350 absl::Span<IntegerValue> GetCoeffs(
const ConstraintInfo& info);
351 absl::Span<IntegerVariable> GetVariables(
const ConstraintInfo& info);
355 void OnVariableChange(IntegerVariable var, IntegerValue lb,
int id);
358 ABSL_MUST_USE_RESULT
bool PropagateOneConstraint(
int id);
359 ABSL_MUST_USE_RESULT
bool PropagateInfeasibleConstraint(
int id,
361 ABSL_MUST_USE_RESULT
bool ReportConflictingCycle();
362 ABSL_MUST_USE_RESULT
bool DisassembleSubtree(
int root_id,
int num_tight);
369 std::pair<IntegerValue, IntegerValue> GetCycleCoefficients(
370 int id, IntegerVariable var, IntegerVariable next_var);
375 std::pair<IntegerValue, int> AnalyzeConstraint(
int id);
377 void ClearPropagatedBy();
378 void CanonicalizeConstraint(
int id);
379 void AddToQueueIfNeeded(
int id);
380 void SetPropagatedBy(IntegerVariable var,
int id);
381 std::string ConstraintDebugString(
int id);
394 const int watcher_id_;
397 int previous_level_ = 0;
406 std::deque<ConstraintInfo> infos_;
407 std::vector<IntegerValue> initial_rhs_;
410 std::vector<IntegerVariable> variables_buffer_;
411 std::vector<IntegerValue> coeffs_buffer_;
412 std::vector<IntegerValue> buffer_of_ones_;
415 std::vector<IntegerValue> max_variations_;
418 std::vector<IntegerLiteral> integer_reason_;
419 std::vector<IntegerValue> reason_coeffs_;
420 std::vector<Literal> literal_reason_;
424 std::deque<int> propagation_queue_;
431 int rev_unenforced_size_ = 0;
432 std::vector<int> unenforced_constraints_;
437 var_to_constraint_ids_;
444 std::vector<int> id_to_propagation_count_;
447 struct DissasembleQueueEntry {
450 IntegerValue increase;
452 std::vector<DissasembleQueueEntry> disassemble_queue_;
453 std::vector<DissasembleQueueEntry> disassemble_branch_;
454 std::vector<std::pair<IntegerVariable, IntegerValue>> disassemble_candidates_;
457 int64_t num_terms_for_dtime_update_ = 0;
460 int64_t num_pushes_ = 0;
461 int64_t num_enforcement_pushes_ = 0;
462 int64_t num_cycles_ = 0;
463 int64_t num_failed_cycles_ = 0;
464 int64_t num_short_reasons_ = 0;
465 int64_t num_long_reasons_ = 0;
466 int64_t num_scanned_ = 0;
467 int64_t num_explored_in_disassemble_ = 0;
468 int64_t num_delayed_ = 0;
469 int64_t num_bool_aborts_ = 0;
470 int64_t num_loop_aborts_ = 0;
471 int64_t num_ignored_ = 0;