Esempio n. 1
0
 /**
  * Replan swapping matches that share the same team
  * @param PlanningResults $result
  */
 private function replan_3run(PlanningResults $result)
 {
     $this->statistics['3run']['unresolved before'] = $result->unresolved();
     $unplaceable = array();
     /* @var $match MatchPlan */
     while ($match = $result->nextUnresolved()) {
         $slot_found = $this->replanMatch_1run($result, $match);
         if (!$slot_found) {
             $new_match = $this->findAngel($result, $match);
             if ($new_match) {
                 $this->statistics['3run']['swapped'][] = array($new_match, $match);
                 $result->appendUnresolved($new_match);
             } else {
                 $unplaceable[] = $match;
             }
         }
     }
     foreach ($unplaceable as $match) {
         $this->statistics['3run']['unplaceable'][] = $match;
         $result->appendUnresolved($match);
     }
     $this->statistics['3run']['unresolved after'] = $result->unresolved();
 }
Esempio n. 2
0
 /**
  * Replan swapping matches that durate for the same time
  * @param PlanningResults $result
  */
 private function replan_2run(PlanningResults $result)
 {
     $this->logger->addDebug("Q unresolved before 2run = " . $result->unresolved());
     $grace_max = $result->unresolved() * 2;
     $cnt_last = -1;
     $grace = 0;
     $unplaceable = array();
     while ($match = $result->nextUnresolved()) {
         $cnt = $result->unresolved();
         if ($cnt == $cnt_last) {
             $grace++;
         } else {
             $cnt_last = $cnt;
             $grace = 0;
         }
         $slot_found = $this->replanMatch_1run($result, $match);
         if (!$slot_found) {
             $new_match = $this->replanMatch_2run($result, $match);
             if ($new_match) {
                 $this->logger->addDebug("Swapped #" . $new_match->getMatchno() . " with #" . $match->getMatchno());
                 $result->appendUnresolved($new_match);
             } else {
                 $this->logger->addDebug("Unplaceable #" . $match->getMatchno());
                 $unplaceable[] = $match;
             }
         }
         if ($grace > $grace_max) {
             break;
         }
     }
     foreach ($unplaceable as $match) {
         $result->appendUnresolved($match);
     }
 }