be more careful when making holes in large domains
This commit is contained in:
@@ -255,7 +255,7 @@ DiffCst::DiffCst(Solver* const s, IntVar* const var, int64 value)
|
||||
: Constraint(s), var_(var), value_(value), demon_(NULL) {}
|
||||
|
||||
void DiffCst::InitialPropagate() {
|
||||
if (var_->Size() >= 0xFFFFFFFF) {
|
||||
if (var_->Size() >= 0xFFFFFF) {
|
||||
demon_ = MakeConstraintDemon0(solver(),
|
||||
this,
|
||||
&DiffCst::BoundPropagate,
|
||||
|
||||
@@ -363,11 +363,15 @@ class DomainIntVar : public IntVar {
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessWatcher(int index) {
|
||||
void ProcessWatcher(int64 index) {
|
||||
IntVar* const boolvar = watchers_.At(index);
|
||||
DCHECK(boolvar != NULL);
|
||||
if (boolvar->Min() == 0) {
|
||||
variable_->RemoveValue(index);
|
||||
if (variable_->Size() < 0xFFFFFF) {
|
||||
variable_->RemoveValue(index);
|
||||
} else {
|
||||
solver()->AddConstraint(solver()->MakeNonEquality(variable_, index));
|
||||
}
|
||||
} else {
|
||||
variable_->SetValue(index);
|
||||
}
|
||||
@@ -5054,6 +5058,13 @@ Constraint* Solver::MakeIsEqualCt(IntExpr* const v1,
|
||||
} else if (v2->Bound()) {
|
||||
return MakeIsEqualCstCt(v1->Var(), v2->Min(), b);
|
||||
}
|
||||
if (b->Bound()) {
|
||||
if (b->Min() == 0) {
|
||||
return MakeNonEquality(v1->Var(), v2->Var());
|
||||
} else {
|
||||
return MakeEquality(v1->Var(), v2->Var());
|
||||
}
|
||||
}
|
||||
return MakeIsEqualCstCt(MakeDifference(v1, v2)->Var(), 0, b);
|
||||
}
|
||||
|
||||
|
||||
@@ -333,12 +333,18 @@ void DiffVar::Post() {
|
||||
|
||||
void DiffVar::InitialPropagate() {
|
||||
if (left_->Bound()) {
|
||||
right_->RemoveValue(left_->Min()); // we use min instead of value
|
||||
// because we do not check again if the variable is bound
|
||||
// when the variable is bound, Min() == Max() == Value()
|
||||
if (right_->Size() < 0xFFFFFF) {
|
||||
right_->RemoveValue(left_->Min()); // we use min instead of value
|
||||
} else {
|
||||
solver()->AddConstraint(solver()->MakeNonEquality(right_, left_->Min()));
|
||||
}
|
||||
}
|
||||
if (right_->Bound()) {
|
||||
left_->RemoveValue(right_->Min()); // see above
|
||||
if (left_->Size() < 0xFFFFFF) {
|
||||
left_->RemoveValue(right_->Min()); // see above
|
||||
} else {
|
||||
solver()->AddConstraint(solver()->MakeNonEquality(left_, right_->Min()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user