diff --git a/admin/judges_sa.php b/admin/judges_sa.php
index 3c4baafd..00f240aa 100644
--- a/admin/judges_sa.php
+++ b/admin/judges_sa.php
@@ -66,11 +66,11 @@ function pick_random_move(&$team)
}
/* The cost function is:
- + 20 * each judge below the min for each team
+ + 50 * each judge below the min for each team
+ 10 * each judge above the max for each team
+ 2 * each level of preference away from the
max level for each judge
- + 50 if the team doesn't have a chair.
+ + 40 if the team doesn't have a chair.
+ 25 for each memember on the team that can't speak the language
of the judging team
@@ -96,7 +96,7 @@ function compute_team_cost(&$teams, &$judges, $team_id)
$c = count($t['judges']);
$min = ($c < $t['min']) ? $t['min'] - $c : 0;
$max = ($c > $t['max']) ? $c - $t['max'] : 0;
- $cost += $min * 20;
+ $cost += $min * 50;
$cost += $max * 10;
// TRACE("Under min=$min, over max=$max\n");
@@ -128,7 +128,7 @@ function compute_team_cost(&$teams, &$judges, $team_id)
}
/* Huge penalty for a team without a willing chair */
if(!$have_chair) {
- $cost += 50;
+ $cost += 40;
}
TRACE("Team $team_id, cost is $cost\n");
@@ -271,7 +271,7 @@ function judges_assign_anneal($divisions, $categories, $languages, $judges, &$te
/* Anneal */
$temperature = 25.0;
while(1) {
- $moves = 500;
+ $moves = 750;
for($m = 0; $m<$moves; $m++) {
/* Pick 2 moves at random */
$move = pick_random_move($team);
@@ -523,29 +523,6 @@ echo "".i18n("Manage Judge Members").""
echo "
";
echo "
";
-
-print("Project Timeslots:
\n");
-print("
Project ID | ");
-for($x=0;$x<$max_ts;$x++) {
- print("Slot ".($x + 1)." | ");
-}
-print("
");
-while(list($proj_id, $projinfo) = each( $data['projects'] )) {
- print("$proj_id | ");
- $last_slot = 1;
- while(list($slot,$jteam) = each ($projinfo['timetable']) ) {
- while($last_slot != $slot) {
- print(" | ");
- $last_slot++;
- }
- print("".($jteam+1)." | ");
- $last_slot++;
- }
- print("
");
-}
-print("
");
-
-
$totalcost=0;
while(list($tn, $t) = each($team)) {
//team numbers start with 0 in the annealer, but we want them to start at 1, so just tn++ here.
@@ -559,8 +536,10 @@ while(list($tn, $t) = each($team)) {
if(!$teamnums[$t['division']][$t['category']]) $teamnums[$t['division']][$t['category']]=1;
else $teamnums[$t['division']][$t['category']]++;
- mysql_query("INSERT INTO judges_teams (num,name,autocreate_type_id,year) VALUES ('$tn','(Divisional) {$div[$t['division']]} - {$cat[$t['category']]} #{$teamnums[$t['division']][$t['category']]}','1','{$config['FAIRYEAR']}')");
+ mysql_query("INSERT INTO judges_teams (num,name,autocreate_type_id,year) VALUES ('$tn','(Divisional) {$div[$t['division']]} - {$cat[$t['category']]} #{$teamnums[$t['division']][$t['category']]} ({$t['language']})','1','{$config['FAIRYEAR']}')");
$team_id=mysql_insert_id();
+ //use tn-1 since we incremented it at the top :p
+ $team[$tn-1]['team_id']=$team_id;
while(list($key, $j) = each($t['judges']) ) {
$judge = $judges[$j];
@@ -599,6 +578,61 @@ while(list($tn, $t) = each($team)) {
}
}
+
+$available_timeslots=array();
+$q=mysql_query("SELECT * FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' AND allowdivisional='yes' ORDER BY date,starttime");
+while($r=mysql_Fetch_object($q))
+{
+ $available_timeslots[]=array("id"=>$r->id,"date"=>$r->date,"starttime"=>substr($r->starttime,0,-3),"endtime"=>substr($r->endtime,0,-3));
+}
+
+print("Project Timeslots:
\n");
+print("Project ID | ");
+//FIXME:! max_ts is sometimes bigger than it should be (by 1 or 2)! whats going on??
+for($x=0;$x<=$max_ts;$x++) {
+ print("".$available_timeslots[$x]['starttime']."-".$available_timeslots[$x]['endtime']." | ");
+}
+print("
");
+while(list($proj_id, $projinfo) = each( $data['projects'] )) {
+ print("$proj_id | ");
+ $last_slot = 1;
+ while(list($slot,$jteam) = each ($projinfo['timetable']) ) {
+ while($last_slot != $slot) {
+ print(" | ");
+ $last_slot++;
+ }
+ print("".($jteam+1));
+ echo " ";
+ echo "tema_id=".$team[$jteam]['team_id'];
+ echo " ";
+ echo "proj_id=".$proj_id;
+ echo " ";
+ echo "ts_id=".$available_timeslots[$slot-1]['id'];
+ echo " ";
+ echo " | ";
+ $last_slot++;
+
+ //add the link of the judge team to the timeslot
+ mysql_query("INSERT INTO judges_teams_timeslots_link (judges_teams_id,judges_timeslots_id,year) VALUES (
+ '".$team[$jteam]['team_id']."',
+ '".$available_timeslots[$slot-1]['id']."',
+ '".$config['FAIRYEAR']."')");
+
+ //now add the link of hte project to this judge team & timeslot
+ mysql_query("INSERT INTO judges_teams_timeslots_projects_link (judges_teams_id,judges_timeslots_id,projects_id,year) VALUES (
+ '".$team[$jteam]['team_id']."',
+ '".$available_timeslots[$slot-1]['id']."',
+ '".$proj_id."',
+ '".$config['FAIRYEAR']."')");
+ }
+ print("
");
+}
+print("
");
+
+
+
+
+
echo "
";
echo "
";
echo "Total 'cost' for all teams: $totalcost";
diff --git a/admin/judges_schedulerconfig.php b/admin/judges_schedulerconfig.php
index aa2f0162..5ee9c9de 100644
--- a/admin/judges_schedulerconfig.php
+++ b/admin/judges_schedulerconfig.php
@@ -92,14 +92,20 @@ while($catr=mysql_fetch_object($catq))
$divq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
while($divr=mysql_fetch_object($divq))
{
- $numq=mysql_query("SELECT COUNT(id) AS num FROM projects WHERE projectcategories_id='$catr->id' AND projectdivisions_id='$divr->id' AND year='{$config['FAIRYEAR']}'");
- $numr=mysql_fetch_object($numq);
- echo "".i18n($divr->division)." | ";
- echo "$numr->num | ";
- $numteams=ceil($numr->num/$schedulerconfig['max_projects_per_team']*$schedulerconfig['num_times_judged']);
- echo "$numteams | ";
- $totalteams+=$numteams;
- echo "
";
+ $langq=mysql_query("SELECT * FROM languages WHERE active='Y'");
+ while($langr=mysql_fetch_object($langq))
+ {
+ $numq=mysql_query("SELECT COUNT(id) AS num FROM projects WHERE projectcategories_id='$catr->id' AND projectdivisions_id='$divr->id' AND year='{$config['FAIRYEAR']}' AND language='$langr->lang'");
+ $numr=mysql_fetch_object($numq);
+ echo "".i18n($divr->division)." ($langr->lang) | ";
+ echo "$numr->num | ";
+ $numteams=ceil($numr->num/$schedulerconfig['max_projects_per_team']*$schedulerconfig['num_times_judged']);
+ if($numteams<$schedulerconfig['num_times_judged']) $numteams=$schedulerconfig['num_times_judged'];
+
+ echo "$numteams | ";
+ $totalteams+=$numteams;
+ echo "
";
+ }
}
echo "";
echo "
";
@@ -203,10 +209,31 @@ if($notfoundawards)
if($foundawards)
echo happy(i18n("Found awards for: %1",array($foundawards)));
if($foundteams)
+{
echo error(i18n("Found judging teams that are currently assigned to divisional awards: %1. These teams must be removed first",array($foundteams)));
+ echo " ".i18n("Judging Teams Manager")."";
+}
else
echo happy(i18n("No judging teams are assigned to divisional awards (good!)"));
+//now check if we have enough timeslots available...
+
+$q=mysql_query("SELECT COUNT(id) AS num FROM judges_timeslots WHERE year='".$config['FAIRYEAR']."' AND allowdivisional='yes'");
+$r=mysql_fetch_object($q);
+$numslots=$r->num;
+
+if($numslots<$schedulerconfig['max_projects_per_team'])
+{
+ echo error(i18n("You do not have enough judging timeslots available for divisional judging. Please create more timeslots first. Available: %1, Required: %2",array($numslots,$schedulerconfig['max_projects_per_team'])));
+ echo " ".i18n("Timeslot Manager")."";
+ $ok=false;
+}
+else
+{
+ echo happy(i18n("You have sufficient timeslots available. Available: %1, Required: %2",array($numslots,$schedulerconfig['max_projects_per_team'])));
+}
+//asdf
+
if($ok)
{
echo i18n("Everything looks in order, we're ready to create the divisional awards judging teams. Click 'Create Divisional Awards Judging Teams' below to start the scheduler. Please be patient as it may take 20-30 seconds to find an optimal solution to the judging team assignments");