[CP-SAT] memory optimizations; improve no_overlap_2d; change default parameters
This commit is contained in:
@@ -44,9 +44,9 @@ namespace sat {
|
||||
|
||||
template <bool use_int128>
|
||||
LinearConstraintPropagator<use_int128>::LinearConstraintPropagator(
|
||||
const std::vector<Literal>& enforcement_literals,
|
||||
const std::vector<IntegerVariable>& vars,
|
||||
const std::vector<IntegerValue>& coeffs, IntegerValue upper, Model* model)
|
||||
absl::Span<const Literal> enforcement_literals,
|
||||
absl::Span<const IntegerVariable> vars,
|
||||
absl::Span<const IntegerValue> coeffs, IntegerValue upper, Model* model)
|
||||
: upper_bound_(upper),
|
||||
shared_(
|
||||
model->GetOrCreate<LinearConstraintPropagator<use_int128>::Shared>()),
|
||||
@@ -82,6 +82,33 @@ LinearConstraintPropagator<use_int128>::LinearConstraintPropagator(
|
||||
rev_lb_fixed_vars_ = IntegerValue(0);
|
||||
}
|
||||
|
||||
// TODO(user): Avoid duplication with other constructor.
|
||||
template <bool use_int128>
|
||||
LinearConstraintPropagator<use_int128>::LinearConstraintPropagator(
|
||||
LinearConstraint ct, Model* model)
|
||||
: upper_bound_(ct.ub),
|
||||
shared_(
|
||||
model->GetOrCreate<LinearConstraintPropagator<use_int128>::Shared>()),
|
||||
size_(ct.num_terms),
|
||||
vars_(std::move(ct.vars)),
|
||||
coeffs_(std::move(ct.coeffs)),
|
||||
max_variations_(new IntegerValue[size_]) {
|
||||
// TODO(user): deal with this corner case.
|
||||
CHECK_GT(size_, 0);
|
||||
|
||||
// Handle negative coefficients.
|
||||
for (int i = 0; i < size_; ++i) {
|
||||
if (coeffs_[i] < 0) {
|
||||
vars_[i] = NegationOf(vars_[i]);
|
||||
coeffs_[i] = -coeffs_[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the reversible numbers.
|
||||
rev_num_fixed_vars_ = 0;
|
||||
rev_lb_fixed_vars_ = IntegerValue(0);
|
||||
}
|
||||
|
||||
template <bool use_int128>
|
||||
void LinearConstraintPropagator<use_int128>::FillIntegerReason() {
|
||||
shared_->integer_reason.clear();
|
||||
|
||||
Reference in New Issue
Block a user