1
0
Fork 0

Remove weak rules

Since we no longer have suggest/recommend rules and no longer use any update
or feature rules so packages are removed by default, we do not need weak rules
anymore.
pull/715/head
Nils Adermann 2012-05-19 21:49:48 +02:00
parent 025581b365
commit dd527a4049
3 changed files with 8 additions and 70 deletions

View File

@ -35,7 +35,6 @@ class Rule
protected $literals;
protected $type;
protected $id;
protected $weak;
protected $job;
@ -53,7 +52,6 @@ class Rule
$this->reasonData = $reasonData;
$this->disabled = false;
$this->weak = false;
$this->job = $job;
@ -139,16 +137,6 @@ class Rule
return !$this->disabled;
}
public function isWeak()
{
return $this->weak;
}
public function setWeak($weak)
{
$this->weak = $weak;
}
public function getLiterals()
{
return $this->literals;

View File

@ -69,7 +69,7 @@ class Solver
for ($ruleIndex = 0; $ruleIndex < count($this->rules); $ruleIndex++) {
$rule = $this->rules->ruleById($ruleIndex);
if ($rule->isWeak() || !$rule->isAssertion() || $rule->isDisabled()) {
if (!$rule->isAssertion() || $rule->isDisabled()) {
continue;
}
@ -104,15 +104,15 @@ class Solver
continue;
}
// conflict with another job or update/feature rule
// conflict with another job
$problem = new Problem;
$problem->addRule($rule);
$problem->addRule($conflict);
// push all of our rules (can only be feature or job rules)
// push all of our rules (can only be job rules)
// asserting this literal on the problem stack
foreach ($this->rules->getIteratorFor(RuleSet::TYPE_JOB) as $assertRule) {
if ($assertRule->isDisabled() || !$assertRule->isAssertion() || $assertRule->isWeak()) {
if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
continue;
}
@ -137,27 +137,6 @@ class Solver
}
$ruleIndex = -1;
}
foreach ($this->rules as $rule) {
if (!$rule->isWeak() || !$rule->isAssertion() || $rule->isDisabled()) {
continue;
}
$literals = $rule->getLiterals();
$literal = $literals[0];
if ($this->decisionMap[abs($literal)] == 0) {
$this->decide($literal, 1, $rule);
continue;
}
if ($this->decisionsSatisfy($literals[0])) {
continue;
}
// conflict, but this is a weak rule => disable
$this->disableProblem($rule);
}
}
protected function setupInstalledMap()
@ -553,7 +532,7 @@ class Solver
return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
}
private function analyzeUnsolvableRule($problem, $conflictRule, &$lastWeakWhy)
private function analyzeUnsolvableRule($problem, $conflictRule)
{
$why = $conflictRule->getId();
@ -562,7 +541,7 @@ class Solver
$problemRules = $this->learnedPool[$learnedWhy];
foreach ($problemRules as $problemRule) {
$this->analyzeUnsolvableRule($problem, $problemRule, $lastWeakWhy);
$this->analyzeUnsolvableRule($problem, $problemRule);
}
return;
}
@ -572,23 +551,15 @@ class Solver
return;
}
if ($conflictRule->isWeak()) {
/** TODO why > or < lastWeakWhy? */
if (!$lastWeakWhy || $why > $lastWeakWhy->getId()) {
$lastWeakWhy = $conflictRule;
}
}
$problem->addRule($conflictRule);
}
private function analyzeUnsolvable($conflictRule, $disableRules)
{
$lastWeakWhy = null;
$problem = new Problem;
$problem->addRule($conflictRule);
$this->analyzeUnsolvableRule($problem, $conflictRule, $lastWeakWhy);
$this->analyzeUnsolvableRule($problem, $conflictRule);
$this->problems[] = $problem;
@ -618,7 +589,7 @@ class Solver
$why = $this->decisionQueueWhy[$decisionId];
$problem->addRule($why);
$this->analyzeUnsolvableRule($problem, $why, $lastWeakWhy);
$this->analyzeUnsolvableRule($problem, $why);
$literals = $why->getLiterals();
@ -631,15 +602,6 @@ class Solver
}
}
if ($lastWeakWhy) {
array_pop($this->problems);
$this->disableProblem($lastWeakWhy);
$this->resetSolver();
return 1;
}
if ($disableRules) {
foreach ($this->problems[count($this->problems) - 1] as $reason) {
$this->disableProblem($reason['rule']);

View File

@ -110,18 +110,6 @@ class RuleTest extends TestCase
$this->assertFalse($rule->isEnabled());
}
public function testSetWeak()
{
$rule = new Rule($this->pool, array(), 'job1', null);
$rule->setWeak(true);
$rule2 = new Rule($this->pool, array(), 'job1', null);
$rule2->setWeak(false);
$this->assertTrue($rule->isWeak());
$this->assertFalse($rule2->isWeak());
}
public function testIsAssertions()
{
$rule = new Rule($this->pool, array(1, 12), 'job1', null);