forked from science-ation/science-ation
- Add 3 config variables: An effort for the tour annealer, and the updater
activity and percent. - Add the status update and links to automatically start the "tour assigner". (Didn't want to call it a scheduler, because someone might thing it's for assigning tours to timeslots or something)
This commit is contained in:
parent
5ad72acabf
commit
b0338f9fdf
@ -33,7 +33,7 @@
|
|||||||
echo "<a href=\"tours_manager.php\">".i18n("Manage Tours")."</a> ".i18n("- Add, Delete, Edit, and List tours")."<br />";
|
echo "<a href=\"tours_manager.php\">".i18n("Manage Tours")."</a> ".i18n("- Add, Delete, Edit, and List tours")."<br />";
|
||||||
echo "<a href=\"tours_assignments.php\">".i18n("Edit Student-Tour Assignments")."</a><br />";
|
echo "<a href=\"tours_assignments.php\">".i18n("Edit Student-Tour Assignments")."</a><br />";
|
||||||
echo "<hr />";
|
echo "<hr />";
|
||||||
echo "<a href=\"tours_schedulerconfig.php\">".i18n("Automatic Tour Assignments")."</a><br />";
|
echo "<a href=\"tours_sa_config.php\">".i18n("Automatic Tour Assignments")."</a><br />";
|
||||||
|
|
||||||
send_footer();
|
send_footer();
|
||||||
|
|
||||||
|
@ -44,9 +44,8 @@ TRACE("<pre>");
|
|||||||
function set_status($txt)
|
function set_status($txt)
|
||||||
{
|
{
|
||||||
TRACE("Status: $txt\n");
|
TRACE("Status: $txt\n");
|
||||||
return;
|
|
||||||
mysql_query("UPDATE config SET val='$txt' WHERE
|
mysql_query("UPDATE config SET val='$txt' WHERE
|
||||||
var='tours_scheduler_activity' AND year=0");
|
var='tours_assigner_activity' AND year=0");
|
||||||
}
|
}
|
||||||
|
|
||||||
$set_percent_last_percent = -1;
|
$set_percent_last_percent = -1;
|
||||||
@ -57,9 +56,8 @@ function set_percent($n)
|
|||||||
if($p == $set_percent_last_percent) return;
|
if($p == $set_percent_last_percent) return;
|
||||||
TRACE("Progress: $p\%\n");
|
TRACE("Progress: $p\%\n");
|
||||||
$set_percent_last_percent = $p;
|
$set_percent_last_percent = $p;
|
||||||
return;
|
|
||||||
mysql_query("UPDATE config SET val='$p' WHERE
|
mysql_query("UPDATE config SET val='$p' WHERE
|
||||||
var='tours_scheduler_percent' AND year=0");
|
var='tours_assigner_percent' AND year=0");
|
||||||
}
|
}
|
||||||
|
|
||||||
set_status("Initializing...");
|
set_status("Initializing...");
|
||||||
@ -79,9 +77,6 @@ set_percent(0);
|
|||||||
+200 for each student below 1/4 the capacity,but
|
+200 for each student below 1/4 the capacity,but
|
||||||
zero if the tour is empty
|
zero if the tour is empty
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Compute the cost of adding a judge to a team */
|
|
||||||
|
|
||||||
function tour_cost_function($annealer, $bucket_id, $ids)
|
function tour_cost_function($annealer, $bucket_id, $ids)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
@ -89,7 +84,7 @@ function tour_cost_function($annealer, $bucket_id, $ids)
|
|||||||
global $tours;
|
global $tours;
|
||||||
global $students;
|
global $students;
|
||||||
/* Bucket ID is the tour number */
|
/* Bucket ID is the tour number */
|
||||||
/* ids are the judge ids currently in the bucket */
|
/* ids are the student ids currently in the bucket */
|
||||||
|
|
||||||
// TRACE("Bucket id=$bucket_id, ids=");
|
// TRACE("Bucket id=$bucket_id, ids=");
|
||||||
// TRACE_R($ids);
|
// TRACE_R($ids);
|
||||||
@ -207,9 +202,9 @@ function tours_assignment_update($progress, $total)
|
|||||||
set_percent(($progress * 50) / $total);
|
set_percent(($progress * 50) / $total);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("Effort: {$config['effort']}\n");
|
TRACE("Effort: {$config['tours_assigner_effort']}\n");
|
||||||
set_status("Assigning students to tours");
|
set_status("Assigning students to tours");
|
||||||
$e = 100 + 10 * ($config['effort'] / 100);
|
$e = 100 + 10 * ($config['tours_assigner_effort'] / 100);
|
||||||
$a = new annealer(count($tours), 50, $e, 0.98,
|
$a = new annealer(count($tours), 50, $e, 0.98,
|
||||||
tour_cost_function, $student_ids);
|
tour_cost_function, $student_ids);
|
||||||
$a->set_update_callback(tours_assignment_update);
|
$a->set_update_callback(tours_assignment_update);
|
||||||
|
155
admin/tours_sa_status.php
Normal file
155
admin/tours_sa_status.php
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
<?
|
||||||
|
/*
|
||||||
|
This file is part of the 'Science Fair In A Box' project
|
||||||
|
SFIAB Website: http://www.sfiab.ca
|
||||||
|
|
||||||
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||||
|
Copyright (C) 2005 James Grant <james@lightbox.org>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public
|
||||||
|
License as published by the Free Software Foundation, version 2.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this pr<input type=\"submit\" value=\"".i18n("Save Configuration")."\" />\n";
|
||||||
|
ogram; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<?
|
||||||
|
|
||||||
|
if($_GET['action'] == 'output') {
|
||||||
|
include "../data/config.inc.php";
|
||||||
|
mysql_connect($DBHOST,$DBUSER,$DBPASS);
|
||||||
|
mysql_select_db($DBNAME);
|
||||||
|
$q=mysql_query("SELECT val FROM config WHERE year='0' AND var='tours_assigner_percent'");
|
||||||
|
$r=mysql_fetch_object($q);
|
||||||
|
$percent=$r->val;
|
||||||
|
|
||||||
|
$q=mysql_query("SELECT val FROM config WHERE year='0' AND var='tours_assigner_activity'");
|
||||||
|
$r=mysql_fetch_object($q);
|
||||||
|
$status=$r->val;
|
||||||
|
|
||||||
|
echo "$percent:$status\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require("../common.inc.php");
|
||||||
|
send_header("Scheduler Status",
|
||||||
|
array('Committee Main' => 'committee_main.php',
|
||||||
|
'Administration' => 'admin/index.php',
|
||||||
|
'Tours' => 'admin/tours.php')
|
||||||
|
);
|
||||||
|
require_once("../ajax.inc.php");
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var starttime=0;
|
||||||
|
var startpercent=0;
|
||||||
|
var deltatime=0;
|
||||||
|
var deltapercent=0;
|
||||||
|
var avgtimeperpercent=0;
|
||||||
|
var remainingpercent=0;
|
||||||
|
var remainingtime=0;
|
||||||
|
|
||||||
|
function updateStatus()
|
||||||
|
{
|
||||||
|
document.getElementById('updatestatus').innerHTML="Updating...";
|
||||||
|
var url="tours_sa_status.php?action=output";
|
||||||
|
http.open("GET",url,true);
|
||||||
|
http.onreadystatechange=handleResponse;
|
||||||
|
http.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearUpdatingMessage()
|
||||||
|
{
|
||||||
|
document.getElementById('updatestatus').innerHTML="Working...";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResponse()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(http.readyState==4)
|
||||||
|
{
|
||||||
|
var obj=http.responseText.split(":");
|
||||||
|
document.getElementById('schedulerstatus').innerHTML=obj[1];
|
||||||
|
if(obj[0]=="-1")
|
||||||
|
{
|
||||||
|
document.getElementById('schedulerpercent').innerHTML="100%";
|
||||||
|
document.getElementById('updatestatus').innerHTML="Scheduling Complete";
|
||||||
|
document.getElementById('schedulereta').innerHTML="Complete";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.getElementById('schedulerpercent').innerHTML=obj[0]+"%";
|
||||||
|
setTimeout('updateStatus()',5000);
|
||||||
|
document.getElementById('updatestatus').innerHTML="Updating... Done!";
|
||||||
|
setTimeout('clearUpdatingMessage()',500);
|
||||||
|
|
||||||
|
var currentTime=new Date();
|
||||||
|
if(starttime==0)
|
||||||
|
{
|
||||||
|
starttime=currentTime.getTime();
|
||||||
|
startpercent=obj[0];
|
||||||
|
}
|
||||||
|
deltatime=currentTime.getTime()-starttime;
|
||||||
|
deltapercent=obj[0]-startpercent;
|
||||||
|
|
||||||
|
avgtimeperpercent=deltatime/deltapercent;
|
||||||
|
remainingpercent=100-obj[0];
|
||||||
|
remainingtime=remainingpercent*avgtimeperpercent;
|
||||||
|
if(remainingtime && obj[0]>0)
|
||||||
|
document.getElementById('schedulereta').innerHTML=Math.round(remainingtime/1000)+" seconds";
|
||||||
|
else
|
||||||
|
document.getElementById('schedulereta').innerHTML="Calculating...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
alert('caught error'+e);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?
|
||||||
|
if($config['tours_assigner_percent']=="-1")
|
||||||
|
{
|
||||||
|
echo i18n("The tour scheduler is not currently running. You can start it by going to the link below.");
|
||||||
|
echo "<br />";
|
||||||
|
echo "<br />";
|
||||||
|
echo "<a href=\"tours_sa_config.php\">".i18n("Automatic Tour Assignment Configuration")."</a>";
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "<table>";
|
||||||
|
echo "<tr><td>".i18n("Assignment status").":</td><td><div id=\"schedulerstatus\" style=\"font-weight: bold;\"></div></td></tr>";
|
||||||
|
echo "<tr><td>".i18n("Assignment percent").":</td><td><div id=\"schedulerpercent\" style=\"font-weight: bold;\"></div></td></tr>";
|
||||||
|
echo "<tr><td>".i18n("Assignment ETA").":</td><td><div id=\"schedulereta\" style=\"font-weight: bold;\"></div></td></tr>";
|
||||||
|
echo "<tr><td align=\"center\" colspan=\"2\"><div id=\"updatestatus\" style=\"font-weight: bold; text-align: center;\"></div></td></tr>";
|
||||||
|
echo "</table>";
|
||||||
|
|
||||||
|
echo "<br />";
|
||||||
|
echo i18n("When the assignments are complete, the following links will be useful:");
|
||||||
|
echo "<br /><ul>";
|
||||||
|
echo "<li><a href=\"tours_assignments.php\">".i18n("Manage Student-Tour Assignments")."</a></li>";
|
||||||
|
echo "<li><a href=\"reports.php\">".i18n("Print/Export Reports")."</a></li>";
|
||||||
|
echo "</ul>";
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">updateStatus()</script>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
send_footer();
|
||||||
|
|
||||||
|
?>
|
@ -1 +1 @@
|
|||||||
83
|
84
|
||||||
|
6
db/db.update.84.sql
Normal file
6
db/db.update.84.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year`)
|
||||||
|
VALUES
|
||||||
|
( 'tours_assigner_activity', 'Done', 'Tour Assigner', '', '', '99999', '', '0'),
|
||||||
|
( 'tours_assigner_percent', '-1', 'Tour Assigner', '', '', '99999', '', '0'),
|
||||||
|
( 'tours_assigner_effort', '10000', 'Tour Assigner', '', '', '99999', 'This number controls how long and hard the tour assigner will look for a quality solution. Smaller numbers are lower effort. 100 is practically no effort, 1000 is moderate effort, 10000 is high effort. It can take several tens of minutes to run the assigner with high effort, but it gives a very good solution.', '-1');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user