14#ifndef OR_TOOLS_SAT_ALL_DIFFERENT_H_
15#define OR_TOOLS_SAT_ALL_DIFFERENT_H_
22#include "absl/container/flat_hash_map.h"
23#include "absl/types/span.h"
39 const std::vector<IntegerVariable>& vars);
50 const std::vector<IntegerVariable>& vars);
52 const std::vector<AffineExpression>& expressions);
65 const std::vector<IntegerVariable>& variables);
86 bool MakeAugmentingPath(
int start);
89 inline LiteralIndex VariableLiteralIndexOf(
int x, int64_t
value);
90 inline bool VariableHasPossibleValue(
int x, int64_t
value);
96 const int num_variables_;
97 const std::vector<IntegerVariable> variables_;
98 int64_t min_all_values_;
99 int64_t num_all_values_;
100 std::vector<int64_t> variable_min_value_;
101 std::vector<int64_t> variable_max_value_;
102 std::vector<std::vector<LiteralIndex>> variable_literal_index_;
108 std::vector<std::vector<int>> successor_;
109 std::vector<bool> value_visited_;
110 std::vector<bool> variable_visited_;
111 std::vector<int> value_to_variable_;
112 std::vector<int> variable_to_value_;
113 std::vector<int> prev_matching_;
114 std::vector<int> visiting_;
115 std::vector<int> variable_visited_from_;
133 std::vector<std::vector<int>> residual_graph_successors_;
134 std::vector<int> component_number_;
164 struct CachedBounds {
171 void FillHallReason(IntegerValue hall_lb, IntegerValue hall_ub);
176 bool PropagateLowerBounds();
177 bool PropagateLowerBoundsInternal(IntegerValue min_lb,
178 absl::Span<CachedBounds> vars);
195 int FindStartIndexAndCompressPath(
int index);
197 int GetIndex(IntegerValue
value)
const {
200 return (
value - base_).value();
203 IntegerValue GetValue(
int index)
const {
return base_ + IntegerValue(
index); }
208 std::vector<CachedBounds> bounds_;
209 std::vector<CachedBounds> negated_bounds_;
212 std::vector<IntegerValue> hall_starts_;
213 std::vector<IntegerValue> hall_ends_;
217 std::vector<int> indices_to_clear_;
218 std::vector<int> index_to_start_index_;
219 std::vector<int> index_to_end_index_;
220 std::vector<bool> index_is_present_;
221 std::vector<AffineExpression> index_to_expr_;
224 std::vector<IntegerLiteral> integer_reason_;
#define DCHECK_GE(val1, val2)
#define DCHECK_LT(val1, val2)
void RegisterWith(GenericLiteralWatcher *watcher)
AllDifferentBoundsPropagator(const std::vector< AffineExpression > &expressions, IntegerTrail *integer_trail)
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 *)> AllDifferentBinary(const std::vector< IntegerVariable > &vars)
std::function< void(Model *)> AllDifferentOnBounds(const std::vector< AffineExpression > &expressions)
Collection of objects used to extend the Constraint Solver library.