forked from science-ation/science-ation
Don't duplicate SA-only judges for all rounds for all special awards (only duplicate them enough to satisfy their special awards requests in the specific rounds the award is judges). Fix a bug where the last jduges would get replcaed by a duplicate of the 2nd last judge for multi-round special awards.
This commit is contained in:
parent
8f063c1ec1
commit
0661224a0b
@ -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<count($ids); $x++) {
|
||||
$j =& $judges[$ids[$x]];
|
||||
if($j['special_award_only'] == 'yes') {
|
||||
$cost += 500;
|
||||
}
|
||||
}
|
||||
return $cost;
|
||||
}
|
||||
|
||||
@ -964,6 +956,7 @@ function judges_sa_cost_function($annealer, $bucket_id, $ids)
|
||||
return $cost;
|
||||
}
|
||||
|
||||
|
||||
if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
||||
|
||||
TRACE("Finding judges for special award round(s)\n");
|
||||
@ -973,17 +966,14 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
||||
|
||||
$total_judges = 0;
|
||||
foreach($judges as &$j) {
|
||||
TRACE(" {$j['firstname']} {$j['lastname']}\n");
|
||||
foreach($round_special_awards as &$r) {
|
||||
if(judge_available_for_round($j, $r) == true) {
|
||||
if($j['special_award_only'] == 'yes') {
|
||||
for($i=0;$i<count($j['special_awards']);$i++) {
|
||||
$r['available_judge_ids'][] = $j['id'];
|
||||
$total_judges++; /* It's ok to count the same judge twice */
|
||||
}
|
||||
} else {
|
||||
$r['available_judge_ids'][] = $j['id'];
|
||||
$total_judges++; /* It's ok to count the same judge twice */
|
||||
}
|
||||
TRACE(" {$r['name']} yes\n");
|
||||
$r['available_judge_ids'][] = $j['id'];
|
||||
$total_judges++;
|
||||
} else {
|
||||
TRACE(" {$r['name']} no\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1091,7 +1081,6 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* If there are no SA-only judges, skip the pre-assignment */
|
||||
@ -1116,7 +1105,10 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
||||
/* If the max judges for the jteam is less than the max, update the max,
|
||||
* this prevents the scheduler from trying to remove sa-only judges
|
||||
* from the jteam because of the over-max cost penalty */
|
||||
if($jt['max_judges'] < count($sa_judges)) $jt['max_judges'] = count($sa_judges);
|
||||
if($jt['max_judges'] < count($sa_judges)) {
|
||||
TRACE(" Changing max_judges to ". count($sa_judges)." to accomodate all SA-only judge requests.\n");
|
||||
$jt['max_judges'] = count($sa_judges);
|
||||
}
|
||||
}
|
||||
unset($jt);
|
||||
|
||||
@ -1149,6 +1141,41 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
||||
$round_special_awards[$highest_offset]['assigned_judges'] += $jt['min_judges'];
|
||||
TRACE("Assigned Team {$jt['name']} to Round {$round_special_awards[$highest_offset]['name']}\n");
|
||||
}
|
||||
unset($jt);
|
||||
|
||||
|
||||
/* Now that teams have been assigned to rounds, search for all the
|
||||
* SA only judges again, and duplicate the available judge id if they are signed
|
||||
* up to judge more than one award in the round */
|
||||
foreach($judges as &$j) {
|
||||
if($j['special_award_only'] == 'no') continue;
|
||||
|
||||
foreach($round_special_awards as &$r) {
|
||||
$count = 0;
|
||||
if(judge_available_for_round($j, $r) == false) continue;
|
||||
|
||||
/* Find out how many of their special awards are in this round. */
|
||||
foreach($sa_jteam as $jt_id=>&$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++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user