diff --git a/ortools/sat/table.cc b/ortools/sat/table.cc index cadc78a5f4..8c49e25e5b 100644 --- a/ortools/sat/table.cc +++ b/ortools/sat/table.cc @@ -314,7 +314,8 @@ void AddTableConstraint(const std::vector& vars, } } - if (prefixes_are_all_different && num_prefix_tuples < max_num_prefix_tuples) { + if (prefixes_are_all_different && num_prefix_tuples < max_num_prefix_tuples && + max_num_prefix_tuples < 4 * num_prefix_tuples) { // If we have a table of 'unique prefix' => value tuples. // This table will likely not be negated, as the density of tuples will be // less than 1 / size of the domain of the last variable.