diff --git a/admin/anneal.inc.php b/admin/anneal.inc.php index 7f8439b2..dc1ec7b7 100644 --- a/admin/anneal.inc.php +++ b/admin/anneal.inc.php @@ -197,10 +197,10 @@ class annealer { $last_cost = 0; $last_cost_count = 0; -// if($this->num_buckets <= 1) { -// TRACE("Only one Bucket, nothing to anneal.\n"); -// return; -// } + if($this->num_buckets <= 1) { + TRACE("Only one Bucket, nothing to anneal.\n"); + return; + } // $this->print_buckets(); while(1) { $moves = $this->start_moves; diff --git a/admin/judges_sa.php b/admin/judges_sa.php index 6ec3fbd8..c9363a0f 100644 --- a/admin/judges_sa.php +++ b/admin/judges_sa.php @@ -588,53 +588,13 @@ while($r=mysql_fetch_object($q)) { $n_timeslots = count($available_timeslots); -$project_index = array(); -function timeslot_pick_move($a) -{ - global $n_timeslots; - - /* Bucket id always 0 */ - $b1 = 0; - $i1 = rand(0, count($a->bucket[0]) - 1); - - /* Find the start and end of this project timeslots */ - $i_s = floor($i1 / $n_timeslots) * $n_timeslots; - $i_e = $i_s + $n_timeslots - 1; - - /* THe second number must be between $i_s and $i_e */ - $b2 = 0; - while(1) { - $i2 = rand($i_s, $i_e); - if($i2 != $i1) break; - } -// TRACE("Move=($b1, $i1, $b2, $i2)\n"); - return array($b1, $i1, $b2, $i2); -} - - -/* Computes the cost of everything, since we slice the data two - * ways we can't really use delta costs - * In this, the bucket_id will always be 1, because we don't - * actually use buckets */ -function timeslot_cost_function($annealer, $bucket_id, $ids) -{ - global $project_index; - global $jteam; - global $n_timeslots; - - $cost = 0; - -// print("Count $ids=".count($ids)); - - /* The pick_move function ensures that projects can't - * move out of a jteam so we dont' need to check that */ - - /* First, check to see if the project is being judged 3 or * more times in a row, OR, if it has large gaps that aren't at the end of the judging */ - - for($x=0; $x 2) $cost += $z_count; +/* if($z_count > 2) $cost += $z_count; $r_count++; $z_count=0; if($r_count > 2) $cost += $r_count; } } } + */ + +function timeslot_pick_move($a) +{ + /* Use the existing pick move, but we want the item numbers + * in each bucket to always be the same */ + list($b1, $i1, $b2, $i2) = $a->pick_move(); + $i2 = $i1; + return array($b1, $i1, $b2, $i2); +} + + +function timeslot_cost_function($annealer, $bucket_id, $ids) +{ + $cost = 0; /* Check to make sure a judge isn't judging two projects * at the same time */ - $n_pids = count($project_index); - for($offset = 0; $offset < $n_timeslots; $offset++) { - for($x=0; $x<$n_pids-1; $x++) { - $o1 = $x * ($n_timeslots) + $offset; - $jteam_id1 = $ids[$o1]; - if($jteam_id1 == 0) continue; - for($y=$x+1; $y<$n_pids; $y++) { - $o2 = $y * ($n_timeslots) + $offset; - $jteam_id2 = $ids[$o2]; - if($jteam_id1 == $jteam_id2) - $cost += 50; - } + $n_pids = count($ids); + for($x=0; $x<$n_pids-1; $x++) { + $jteam_id1 = $ids[$x]; + if($jteam_id1 == 0) continue; + for($y=$x+1; $y<$n_pids; $y++) { + $jteam_id2 = $ids[$y]; + if($jteam_id1 == $jteam_id2) + $cost += 50; } } return $cost; - } + + $keys = array_keys($jdiv); for($k=0; $kset_pick_move(timeslot_pick_move); $a->anneal(); @@ -734,8 +703,7 @@ for($k=0; $kbucket[0][$idx]; + $jteam_id = $a->bucket[$y][$x]; TRACE(($y+1).":$jteam_id "); if($jteam_id == 0) continue;