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);
60 const std::vector<IntegerVariable>& variables);
81 bool MakeAugmentingPath(
int start);
84 inline LiteralIndex VariableLiteralIndexOf(
int x, int64_t
value);
85 inline bool VariableHasPossibleValue(
int x, int64_t
value);
91 const int num_variables_;
92 const std::vector<IntegerVariable> variables_;
93 int64_t min_all_values_;
94 int64_t num_all_values_;
95 std::vector<int64_t> variable_min_value_;
96 std::vector<int64_t> variable_max_value_;
97 std::vector<std::vector<LiteralIndex>> variable_literal_index_;
103 std::vector<std::vector<int>> successor_;
104 std::vector<bool> value_visited_;
105 std::vector<bool> variable_visited_;
106 std::vector<int> value_to_variable_;
107 std::vector<int> variable_to_value_;
108 std::vector<int> prev_matching_;
109 std::vector<int> visiting_;
110 std::vector<int> variable_visited_from_;
128 std::vector<std::vector<int>> residual_graph_successors_;
129 std::vector<int> component_number_;
166 void FillHallReason(IntegerValue hall_lb, IntegerValue hall_ub);
171 bool PropagateLowerBounds();
172 bool PropagateLowerBoundsInternal(IntegerValue min_lb,
173 absl::Span<VarValue> vars);
190 int FindStartIndexAndCompressPath(
int index);
192 int GetIndex(IntegerValue
value)
const {
195 return (
value - base_).value();
198 IntegerValue GetValue(
int index)
const {
return base_ + IntegerValue(
index); }
200 bool PointIsPresent(
int index)
const {
207 std::vector<VarValue> vars_;
208 std::vector<VarValue> negated_vars_;
211 std::vector<IntegerValue> hall_starts_;
212 std::vector<IntegerValue> hall_ends_;
216 std::vector<int> indices_to_clear_;
217 std::vector<int> index_to_start_index_;
218 std::vector<int> index_to_end_index_;
219 std::vector<IntegerVariable> index_to_var_;
222 std::vector<IntegerLiteral> integer_reason_;
#define DCHECK_GE(val1, val2)
#define DCHECK_LT(val1, val2)
AllDifferentBoundsPropagator(const std::vector< IntegerVariable > &vars, IntegerTrail *integer_trail)
void RegisterWith(GenericLiteralWatcher *watcher)
void RegisterWith(GenericLiteralWatcher *watcher)
AllDifferentConstraint(std::vector< IntegerVariable > variables, IntegerEncoder *encoder, Trail *trail, IntegerTrail *integer_trail)
std::function< void(Model *)> AllDifferentAC(const std::vector< IntegerVariable > &variables)
std::function< void(Model *)> AllDifferentOnBounds(const std::vector< IntegerVariable > &vars)
const IntegerVariable kNoIntegerVariable(-1)
std::function< void(Model *)> AllDifferentBinary(const std::vector< IntegerVariable > &vars)
Collection of objects used to extend the Constraint Solver library.