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_;
345 bool AddConstraint(absl::Span<const Literal> enforcement_literals,
346 absl::Span<const IntegerVariable> vars,
347 absl::Span<const IntegerValue> coeffs,
348 IntegerValue upper_bound);
351 void Explain(
int id, IntegerValue propagation_slack,
352 IntegerVariable var_to_explain,
int trail_index,
353 std::vector<Literal>* literals_reason,
354 std::vector<int>* trail_indices_reason)
final;
357 push_affine_ub_for_binary_relations_ =
true;
368 struct ConstraintInfo {
369 unsigned int enf_status : 2;
371 unsigned int all_coeffs_are_one : 1;
372 unsigned int initial_size : 29;
374 EnforcementId enf_id;
377 IntegerValue rev_rhs;
380 static_assert(
sizeof(ConstraintInfo) == 24,
381 "ERROR_ConstraintInfo_is_not_well_compacted");
383 absl::Span<IntegerValue> GetCoeffs(
const ConstraintInfo& info);
384 absl::Span<IntegerVariable> GetVariables(
const ConstraintInfo& info);
388 void OnVariableChange(IntegerVariable var, IntegerValue lb,
int id);
391 ABSL_MUST_USE_RESULT
bool PropagateOneConstraint(
int id);
392 ABSL_MUST_USE_RESULT
bool PropagateInfeasibleConstraint(
int id,
394 ABSL_MUST_USE_RESULT
bool ReportConflictingCycle();
395 ABSL_MUST_USE_RESULT
bool DisassembleSubtree(
int root_id,
int num_tight);
402 std::pair<IntegerValue, IntegerValue> GetCycleCoefficients(
403 int id, IntegerVariable var, IntegerVariable next_var);
408 std::pair<IntegerValue, int> AnalyzeConstraint(
int id);
410 void ClearPropagatedBy();
411 void CanonicalizeConstraint(
int id);
412 void AddToQueueIfNeeded(
int id);
413 void SetPropagatedBy(IntegerVariable var,
int id);
414 std::string ConstraintDebugString(
int id);
418 IntegerTrail* integer_trail_;
419 EnforcementPropagator* enforcement_propagator_;
420 GenericLiteralWatcher* watcher_;
422 RevIntRepository* rev_int_repository_;
423 RevIntegerValueRepository* rev_integer_value_repository_;
424 PrecedenceRelations* precedences_;
425 BinaryRelationsMaps* binary_relations_;
426 ModelRandomGenerator* random_;
427 SharedStatistics* shared_stats_ =
nullptr;
428 const int watcher_id_;
430 bool push_affine_ub_for_binary_relations_ =
false;
433 int previous_level_ = 0;
442 std::deque<ConstraintInfo> infos_;
443 std::vector<IntegerValue> initial_rhs_;
446 std::vector<IntegerVariable> variables_buffer_;
447 std::vector<IntegerValue> coeffs_buffer_;
448 std::vector<IntegerValue> buffer_of_ones_;
451 std::vector<IntegerValue> max_variations_;
454 std::vector<IntegerLiteral> integer_reason_;
455 std::vector<IntegerValue> reason_coeffs_;
456 std::vector<Literal> literal_reason_;
460 std::deque<int> propagation_queue_;
463 ConstraintPropagationOrder order_;
467 int rev_unenforced_size_ = 0;
468 std::vector<int> unenforced_constraints_;
473 var_to_constraint_ids_;
480 std::vector<int> id_to_propagation_count_;
483 struct DissasembleQueueEntry {
486 IntegerValue increase;
488 std::vector<DissasembleQueueEntry> disassemble_queue_;
489 std::vector<DissasembleQueueEntry> disassemble_branch_;
490 std::vector<std::pair<IntegerVariable, IntegerValue>> disassemble_candidates_;
493 int64_t num_terms_for_dtime_update_ = 0;
496 int64_t num_pushes_ = 0;
497 int64_t num_enforcement_pushes_ = 0;
498 int64_t num_cycles_ = 0;
499 int64_t num_failed_cycles_ = 0;
500 int64_t num_short_reasons_ = 0;
501 int64_t num_long_reasons_ = 0;
502 int64_t num_scanned_ = 0;
503 int64_t num_explored_in_disassemble_ = 0;
504 int64_t num_delayed_ = 0;
505 int64_t num_bool_aborts_ = 0;
506 int64_t num_loop_aborts_ = 0;
507 int64_t num_ignored_ = 0;