14 #ifndef OR_TOOLS_SAT_ALL_DIFFERENT_H_ 15 #define OR_TOOLS_SAT_ALL_DIFFERENT_H_ 22 #include "absl/container/flat_hash_map.h" 36 const std::vector<IntegerVariable>& vars);
47 const std::vector<IntegerVariable>& vars);
49 const std::vector<AffineExpression>& expressions);
62 const std::vector<IntegerVariable>& variables);
83 bool MakeAugmentingPath(
int start);
86 inline LiteralIndex VariableLiteralIndexOf(
int x, int64_t
value);
87 inline bool VariableHasPossibleValue(
int x, int64_t
value);
93 const int num_variables_;
94 const std::vector<IntegerVariable> variables_;
95 int64_t min_all_values_;
96 int64_t num_all_values_;
97 std::vector<int64_t> variable_min_value_;
98 std::vector<int64_t> variable_max_value_;
99 std::vector<std::vector<LiteralIndex>> variable_literal_index_;
105 std::vector<std::vector<int>> successor_;
106 std::vector<bool> value_visited_;
107 std::vector<bool> variable_visited_;
108 std::vector<int> value_to_variable_;
109 std::vector<int> variable_to_value_;
110 std::vector<int> prev_matching_;
111 std::vector<int> visiting_;
112 std::vector<int> variable_visited_from_;
130 std::vector<std::vector<int>> residual_graph_successors_;
131 std::vector<int> component_number_;
161 struct CachedBounds {
168 void FillHallReason(IntegerValue hall_lb, IntegerValue hall_ub);
173 bool PropagateLowerBounds();
174 bool PropagateLowerBoundsInternal(IntegerValue min_lb,
175 absl::Span<CachedBounds> vars);
192 int FindStartIndexAndCompressPath(
int index);
194 int GetIndex(IntegerValue
value)
const {
197 return (
value - base_).value();
200 IntegerValue GetValue(
int index)
const {
return base_ + IntegerValue(
index); }
205 std::vector<CachedBounds> bounds_;
206 std::vector<CachedBounds> negated_bounds_;
209 std::vector<IntegerValue> hall_starts_;
210 std::vector<IntegerValue> hall_ends_;
214 std::vector<int> indices_to_clear_;
215 std::vector<int> index_to_start_index_;
216 std::vector<int> index_to_end_index_;
217 std::vector<bool> index_is_present_;
218 std::vector<AffineExpression> index_to_expr_;
221 std::vector<IntegerLiteral> integer_reason_;
229 #endif // OR_TOOLS_SAT_ALL_DIFFERENT_H_ std::function< void(Model *)> AllDifferentBinary(const std::vector< IntegerVariable > &vars)
void RegisterWith(GenericLiteralWatcher *watcher)
AllDifferentBoundsPropagator(const std::vector< AffineExpression > &expressions, IntegerTrail *integer_trail)
Class that owns everything related to a particular optimization model.
#define DCHECK_GE(val1, val2)
std::function< void(Model *)> AllDifferentOnBounds(const std::vector< IntegerVariable > &vars)
AllDifferentConstraint(std::vector< IntegerVariable > variables, IntegerEncoder *encoder, Trail *trail, IntegerTrail *integer_trail)
std::function< void(Model *)> AllDifferentAC(const std::vector< IntegerVariable > &variables)
Collection of objects used to extend the Constraint Solver library.
void RegisterWith(GenericLiteralWatcher *watcher)
#define DCHECK_LT(val1, val2)