Skip to content

Commit b4de297

Browse files
committed
[CP-SAT] improve alldiff presolve
1 parent e269401 commit b4de297

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ortools/sat/cp_model_presolve.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,7 +5536,8 @@ bool CpModelPresolver::PresolveAllDiff(ConstraintProto* ct) {
55365536

55375537
// Detect duplicate expressions, and remove impossible values from expressions
55385538
// with the same variable.
5539-
absl::flat_hash_map<int, std::vector<std::pair<int64_t, int64_t>>> terms;
5539+
// We use btree_map to have a deterministic order.
5540+
absl::btree_map<int, std::vector<std::pair<int64_t, int64_t>>> terms;
55405541
std::vector<int64_t> forbidden_values;
55415542
for (const LinearExpressionProto& expr : all_diff.exprs()) {
55425543
if (expr.vars_size() != 1) continue;
@@ -5598,7 +5599,7 @@ bool CpModelPresolver::PresolveAllDiff(ConstraintProto* ct) {
55985599
}
55995600

56005601
if (all_diff.exprs_size() == union_of_domains.Size()) {
5601-
absl::flat_hash_map<int64_t, UniqueNonNegativeValue> value_to_index;
5602+
absl::btree_map<int64_t, UniqueNonNegativeValue> value_to_index;
56025603
for (int i = 0; i < all_diff.exprs_size(); ++i) {
56035604
const LinearExpressionProto& expr = all_diff.exprs(i);
56045605
DCHECK_EQ(expr.vars_size(), 1);

0 commit comments

Comments
 (0)