|
@@ -44,13 +44,24 @@ class RuleWatchGraph
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- foreach (array($node->watch1, $node->watch2) as $literal) {
|
|
|
- if (!isset($this->watchChains[$literal])) {
|
|
|
- $this->watchChains[$literal] = new RuleWatchChain;
|
|
|
+ if (!$node->getRule() instanceof MultiConflictRule) {
|
|
|
+ foreach (array($node->watch1, $node->watch2) as $literal) {
|
|
|
+ if (!isset($this->watchChains[$literal])) {
|
|
|
+ $this->watchChains[$literal] = new RuleWatchChain;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->watchChains[$literal]->unshift($node);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ foreach ($node->getRule()->getLiterals() as $literal) {
|
|
|
+ if (!isset($this->watchChains[$literal])) {
|
|
|
+ $this->watchChains[$literal] = new RuleWatchChain;
|
|
|
+ }
|
|
|
|
|
|
- $this->watchChains[$literal]->unshift($node);
|
|
|
+ $this->watchChains[$literal]->unshift($node);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -92,28 +103,41 @@ class RuleWatchGraph
|
|
|
$chain->rewind();
|
|
|
while ($chain->valid()) {
|
|
|
$node = $chain->current();
|
|
|
- $otherWatch = $node->getOtherWatch($literal);
|
|
|
+ if (!$node->getRule() instanceof MultiConflictRule) {
|
|
|
+ $otherWatch = $node->getOtherWatch($literal);
|
|
|
|
|
|
- if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
|
|
|
- $ruleLiterals = $node->getRule()->getLiterals();
|
|
|
+ if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
|
|
|
+ $ruleLiterals = $node->getRule()->getLiterals();
|
|
|
|
|
|
- $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
|
|
|
- return $literal !== $ruleLiteral &&
|
|
|
- $otherWatch !== $ruleLiteral &&
|
|
|
- !$decisions->conflict($ruleLiteral);
|
|
|
- });
|
|
|
+ $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
|
|
|
+ return $literal !== $ruleLiteral &&
|
|
|
+ $otherWatch !== $ruleLiteral &&
|
|
|
+ !$decisions->conflict($ruleLiteral);
|
|
|
+ });
|
|
|
|
|
|
- if ($alternativeLiterals) {
|
|
|
- reset($alternativeLiterals);
|
|
|
- $this->moveWatch($literal, current($alternativeLiterals), $node);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if ($alternativeLiterals) {
|
|
|
+ reset($alternativeLiterals);
|
|
|
+ $this->moveWatch($literal, current($alternativeLiterals), $node);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- if ($decisions->conflict($otherWatch)) {
|
|
|
- return $node->getRule();
|
|
|
- }
|
|
|
+ if ($decisions->conflict($otherWatch)) {
|
|
|
+ return $node->getRule();
|
|
|
+ }
|
|
|
|
|
|
- $decisions->decide($otherWatch, $level, $node->getRule());
|
|
|
+ $decisions->decide($otherWatch, $level, $node->getRule());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // check isDisabled?
|
|
|
+ foreach ($node->getRule()->getLiterals() as $otherLiteral) {
|
|
|
+ if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
|
|
|
+ if ($decisions->conflict($otherLiteral)) {
|
|
|
+ return $node->getRule();
|
|
|
+ }
|
|
|
+
|
|
|
+ $decisions->decide($otherLiteral, $level, $node->getRule());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$chain->next();
|