@@ -797,7 +797,7 @@ void ProductDetector::UpdateRLTMaps(
797797
798798// TODO(user): limit work if too many ternary.
799799void ProductDetector::InitializeBooleanRLTCuts (
800- const absl::flat_hash_map<IntegerVariable, glop::ColIndex>& lp_vars,
800+ absl::Span< const IntegerVariable> lp_vars,
801801 const util_intops::StrongVector<IntegerVariable, double >& lp_values) {
802802 // TODO(user): Maybe we shouldn't reconstruct this every time, but it is hard
803803 // in case of multiple lps to make sure we don't use variables not in the lp
@@ -808,14 +808,19 @@ void ProductDetector::InitializeBooleanRLTCuts(
808808 // We will list all interesting multiplicative candidate for each variable.
809809 bool_rlt_candidates_.clear ();
810810 const int size = ternary_clauses_with_view_.size ();
811+ if (size == 0 ) return ;
812+
813+ is_in_lp_vars_.resize (integer_trail_->NumIntegerVariables ().value ());
814+ for (const IntegerVariable var : lp_vars) is_in_lp_vars_.Set (var);
815+
811816 for (int i = 0 ; i < size; i += 3 ) {
812817 const IntegerVariable var1 = ternary_clauses_with_view_[i];
813818 const IntegerVariable var2 = ternary_clauses_with_view_[i + 1 ];
814819 const IntegerVariable var3 = ternary_clauses_with_view_[i + 2 ];
815820
816- if (!lp_vars. contains ( PositiveVariable (var1)) ) continue ;
817- if (!lp_vars. contains ( PositiveVariable (var2)) ) continue ;
818- if (!lp_vars. contains ( PositiveVariable (var3)) ) continue ;
821+ if (!is_in_lp_vars_[ PositiveVariable (var1)] ) continue ;
822+ if (!is_in_lp_vars_[ PositiveVariable (var2)] ) continue ;
823+ if (!is_in_lp_vars_[ PositiveVariable (var3)] ) continue ;
819824
820825 // If we have l1 + l2 + l3 >= 1, then for all (i, j) pair we have
821826 // !li * !lj <= lk. We are looking for violation like this.
@@ -830,6 +835,10 @@ void ProductDetector::InitializeBooleanRLTCuts(
830835 UpdateRLTMaps (lp_values, NegationOf (var2), 1.0 - lp2, NegationOf (var3),
831836 1.0 - lp3, var1, lp1);
832837 }
838+
839+ // Clear.
840+ // TODO(user): Just switch to memclear() when dense.
841+ for (const IntegerVariable var : lp_vars) is_in_lp_vars_.ClearBucket (var);
833842}
834843
835844} // namespace sat
0 commit comments