Example #1
0
 private function analyzeUnsolvable($conflictRule, $disableRules)
 {
     $problem = new Problem();
     $problem->addRule($conflictRule);
     $this->analyzeUnsolvableRule($problem, $conflictRule);
     $this->problems[] = $problem;
     $seen = array();
     $literals = $conflictRule->getLiterals();
     foreach ($literals as $literal) {
         // skip the one true literal
         if ($this->decisionsSatisfy($literal)) {
             continue;
         }
         $seen[abs($literal)] = true;
     }
     $decisionId = count($this->decisionQueue);
     while ($decisionId > 0) {
         $decisionId--;
         $literal = $this->decisionQueue[$decisionId];
         // skip literals that are not in this rule
         if (!isset($seen[abs($literal)])) {
             continue;
         }
         $why = $this->decisionQueueWhy[$decisionId];
         $problem->addRule($why);
         $this->analyzeUnsolvableRule($problem, $why);
         $literals = $why->getLiterals();
         foreach ($literals as $literal) {
             // skip the one true literal
             if ($this->decisionsSatisfy($literal)) {
                 continue;
             }
             $seen[abs($literal)] = true;
         }
     }
     if ($disableRules) {
         foreach ($this->problems[count($this->problems) - 1] as $reason) {
             $this->disableProblem($reason['rule']);
         }
         $this->resetSolver();
         return 1;
     }
     return 0;
 }
Example #2
0
 /**
  * @param  Rule $conflictRule
  * @param  bool $disableRules
  * @return int
  */
 private function analyzeUnsolvable(Rule $conflictRule, $disableRules)
 {
     $problem = new Problem($this->pool);
     $problem->addRule($conflictRule);
     $this->analyzeUnsolvableRule($problem, $conflictRule);
     $this->problems[] = $problem;
     $seen = array();
     $literals = $conflictRule->literals;
     foreach ($literals as $literal) {
         // skip the one true literal
         if ($this->decisions->satisfy($literal)) {
             continue;
         }
         $seen[abs($literal)] = true;
     }
     foreach ($this->decisions as $decision) {
         $literal = $decision[Decisions::DECISION_LITERAL];
         // skip literals that are not in this rule
         if (!isset($seen[abs($literal)])) {
             continue;
         }
         $why = $decision[Decisions::DECISION_REASON];
         $problem->addRule($why);
         $this->analyzeUnsolvableRule($problem, $why);
         $literals = $why->literals;
         foreach ($literals as $literal) {
             // skip the one true literal
             if ($this->decisions->satisfy($literal)) {
                 continue;
             }
             $seen[abs($literal)] = true;
         }
     }
     if ($disableRules) {
         foreach ($this->problems[count($this->problems) - 1] as $reason) {
             $this->disableProblem($reason['rule']);
         }
         $this->resetSolver();
         return 1;
     }
     return 0;
 }
Example #3
0
 private function analyzeUnsolvable($conflictRule, $disableRules)
 {
     $lastWeakWhy = null;
     $problem = new Problem();
     $problem->addRule($conflictRule);
     $this->analyzeUnsolvableRule($problem, $conflictRule, $lastWeakWhy);
     $this->problems[] = $problem;
     $seen = array();
     $literals = $conflictRule->getLiterals();
     /* unnecessary because unlike rule.d, watch2 == 2nd literal, unless watch2 changed
             if (sizeof($literals) == 2) {
                 $literals[1] = $this->literalFromId($conflictRule->watch2);
             }
     */
     foreach ($literals as $literal) {
         // skip the one true literal
         if ($this->decisionsSatisfy($literal)) {
             continue;
         }
         $seen[$literal->getPackageId()] = true;
     }
     $decisionId = count($this->decisionQueue);
     while ($decisionId > 0) {
         $decisionId--;
         $literal = $this->decisionQueue[$decisionId];
         // skip literals that are not in this rule
         if (!isset($seen[$literal->getPackageId()])) {
             continue;
         }
         $why = $this->decisionQueueWhy[$decisionId];
         $problem->addRule($why);
         $this->analyzeUnsolvableRule($problem, $why, $lastWeakWhy);
         $literals = $why->getLiterals();
         /* unnecessary because unlike rule.d, watch2 == 2nd literal, unless watch2 changed
                     if (sizeof($literals) == 2) {
                         $literals[1] = $this->literalFromId($why->watch2);
                     }
         */
         foreach ($literals as $literal) {
             // skip the one true literal
             if ($this->decisionsSatisfy($literal)) {
                 continue;
             }
             $seen[$literal->getPackageId()] = true;
         }
     }
     if ($lastWeakWhy) {
         array_pop($this->problems);
         if ($lastWeakWhy->getType() === RuleSet::TYPE_JOB) {
             $why = $this->ruleToJob[$lastWeakWhy];
         } else {
             $why = $lastWeakWhy;
         }
         if ($lastWeakWhy->getType() == RuleSet::TYPE_CHOICE) {
             $this->disableChoiceRules($lastWeakWhy);
         }
         $this->disableProblem($why);
         /**
         @TODO what does v < 0 mean here? ($why == v)
               if (v < 0)
             solver_reenablepolicyrules(solv, -(v + 1));
         */
         $this->resetSolver();
         return true;
     }
     if ($disableRules) {
         foreach ($this->problems[count($this->problems) - 1] as $reason) {
             if ($reason['job']) {
                 $this->disableProblem($reason['job']);
             } else {
                 $this->disableProblem($reason['rule']);
             }
         }
         $this->resetSolver();
         return true;
     }
     return false;
 }