fix missing propagation

This commit is contained in:
lperron@google.com
2010-11-17 16:43:58 +00:00
parent c993d7c186
commit 5c8c6b7cc4
3 changed files with 18 additions and 21 deletions

View File

@@ -2498,7 +2498,10 @@ class IntervalVar : public PropagationBaseObject {
virtual void SetPerformed(bool val) = 0;
virtual void WhenPerformedBound(Demon* const d) = 0;
// These methods creates expressions encapsulating the start, end
// Attaches a demon awakened when anything about this interval changes.
void WhenAnything(Demon* const d);
// These methods create expressions encapsulating the start, end
// and duration of the interval var. Please note that these must not
// be used if the interval var is unperformed.
IntExpr* StartExpr();

View File

@@ -442,6 +442,13 @@ class IntervalVarPerformedExpr : public BaseIntExpr {
DISALLOW_COPY_AND_ASSIGN(IntervalVarPerformedExpr);
};
void IntervalVar::WhenAnything(Demon* const d) {
WhenDurationRange(d);
WhenStartRange(d);
WhenEndRange(d);
WhenPerformedBound(d);
}
IntExpr* IntervalVar::StartExpr() {
if (start_expr_ == NULL) {
solver()->SaveValue(reinterpret_cast<void**>(&start_expr_));

View File

@@ -73,10 +73,7 @@ class IntervalUnaryRelation : public Constraint {
void IntervalUnaryRelation::Post() {
if (t_->MayBePerformed()) {
Demon* d = solver()->MakeConstraintInitialPropagateCallback(this);
t_->WhenStartRange(d);
t_->WhenDurationRange(d);
t_->WhenEndRange(d);
t_->WhenPerformedBound(d);
t_->WhenAnything(d);
}
}
@@ -152,14 +149,8 @@ class IntervalBinaryRelation : public Constraint {
void IntervalBinaryRelation::Post() {
if (t1_->MayBePerformed() && t2_->MayBePerformed()) {
Demon* d = solver()->MakeConstraintInitialPropagateCallback(this);
t1_->WhenStartRange(d);
t1_->WhenDurationRange(d);
t1_->WhenEndRange(d);
t1_->WhenPerformedBound(d);
t2_->WhenStartRange(d);
t2_->WhenDurationRange(d);
t2_->WhenEndRange(d);
t2_->WhenPerformedBound(d);
t1_->WhenAnything(d);
t2_->WhenAnything(d);
}
}
@@ -274,12 +265,12 @@ void TemporalDisjunction::Post() {
this,
&TemporalDisjunction::RangeDemon1,
"RangeDemon1");
t1_->WhenStartRange(d);
t1_->WhenAnything(d);
d = MakeConstraintDemon0(s,
this,
&TemporalDisjunction::RangeDemon2,
"RangeDemon2");
t2_->WhenStartRange(d);
t2_->WhenAnything(d);
if (alt_ != NULL) {
d = MakeConstraintDemon0(s,
this,
@@ -440,8 +431,7 @@ void Sequence::Post() {
&Sequence::RangeChanged,
"RangeChanged",
i);
t->WhenStartRange(d);
t->WhenEndRange(d);
t->WhenAnything(d);
}
Constraint* ct =
MakeDecomposedSequenceConstraint(solver(), intervals_.get(), size_);
@@ -1265,10 +1255,7 @@ class DecomposedSequenceConstraint : public Constraint {
&DecomposedSequenceConstraint::InitialPropagate,
"InitialPropagate");
for (int32 i = 0; i < straight_.size(); ++i) {
IntervalVar* interval_var = straight_.intervals()[i];
interval_var->WhenStartRange(d);
interval_var->WhenDurationRange(d);
interval_var->WhenEndRange(d);
straight_.intervals()[i]->WhenAnything(d);
}
}