diff --git a/admin/judges_sa.php b/admin/judges_sa.php index 75561cdf..10cfefe2 100644 --- a/admin/judges_sa.php +++ b/admin/judges_sa.php @@ -172,13 +172,11 @@ function judges_cost_function($annealer, $bucket_id, $ids) } /* Huge penalty for a team without a willing chair, but only if the min judges per team >1 */ - if(!$have_chair && $config['min_judges_per_team']>1) - $cost += 40; + if(!$have_chair && $config['min_judges_per_team']>1) $cost += 40; /* Huge penalty for not having a round2 person on the team */ if($round_divisional2 != NULL) { - if($have_div2 == false) - $cost += 40; + if($have_div2 == false) $cost += 40; } /* Small penalty for a jteam with no experience whatsoever */ @@ -471,6 +469,7 @@ set_status("Loading Judges"); $judges = judges_load_all(); + foreach($judges as &$j) { if($j['judge_active'] == 'no') { TRACE(" {$j['name']} has their judge profile deactivated, skipping.\n"); @@ -540,7 +539,7 @@ foreach($judges as &$j) { * round2 judge per team */ $j['available_for_divisional2'] = judge_available_for_round($j, $round_divisional2); } - +unset($j); TRACE("Loaded ".count($judges)." judges\n"); $jteam[0]['max_judges'] = count($judges); @@ -900,13 +899,6 @@ function judges_sa_cost_function($annealer, $bucket_id, $ids) if($bucket_id == 0) { /* This is the placeholder */ $cost = count($ids) * 50; - /* But check for judges who should be on a special award */ - for($x=0; $x&$jt) { + /* Is the team in this round? */ + if(!in_array($jt_id, $r['jteam_ids'])) continue; + + /* Is this SA judge requsing an award judged by this team? */ + foreach($jt['award_ids'] as $aid) { + if(in_array($aid, $j['special_awards'])) + $count++; + } + } + unset($jt); + while($count > 1) { + $r['available_judge_ids'][] = $j['id']; + $count--; + TRACE(" Duplicate {$j['firstname']} {$j['lastname']} for multiple SA-only request in round {$r['name']}\n"); + } + } + unset($r); + } + unset($j); + /* Now, anneal in each special award round */ foreach($round_special_awards as $r) { @@ -1156,6 +1183,7 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') { $current_jteam_ids = $r['jteam_ids']; $judge_ids = $r['available_judge_ids']; + $e = $config['effort']; $a = new annealer(count($r['jteam_ids']), 25, $e, 0.98, judges_sa_cost_function, $judge_ids); @@ -1167,6 +1195,7 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') { unset($t); unset($tid); + foreach($r['jteam_ids'] as $tid) { if($tid == 0) { $x++;