From goldberg@cs.rpi.edu Tue Sep 17 22:34:48 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 WAA18941 for <skiena@sbcs.sunysb.edu>; Tue, 17 Sep 1996 22:34:47 -0400
From: goldberg@cs.rpi.edu
Received: from avs.cs.rpi.edu by cs.rpi.edu (5.67a/1.4-RPI-CS-Dept)
	id AA24219; Tue, 17 Sep 1996 22:32:01 -0400 (goldberg from avs.cs.rpi.edu)
Date: Tue, 17 Sep 96 22:28:57 EDT
Received: by avs.cs.rpi.edu (4.1/2.3-RPI-CS-client)
	id AA02307; Tue, 17 Sep 96 22:28:57 EDT
Message-Id: <9609180228.AA02307@avs.cs.rpi.edu>
To: skiena@sbcs.sunysb.edu
Status: RO

#!/usr/local/bin/perl

if (fork) {
    open (O, ">>$ARGV[0]");
    printf O "  p  | Delta | greedy | nongreedy | time > 30min | class two\n";
    printf O "-------------------------------------------------------------\n";
    close(O);
    for $delta ( 3, 5, 10, 15) {
	$greedy = $nongreedy = $nonterm = $classtwo = 0;
	for $seed (5001..5010) {
	    open (F, "rgg 50 $delta $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
	    ("  50 |  %3d  |  %3d   |    %3d    |     %3d      |    %3d\n",
	     $delta, $greedy, $nongreedy, $nonterm, $classtwo);
	close(O);
    }
    for $delta (3, 10, 15, 25) {
	$greedy = $nongreedy = $nonterm = $classtwo = 0;
	for $seed (5001..5010) {
	    open (F, "rgg 100 $delta $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
	    (" 100 |  %3d  |  %3d   |    %3d    |     %3d      |    %3d\n",
	     $delta, $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;
    }
}

