0) && isset($topicReviewerAR[$t]) && (count($topicReviewerAR[$t] > 0))) { $topicScoreAR[$t] = count($topicReviewerAR[$t]) / $topPAR[$t]; } else $topicScoreAR[$t] = 0; } // Calculate paper scores foreach ($paperTopicAR as $paperid => $topiclist) { $score = 0; foreach ($topiclist as $topicid) { $score += $topicScoreAR[$topicid]; } $paperScoreAR[$paperid] = $score; } asort($paperScoreAR); // Calculate reviewer scores foreach ($reviewerTopicAR as $reviewerid => $topiclist) { $score = 0; foreach ($topiclist as $topicid) { $score += $topicScoreAR[$topicid]; } $reviewerScoreAR[$reviewerid] = $score; } asort($reviewerScoreAR); } // Iterate through papers (score low to high) assigning // REVIEWERS in order of their score foreach (array_keys($paperScoreAR) as $paperid) { if ($continueFrom && ($paperid != $continueFrom)) { // skip to where processing stopped continue; } else { // reset continueFrom - excessive, need to clean up $continueFrom = 0; $continueVal = $paperid; } if (oc_checkTimeout()) { // shutdown if close to timeout oc_assignTimeoutShutdown(); } // Create a list of reviewers for paper incl. scores $Rs = array(); if (isset($paperTopicAR[$paperid])) { foreach($paperTopicAR[$paperid] as $topicid) { if (isset($topicReviewerAR[$topicid])) { // may not have a reviewer for every topic foreach ($topicReviewerAR[$topicid] as $reviewerid) { if (!in_array($reviewerid,$pAR[$paperid]) // reviewer not yet assigned to paper && !in_array($paperid."-".$reviewerid,$nAR) // reviewer not in conflict && (count($rAR[$reviewerid]) < $ppr) ) // not enough papers yet { $Rs[$reviewerid] = $reviewerScoreAR[$reviewerid]; } } } } } // Assign reviewers based on reviewer scores (sortorder: 1=highest first; 2=lowest first) if (count($Rs) > 0) { if ($sortorder=="1") { arsort($Rs); } else { asort($Rs); } reset($Rs); // assign reviewers while available & not enough while ((count($Rs)>0) && (count($pAR[$paperid]) < $rpp)) { $rid = key($Rs); array_push($pAR[$paperid],$rid); array_push($rAR[$rid],$paperid); unset($Rs[$rid]); #next($Rs); } } } } oc_algoWeightedTopicMatch($reviewersPerPaper,$papersPerReviewer,1);