@@ -797,7 +797,7 @@ void ProductDetector::UpdateRLTMaps(
797
797
798
798
// TODO(user): limit work if too many ternary.
799
799
void ProductDetector::InitializeBooleanRLTCuts (
800
- const absl::flat_hash_map<IntegerVariable, glop::ColIndex>& lp_vars,
800
+ absl::Span< const IntegerVariable> lp_vars,
801
801
const util_intops::StrongVector<IntegerVariable, double >& lp_values) {
802
802
// TODO(user): Maybe we shouldn't reconstruct this every time, but it is hard
803
803
// in case of multiple lps to make sure we don't use variables not in the lp
@@ -808,14 +808,19 @@ void ProductDetector::InitializeBooleanRLTCuts(
808
808
// We will list all interesting multiplicative candidate for each variable.
809
809
bool_rlt_candidates_.clear ();
810
810
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
+
811
816
for (int i = 0 ; i < size; i += 3 ) {
812
817
const IntegerVariable var1 = ternary_clauses_with_view_[i];
813
818
const IntegerVariable var2 = ternary_clauses_with_view_[i + 1 ];
814
819
const IntegerVariable var3 = ternary_clauses_with_view_[i + 2 ];
815
820
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 ;
819
824
820
825
// If we have l1 + l2 + l3 >= 1, then for all (i, j) pair we have
821
826
// !li * !lj <= lk. We are looking for violation like this.
@@ -830,6 +835,10 @@ void ProductDetector::InitializeBooleanRLTCuts(
830
835
UpdateRLTMaps (lp_values, NegationOf (var2), 1.0 - lp2, NegationOf (var3),
831
836
1.0 - lp3, var1, lp1);
832
837
}
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);
833
842
}
834
843
835
844
} // namespace sat
0 commit comments