public function assignWorker(WorkerSchedule $worker, $expoId)
 {
     if (0 == count($this->jobList)) {
         return;
     }
     // jobs in preference order
     $myJobList = $worker->sortJobPreference($this->jobList, FALSE);
     // first get locations in preference order
     $locations = array();
     foreach ($myJobList as $job) {
         if (!in_array($job->location, $locations)) {
             $locations[] = $job->location;
         }
     }
     // $job
     // next reorder jobs ... order by preference group by location!
     $groupByLocation = array();
     foreach ($locations as $location) {
         foreach ($myJobList as $job) {
             if (0 == strcmp($job->location, $location)) {
                 $groupByLocation[] = $job;
             }
         }
         // $job
     }
     // $location
     $myJobList = NULL;
     $locations = NULL;
     $lockLocation = NULL;
     logMessage("LocationLock", "assigning workerid:" . $worker->workerid . "  count(gbl):" . count($groupByLocation));
     foreach ($groupByLocation as $job) {
         try {
             logMessage("LocationLock - isnull?", "jobid:" . $job->jobid . " in try  ");
             if (!is_null($lockLocation)) {
                 logMessage("LocationLock - strcmp", "lockLocation:" . $lockLocation . " after is_null  " . $job->location);
                 if (0 != strcmp($lockLocation, $job->location)) {
                     logMessage("LocationLock - break", "jobid:" . $job->jobid . "  lockLocation:" . $lockLocation . " before break  ");
                     break;
                     // leave loop
                 }
             }
             logMessage("LocationLock - addwprler", "jobid:" . $job->jobid . "  worker:" . $worker->workerid);
             $job->addWorker($worker, $expoId);
             // exception leaves $lockLocation NULL
             logMessage("LocationLock - set lockLocation", "job->location:" . $job->location);
             $lockLocation = $job->location;
         } catch (ScheduleException $se) {
             logMessage("LocationLock failure", $job->jobid . "  " . $se->getMessage());
             continue;
             // do not force
         }
     }
     // $job
     $groupByLocation = NULL;
 }
 public function assignWorker(WorkerSchedule $worker, $expoId)
 {
     if (0 == count($this->jobList)) {
         return;
     }
     // jobs in preference order
     $myJobList = $worker->sortJobPreference($this->jobList, FALSE);
     // first get locations in preference order
     $locations = array();
     foreach ($myJobList as $job) {
         if (!in_array($job->location, $locations)) {
             $locations[] = $job->location;
         }
     }
     // $job
     // next reorder jobs ... order by preference group by location!
     $groupByLocation = array();
     foreach ($locations as $location) {
         foreach ($myJobList as $job) {
             if (0 == strcmp($job->location, $location)) {
                 $groupByLocation[] = $job;
             }
         }
         // $job
     }
     // $location
     $myJobList = NULL;
     $locations = NULL;
     foreach ($groupByLocation as $job) {
         try {
             $job->addWorker($worker, $expoId);
         } catch (ScheduleException $se) {
             // logMessage("failure", $job->jobid . "  " . $se->getMessage());
             continue;
             // do not force
         }
     }
     // $job
     $groupByLocation = NULL;
 }
Esempio n. 3
0
 public function assignWorker(WorkerSchedule $worker, $expoId)
 {
     if (0 == count($this->jobList)) {
         return;
     }
     $myJobList = $worker->sortJobPreference($this->jobList, FALSE);
     foreach ($myJobList as $job) {
         try {
             $job->addWorker($worker, $expoId);
             logMessage("FCFS schedule", "expoid:{$expoId} - job:{$job->jobid} - worker:{$worker->workerid}\n");
         } catch (ScheduleConflictException $se) {
             // logMessage("conflict", $job->jobid . "   " . $se->getMessage());
             // will have to fix later anyway
             $conflict = $se->conflict;
             $worker->swapHappier($job, $conflict, $expoId);
         } catch (ScheduleException $se) {
             // logMessage("failure", $job->jobid . "  " . $se->getMessage());
             continue;
             // do not force
         }
     }
     // $job
 }