- Fix a bug where the special awards annealer would overwrite the last jteam

- Add an alternative (but commented out) array population for the annealer
- Leave in some of the debug statements, they don't hurt anything.
This commit is contained in:
james 2008-09-17 18:04:50 +00:00
parent 87841466e6
commit bfb471011a

View File

@ -357,7 +357,7 @@ for($k=0; $k<count($keys); $k++) {
$jdiv[$jdiv_id]['jteams'] = array();
for($x=0;$x<$a->num_buckets; $x++) {
$bkt = $a->bucket[$x];
TRACE(" SubTeam $x:\n");
TRACE(" SubTeam $x: (jteam $jteam_id)\n");
$jdiv[$jdiv_id]['jteams'][] = $jteam_id;
$jteam[$jteam_id]['id'] = $jteam_id;
@ -398,19 +398,19 @@ printf("Judge Willing Chair = Question ID $willing_chair_question_id\n");
TRACE("Deleting autocreated divisional and special award judging teams:");
$q = mysql_query("SELECT * FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}");
while($r = mysql_fetch_object($q)) {
$jteam_id = $r->id;
print(" $jteam_id");
$id = $r->id;
print(" $id");
/* Clean out the judges_teams_link */
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
/* Awards */
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
/* Timeslots */
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
/* Timeslots projects */
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}");
mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$id' AND year={$config['FAIRYEAR']}");
print mysql_error();
}
/* Finally, delete all the autocreated judges teams */
@ -770,6 +770,7 @@ function judges_sa_pick_move($a)
if($config['scheduler_enable_sa_scheduling'] == 'yes') {
set_status("Creating Special Award Judging Teams (one team per award)");
$q = "SELECT award_awards.name,award_awards.id FROM award_awards,award_types
WHERE
@ -790,6 +791,9 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$sa_jteam[0]['max_judges'] = 0;
$sa_jteam[0]['award_ids'] = array();
/* Reload the jteam_id */
$jteam_id = count($jteam);
$x=1;
while($i = mysql_fetch_object($r)) {
$projects = getProjectsNominatedForSpecialAward($i->id);
@ -821,8 +825,6 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
$x++;
}
/* ====================================================================*/
set_status("Assigning Judges to Special Award Teams\n");
@ -834,14 +836,17 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
//$a->set_pick_move(judges_sa_pick_move);
$a->anneal();
$x=0;
unset($t);
unset($tid);
foreach($sa_jteam as $tid => $t) {
if($tid == 0) {
$x++;
continue;
}
print("Judging Team {$t['id']}: cost={$a->bucket_cost[$x]} #=({$t['min_judges']},{$t['max_judges']}) ");
// print("langs=(");
/* $langstr="";
for($y=0; $y<count($t['langs']); $y++) {
@ -954,8 +959,6 @@ function timeslot_cost_function($annealer, $bucket_id, $ids)
}
$keys = array_keys($jdiv);
$keys_count = count($keys);
for($k=0; $k<$keys_count; $k++) {
@ -973,19 +976,23 @@ for($k=0; $k<$keys_count; $k++) {
$project_rlookup[$pids[$x]] = $x;
}
$current_jdiv = $jdiv_id;
// $current_jdiv = $jdiv_id;
printf($n_projects. " projects in this jdiv\n");
printf("jdiv $jdiv_id, $n_projects projects in this jdiv\n");
unset($jteams_ids);
$jteams_ids = array();
/* Pad to the correct length */
for($x=0; $x<($n_timeslots * count($pids)); $x++)
for($x=0; $x<($n_timeslots * $n_projects); $x++)
$jteams_ids[] = 0;
printf("total of ".count($jteams_ids)." slots (should be $n_timeslots * $n_projects)\n");
/* Fill out the jteam array with a jteam_id for each time the
* jteam_id is supposed to judge a project */
$jteams = $jdiv[$jdiv_id]['jteams'];
foreach($jteams as $jteam_id) {
for($y=0;$y<count($jteam[$jteam_id]['projects']); $y++) {
$pid = $jteam[$jteam_id]['projects'][$y];
$idx = $project_rlookup[$pid];
@ -999,6 +1006,22 @@ for($k=0; $k<$keys_count; $k++) {
}
}
/*
$y = 0;
foreach($jteams as $jteam_id) {
$o = 0;
print("setting up jteam $jteam_id\n");
print_r($jteam[$jteam_id]);
foreach($jteam[$jteam_id]['projects'] as $pid) {
$jteams_ids[$y * $n_timeslots + $o] = $jteam_id;
$o++;
}
$y++;
}
printf("jteams_ids=\n");
print_r($jteams_ids);
*/
print("Jteams ids len=".count($jteams_ids));
print("\n");