diff --git a/admin/anneal.inc.php b/admin/anneal.inc.php
index 29f90133..ccda734c 100644
--- a/admin/anneal.inc.php
+++ b/admin/anneal.inc.php
@@ -9,6 +9,7 @@ class annealer {
var $start_temp, $start_moves;
var $cost_function_callback;
var $pick_move_callback;
+ var $update_callback;
var $iterations;
var $items_per_bucket;
var $rate;
@@ -21,6 +22,7 @@ class annealer {
$this->start_moves = $start_moves;
$this->cost_function_callback = $cost_function_cb;
unset($this->pick_move_callback);
+ unset($this->update_callback);
$this->bucket_cost = array();
$this->bucket = array();
@@ -53,6 +55,11 @@ class annealer {
$this->pick_move_callback = $func;
}
+ function set_update_callback($func)
+ {
+ $this->update_callback = $func;
+ }
+
function pick_move()
{
@@ -202,6 +209,9 @@ class annealer {
return;
}
// $this->print_buckets();
+ $estimated_iterations = ceil(log(0.1 / $this->start_temp, $this->rate));
+
+ $iterations = 0;
while(1) {
$moves = $this->start_moves;
for($m = 0; $m<$moves; $m++) {
@@ -235,7 +245,7 @@ class annealer {
// TRACE("Move rejected\n");
}
$this->iterations++;
- if($this->iterations % 50000 == 0) {
+ if($this->iterations % 10000 == 0) {
TRACE(" {$this->iterations} iterations, cost={$this->cost}, temperature=$temperature\n");
// $this->print_buckets();
}
@@ -246,7 +256,12 @@ class annealer {
break;
}
}
+ $iterations++;
+ if(isset ($this->update_callback)) {
+ $cb = $this->update_callback;
+ $cb($iterations, $estimated_iterations);
+ }
if($this->cost == 0) break;
if($this->cost == $last_cost) {
diff --git a/admin/judges_sa.php b/admin/judges_sa.php
index 6474bb66..d6533ddb 100644
--- a/admin/judges_sa.php
+++ b/admin/judges_sa.php
@@ -30,6 +30,7 @@
send_header("Judging teams automatic scheduler");
+
echo i18n("The scheduler is running. Depending on the effort it may take
several minutes to complete. It will generate a lot of output on this page,
most of it is just information about what the scheduler is doing. You can copy
@@ -58,8 +59,6 @@ echo "
";
echo "
";
-TRACE("
"); - //function TRACE() { } //function TRACE_R() { } @@ -67,6 +66,28 @@ function TRACE($str) { print($str); } function TRACE_R($array) { print_r($array); } +TRACE(""); + + +function set_status($txt) +{ + TRACE("Status: $txt\n"); + mysql_query("UPDATE config SET val='$txt' WHERE + var='judge_scheduler_activity' AND year=0"); +} + +function set_progress($n) +{ + $p = floor($n); + TRACE("Progress: $p\%\n"); + mysql_query("UPDATE config SET val='$p' WHERE + var='judge_scheduler_precent' AND year=0"); + +} + +set_status("Initializing..."); +set_progress(0); + /* The cost function is: + 50 * each judge below the min for each team + 10 * each judge above the max for each team @@ -205,6 +226,7 @@ function jdiv_compute_cost($annealer, $bucket_id, $ids) } +set_status("Loading Data From Database..."); TRACE("\n\n"); $div = array(); TRACE("Loading Project Divisions...\n"); @@ -269,7 +291,7 @@ for($k=0; $kset_update_callback(judges_to_teams_update); $a->anneal(); @@ -568,6 +598,8 @@ print("Unused Judges:\n"); $ids = $a->bucket[0]; for($y=0; $y set_pick_move(timeslot_pick_move); diff --git a/admin/judges_schedulerconfig.php b/admin/judges_schedulerconfig.php index d5f5cb48..55720f81 100644 --- a/admin/judges_schedulerconfig.php +++ b/admin/judges_schedulerconfig.php @@ -38,6 +38,10 @@ ogram; see the file COPYING. If not, write to array( "max_projects_per_team", "times_judged", "min_judges_per_team", "max_judges_per_team", "effort", "project_status") ); + config_editor_require_vars("Judge Scheduler Status", 0, + array( "judge_scheduler_precent", + "judge_scheduler_activity" ) ); + config_editor("Judge Scheduler", $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']); echo "
";