From goldberg@cs.rpi.edu Tue Sep 17 22:35:00 1996
Received: from cs.rpi.edu (root@cs.rpi.edu [128.213.1.1]) by cs.sunysb.edu (8.6.12/8.6.9) with SMTP id WAA18946 for <skiena@sbcs.sunysb.edu>; Tue, 17 Sep 1996 22:34:59 -0400
From: goldberg@cs.rpi.edu
Received: from avs.cs.rpi.edu by cs.rpi.edu (5.67a/1.4-RPI-CS-Dept)
	id AA24235; Tue, 17 Sep 1996 22:32:13 -0400 (goldberg from avs.cs.rpi.edu)
Date: Tue, 17 Sep 96 22:29:09 EDT
Received: by avs.cs.rpi.edu (4.1/2.3-RPI-CS-client)
	id AA02318; Tue, 17 Sep 96 22:29:09 EDT
Message-Id: <9609180229.AA02318@avs.cs.rpi.edu>
To: skiena@sbcs.sunysb.edu
Status: RO

#!/usr/local/bin/perl

if (fork) {
    open (O, ">>$ARGV[0]");
    printf O
	"edge prob |  p  | greedy | nongreedy | time > 30min | class two\n";
    printf O
	"----------------------------------------------------------------\n";
    close (O);
    for $prob (2..6) {
	for ($size = 10; $size <= 90; $size += 10) {
	    $greedy = $nongreedy = $nonterm = $classtwo = 0;
	    for $seed (5001..5010) {
		open (F, "gg $size 0.$prob $seed | /bin/nice ec |");
		if ($line = <F>) {
		    $line =~ m/Class (.*) graph/;
		    if ($1 eq "one") {
			while (<F>) { 
			    $line = $_ ;
			    if ($line =~ m/^coordinate/) {
				@tosum = split (' ', $line);
				$sum = 0;
				foreach $elem (@tosum) { $sum += $elem; }
			    }
			}
			if ($sum == 0) { $greedy++; }
			else { $nongreedy++; }
		    }
		    else { $classtwo++; }
		}
		else { $nonterm++; }
		close(F);
	    }
	    open (O, ">>$ARGV[0]");
	    printf O ("   0.%d    | %3d |  %3d   |    %3d    |     %3d      |    %3d\n",
		      $prob, $size, $greedy, $nongreedy, $nonterm, $classtwo);
	    close(O);
	}
    }
}
else {
    while (1) {
	open (F, "/bin/ps -xg | /bin/grep ' ec\$' | /usr/ucb/tail -1 | /bin/cut -c1-5,14-16 |");
	$_ = <F>;
	($junk, $pid, $min) = split;
	if ($junk > 0) { $min = $pid; $pid = $junk; }
	if ($min >= 30) { kill 9, $pid; }
	$sleeptime = (30-$min) * 60;
	if ($sleeptime < 60) { $sleeptime = 60; }
	sleep $sleeptime;
    }
}

