14#ifndef OR_TOOLS_SAT_PRECEDENCES_H_
15#define OR_TOOLS_SAT_PRECEDENCES_H_
22#include "absl/container/inlined_vector.h"
59 watcher_id_(watcher_->Register(this)) {
83 IntegerVariable offset_var);
90 IntegerValue offset,
Literal l);
95 IntegerVariable offset_var,
119 std::vector<IntegerPrecedences>* output);
121 std::vector<Literal>* literal_reason,
122 std::vector<IntegerLiteral>* integer_reason)
const;
136 DEFINE_INT_TYPE(OptionalArcIndex,
int);
141 int AddGreaterThanAtLeastOneOfConstraintsFromClause(
142 const absl::Span<const Literal> clause,
Model*
model);
148 int AddGreaterThanAtLeastOneOfConstraintsWithClauseAutoDetection(
153 IntegerVariable tail_var;
154 IntegerVariable head_var;
157 IntegerVariable offset_var;
160 absl::InlinedVector<Literal, 6> presence_literals;
164 mutable bool is_marked;
172 void AdjustSizeFor(IntegerVariable i);
173 void AddArc(IntegerVariable
tail, IntegerVariable
head, IntegerValue offset,
174 IntegerVariable offset_var,
175 absl::Span<const Literal> presence_literals);
179 bool EnqueueAndCheck(
const ArcInfo& arc, IntegerValue new_head_lb,
181 IntegerValue ArcOffset(
const ArcInfo& arc)
const;
185 void PropagateOptionalArcs(
Trail* trail);
203 void InitializeBFQueueWithModifiedNodes();
204 bool BellmanFordTarjan(
Trail* trail);
205 bool DisassembleSubtree(
int source,
int target,
206 std::vector<bool>* can_be_skipped);
208 std::vector<Literal>* must_be_all_true,
209 std::vector<Literal>* literal_reason,
210 std::vector<IntegerLiteral>* integer_reason);
211 void CleanUpMarkedArcsAndParents();
215 bool NoPropagationLeft(
const Trail& trail)
const;
247 impacted_potential_arcs_;
256 bool operator<(
const SortedVar& other)
const {
260 std::vector<SortedVar> tmp_sorted_vars_;
261 std::vector<IntegerPrecedences> tmp_precedences_;
271 literal_to_new_impacted_arcs_;
275 std::vector<Literal> literal_reason_;
276 std::vector<IntegerLiteral> integer_reason_;
281 std::deque<int> bf_queue_;
282 std::vector<bool> bf_in_queue_;
283 std::vector<bool> bf_can_be_skipped_;
284 std::vector<ArcIndex> bf_parent_arc_of_;
287 std::vector<int> tmp_vector_;
297 IntegerVariable i2) {
303 IntegerVariable i1, IntegerVariable i2, IntegerValue offset) {
315 IntegerVariable i1, IntegerVariable i2, IntegerValue offset,
Literal l) {
320 IntegerVariable i1, IntegerVariable i2, IntegerVariable offset_var) {
321 AddArc(i1, i2, IntegerValue(0), offset_var, {});
325 IntegerVariable i1, IntegerVariable i2, IntegerValue offset,
326 IntegerVariable offset_var, absl::Span<const Literal> presence_literals) {
327 AddArc(i1, i2, offset, offset_var, presence_literals);
348 a,
b, IntegerValue(offset));
361 IntegerVariable
a, IntegerVariable
b, int64_t ub,
362 const std::vector<Literal>& enforcement_literals) {
383 IntegerVariable
a, IntegerVariable
b, IntegerVariable c, int64_t ub,
384 const std::vector<Literal>& enforcement_literals) {
388 enforcement_literals);
421 IntegerVariable
a, IntegerVariable
b, int64_t offset,
Literal is_le) {
437 IntegerVariable
a, IntegerVariable
b, absl::Span<const Literal> literals) {
447 IntegerVariable
a, IntegerVariable
b, int64_t offset,
Literal is_le) {
void SetPropagatorPriority(int id, int priority)
void RegisterWatcher(SparseBitset< IntegerVariable > *p)
Class that owns everything related to a particular optimization model.
void AddPrecedenceReason(int arc_index, IntegerValue min_offset, std::vector< Literal > *literal_reason, std::vector< IntegerLiteral > *integer_reason) const
void AddConditionalPrecedence(IntegerVariable i1, IntegerVariable i2, Literal l)
void AddConditionalPrecedenceWithOffset(IntegerVariable i1, IntegerVariable i2, IntegerValue offset, Literal l)
void AddPrecedenceWithOffset(IntegerVariable i1, IntegerVariable i2, IntegerValue offset)
void AddPrecedenceWithAllOptions(IntegerVariable i1, IntegerVariable i2, IntegerValue offset, IntegerVariable offset_var, absl::Span< const Literal > presence_literals)
void ComputePrecedences(const std::vector< IntegerVariable > &vars, std::vector< IntegerPrecedences > *output)
void AddPrecedence(IntegerVariable i1, IntegerVariable i2)
int AddGreaterThanAtLeastOneOfConstraints(Model *model)
PrecedencesPropagator(Model *model)
void AddPrecedenceWithVariableOffset(IntegerVariable i1, IntegerVariable i2, IntegerVariable offset_var)
void Untrail(const Trail &trail, int trail_index) final
bool PropagateOutgoingArcs(IntegerVariable var)
std::function< void(Model *)> Equality(IntegerVariable v, int64_t value)
std::function< void(Model *)> LowerOrEqualWithOffset(IntegerVariable a, IntegerVariable b, int64_t offset)
std::function< void(Model *)> ConditionalLowerOrEqual(IntegerVariable a, IntegerVariable b, Literal is_le)
std::function< BooleanVariable(Model *)> NewBooleanVariable()
std::function< void(Model *)> LowerOrEqual(IntegerVariable v, int64_t ub)
std::function< void(Model *)> Sum2LowerOrEqual(IntegerVariable a, IntegerVariable b, int64_t ub)
const IntegerVariable kNoIntegerVariable(-1)
std::function< void(Model *)> NotEqual(IntegerVariable a, IntegerVariable b)
std::function< void(Model *)> EqualityWithOffset(IntegerVariable a, IntegerVariable b, int64_t offset)
std::function< void(Model *)> ReifiedBoolAnd(const std::vector< Literal > &literals, Literal r)
std::vector< IntegerVariable > NegationOf(const std::vector< IntegerVariable > &vars)
std::function< void(Model *)> GreaterOrEqual(IntegerVariable v, int64_t lb)
std::function< void(Model *)> ConditionalSum2LowerOrEqual(IntegerVariable a, IntegerVariable b, int64_t ub, const std::vector< Literal > &enforcement_literals)
std::function< void(Model *)> Sum3LowerOrEqual(IntegerVariable a, IntegerVariable b, IntegerVariable c, int64_t ub)
std::function< void(Model *)> ReifiedLowerOrEqualWithOffset(IntegerVariable a, IntegerVariable b, int64_t offset, Literal is_le)
std::function< void(Model *)> ReifiedEqualityWithOffset(IntegerVariable a, IntegerVariable b, int64_t offset, Literal is_eq)
std::function< void(Model *)> ConditionalSum3LowerOrEqual(IntegerVariable a, IntegerVariable b, IntegerVariable c, int64_t ub, const std::vector< Literal > &enforcement_literals)
std::function< void(Model *)> ConditionalLowerOrEqualWithOffset(IntegerVariable a, IntegerVariable b, int64_t offset, Literal is_le)
std::function< void(Model *)> ReifiedEquality(IntegerVariable a, IntegerVariable b, Literal is_eq)
Collection of objects used to extend the Constraint Solver library.