14#ifndef OR_TOOLS_SAT_PRECEDENCES_H_
15#define OR_TOOLS_SAT_PRECEDENCES_H_
22#include "absl/container/inlined_vector.h"
23#include "absl/strings/string_view.h"
24#include "absl/types/span.h"
61 watcher_id_(watcher_->Register(this)) {
85 IntegerVariable offset_var);
92 IntegerValue offset,
Literal l);
97 IntegerVariable offset_var,
121 std::vector<IntegerPrecedences>* output);
123 std::vector<Literal>* literal_reason,
124 std::vector<IntegerLiteral>* integer_reason)
const;
138 DEFINE_STRONG_INDEX_TYPE(OptionalArcIndex);
143 int AddGreaterThanAtLeastOneOfConstraintsFromClause(
144 const absl::Span<const Literal> clause,
Model*
model);
150 int AddGreaterThanAtLeastOneOfConstraintsWithClauseAutoDetection(
155 IntegerVariable tail_var;
156 IntegerVariable head_var;
159 IntegerVariable offset_var;
162 absl::InlinedVector<Literal, 6> presence_literals;
166 mutable bool is_marked;
174 void AdjustSizeFor(IntegerVariable i);
175 void AddArc(IntegerVariable
tail, IntegerVariable
head, IntegerValue offset,
176 IntegerVariable offset_var,
177 absl::Span<const Literal> presence_literals);
181 bool EnqueueAndCheck(
const ArcInfo&
arc, IntegerValue new_head_lb,
183 IntegerValue ArcOffset(
const ArcInfo&
arc)
const;
187 void PropagateOptionalArcs(
Trail* trail);
205 void InitializeBFQueueWithModifiedNodes();
206 bool BellmanFordTarjan(
Trail* trail);
207 bool DisassembleSubtree(
int source,
int target,
208 std::vector<bool>* can_be_skipped);
210 std::vector<Literal>* must_be_all_true,
211 std::vector<Literal>* literal_reason,
212 std::vector<IntegerLiteral>* integer_reason);
213 void CleanUpMarkedArcsAndParents();
217 bool NoPropagationLeft(
const Trail& trail)
const;
249 impacted_potential_arcs_;
258 bool operator<(
const SortedVar& other)
const {
262 std::vector<SortedVar> tmp_sorted_vars_;
263 std::vector<IntegerPrecedences> tmp_precedences_;
273 literal_to_new_impacted_arcs_;
277 std::vector<Literal> literal_reason_;
278 std::vector<IntegerLiteral> integer_reason_;
283 std::deque<int> bf_queue_;
284 std::vector<bool> bf_in_queue_;
285 std::vector<bool> bf_can_be_skipped_;
286 std::vector<ArcIndex> bf_parent_arc_of_;
289 std::vector<int> tmp_vector_;
299 IntegerVariable i2) {
305 IntegerVariable i1, IntegerVariable i2, IntegerValue offset) {
317 IntegerVariable i1, IntegerVariable i2, IntegerValue offset,
Literal l) {
322 IntegerVariable i1, IntegerVariable i2, IntegerVariable offset_var) {
323 AddArc(i1, i2, IntegerValue(0), offset_var, {});
327 IntegerVariable i1, IntegerVariable i2, IntegerValue offset,
328 IntegerVariable offset_var, absl::Span<const Literal> presence_literals) {
329 AddArc(i1, i2, offset, offset_var, presence_literals);
350 a,
b, IntegerValue(offset));
363 IntegerVariable
a, IntegerVariable
b, int64_t ub,
364 const std::vector<Literal>& enforcement_literals) {
385 IntegerVariable
a, IntegerVariable
b, IntegerVariable c, int64_t ub,
386 const std::vector<Literal>& enforcement_literals) {
390 enforcement_literals);
423 IntegerVariable
a, IntegerVariable
b, int64_t offset,
Literal is_le) {
439 IntegerVariable
a, IntegerVariable
b, absl::Span<const Literal> literals) {
449 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.