📄 mktable.pl.in,v
字号:
a110 1 $lower_bound_file = shift @@ARGV;d138 4a141 1read_bounds($lower_bound_file) if defined $lower_bound_file;d172 3a174 2 open IN, "<$file" || die "Couldn't open $file for reading"; while (<IN>) {d182 2@1.11log@Better help text.Pass comment lines throughBetter matching for instance line@text@d170 1a170 1 if (m/^instance ([^:]+):\d+:-l\s+optimal\s+(\d+.?\d*)\x+:/) {d238 3a240 1 return $1+0;d284 1d291 2a292 1 record($instance_iter,$kind,$iter,'pct',$pct);@1.10log@Avoid division by zero. Doh!@text@d81 1a81 1 --version : Print a version info, then exitd143 7a149 1 read_file($_);d165 1d170 1a170 1 if (m/^instance ([^:]+):\d+:-l optimal (\d+.?\d*) :/) {@1.9log@Close the lower bound file stream@text@a169 1 close IN;d205 5a209 1 push @@pair,sprintf("%.2f",($pair[0]/$pair[1])); # LK/LKcc@1.8log@Fixed tabs in help.Fixed getting lower bound file name in option handling.@text@d170 1@1.7log@New option -b to allow reading lower bounds from a file, overridinglog file's idea of lower bounds.@text@d12 1d63 2a64 2 -b <lower_bound_file> : Read lower bounds from <lower_bound_file>, overridingd70 1a70 1 $render_pair_macro\{LK result,LKcc result,LKcc-LK,LK/LKcc\}d104 1d109 2a110 1 my $lower_bound_file = shift @@ARGV;@1.6log@Since LK is the baseline, it should always come before LKcc.@text@d19 1d62 3d86 1d105 5d134 2d156 13d252 2d269 2a270 2 if (m/^Milestone:Requested:End of LK step (\d+): length\s+\d+\.?\d+?\s+(-?\d+.\d+)\% [a-z]+ $lower_bound_name after (\d+\.\d+) .* sec/) { my ($iter,$pct,$time) = ($1,$2,$3);d273 3a275 2 record($instance_iter,$kind,$iter,'pct',($pct+0)); record($instance_iter,$kind,$iter,'time',($time+0));@1.5log@Try to allow setting of line macros.@text@d20 1a20 1my @@kinds=qw(deg no_d);d65 1a65 1 $render_pair_macro\{LKcc result,LK result,LK-LKcc,LK/LKcc\}d166 1a166 1 foreach $kind (@@kinds) {d176 2a177 2 push @@pair,sprintf("%.2f",($pair[1]-$pair[0])); push @@pair,sprintf("%.2f",($pair[1]/$pair[0]));@1.4log@Use TeX macros to render the line instead of trying to doit all ourselves. That way we can defer layout decisions.@text@d93 7d109 1a109 1 } else { die "$usage"."Option -l needs a string parameter"; }@1.3log@Added proper options processing.Output only one of pct, time at a time.Try to make the 1,n/10,n in proper order.@text@d47 6d62 10d154 3a156 1 print canon_name($instance);d158 1d162 1a162 1 printf " & %.2f",avg(@@list) if $#list >= 0;d168 6d175 2a176 1 print " \\\\ \\hline % $value_type\n";@1.2log@Removed old results.pl codeAdded prefix substitution (for Bentley distributions)Changed debug output to more TeX-friendly table output.@text@d12 7a18 4my $prog = "mktable.pl";my $usage = <<USAGE;./$prog <lower_bound_name> [out.<instance>..i<iters>..*.gz ...]USAGEd44 55a98 1my $lower_bound_name = shift @@ARGV;d101 3d108 1a108 2my $valuetype;foreach $valuetype ( qw(pct time) ) {d115 1a115 1 summarize($valuetype,$instance,$instance_iter);d117 1a117 1}d133 1a133 1 my ($valuetype,$instance,$instance_iter) = @@_;d137 1a137 1 my %ns = (1=>1,$n/10=>1,$n=>1);d139 1a139 1 foreach $iter ( sort keys %ns ) {d141 7a147 4 my @@list = @@{record($instance_iter,$kind,$iter,$valuetype)}; # print "%%$instance_iter $kind $iter $valuetype: avg ", # " of ",join(' ',@@list)," \n"; printf " & %.2f",avg(@@list) if defined @@list && $#list >= 0;d150 1a150 1 print " % $valuetype\n";d192 1d207 1a207 1 print "%%<";d209 2a210 2 if (m/^Milestone:Requested:End of LK step (\d+): length \d+(\.\d+)?\s+(\d+.\d+)\% [a-z]+ $lower_bound_name after (\d+\.\d+) .* sec/) { my ($iter,$dummy,$pct,$time) = ($1,$2,$3,$4);d215 1a215 1 # print "+";d217 1a217 1 # print ".";d220 1a220 1 print ">\n";d224 2a225 2 my ($instance_iter,$kind,$iter,$valuetype,$value) = @@_; my $key = "$instance_iter#$kind#$valuetype";d232 1@1.1log@Initial revision@text@d10 1d27 13d48 10a57 7foreach ( sort cmp_instance keys %instance_iters ) { my $instance_iter = $_; my $n = n_instance($instance_iter); print "\n"; print "# $instance_iter, n = $n\n"; my $instance = $instance_iter; $instance=s/#.*//; summarize($instance_iter);d62 11d74 1a74 1 my $instance_iter = shift;d79 2a80 2 my $valuetype; foreach $valuetype ( qw(pct time) ) {d82 4a85 6 foreach $iter ( sort keys %ns ) { my @@list = @@{record($instance_iter,$kind,$iter,$valuetype)}; print "#$instance_iter $kind $iter $valuetype: avg ", (sprintf "%.2f",avg(@@list)), " of ",join(' ',@@list)," \n"; }d88 1d101 2d111 3a113 1 return $a <=> $b;d144 1a144 1 print "<";d146 2a147 2 if (m/^Milestone:Requested:End of LK step (\d+): length \d+\s+(\d+.\d+)\% [a-z]+ $lower_bound_name after (\d+\.\d+) .* sec/) { my ($iter,$pct,$time) = ($1,$2,$3);a168 128#######! @@PERL@@ -w#### @@configure_input@@######## results.pl#### Summarize statistics from many experiments.####### usage: #### cat (list of filenames) | results.pl minfile #### Content of minfile is a collection of pairs of instance names followed by#### the lowest observed length. (or some other bound, e.g. Held-Karp lower bound)######## Generate TeX lines with data:#### Instance & #### LK time & #### LK+dec time & #### LK/LK+dec & #### LK tour (length/lower bound) & #### LK+dec (length/lower bound) & #### LK/LK+dec \\########### Key is instance name.#### Value is an array of: #### number of LK samples, #### sum LK time,#### sum LK tour length#### number of LK+dec samples, #### sum LK+dec time,#### sum LK+dec tour length###%instance = ();########## Find the minimum value observed for all the instances, drawn from the#### file named as the first argument.###$minfile = shift(@@ARGV);###open(LEAST,"<$minfile") || die "Can't open $minfile for reading.";###%least = ();###while (<LEAST>) {### m/^([^\s]+)\s+([^\s]+)/;### $least{$1}=$2+0;###}######@@file_names=();###while(<>) {### chop;### push(@@file_names,$_);###}####### Now parse the values found in individual experiments listed on stdin.###my $this_instance = "";###my $is_decluster;###my $seconds;######my $file;###foreach $file (@@file_names) {### print "\%\%\% file is $file\n";### open(IN,"zcat $file |") || die "Can't uncompress input files";###### while(<IN>) {### chop;### if (m/^LK [0-9]+\.[0-9]+\.[0-9]+([^\s]*)/) {### $is_decluster = $1 eq "deg";### } elsif (m/^\s+(\d+\.\d+) user seconds and/ ) {### $seconds = $1+0; # Last one is the total run time.### } elsif (m/^Instance name:\s+([^\s]+)/) {### $this_instance=$1;### #print "instance $1\n";### } elsif (m/^Length:\s+([^\s]+)/) {### my $aref = $instance{$this_instance};### my $this_length=$1+0;### if ( !defined($aref) ) {### $aref = $instance{$this_instance} = [ 0, 0, 0, 0, 0, 0 ];### }### if ( $is_decluster ) {### $$aref[3]++;### $$aref[4]+=$seconds;### $$aref[5]+=$this_length;### } else {### $$aref[0]++;### $$aref[1]+=$seconds;### $$aref[2]+=$this_length;### }### print "\t\% $this_instance ".join(' ',@@{$instance{$this_instance}})."\n";### }### }###}######print STDERR "\%\%\%\%\% Now ready to output results.\n";###print "\%\%\%\%\% Now ready to output results.\n";######my $i;###LOOP: for $i ( sort { (nv($a)+0)<=> (nv($b)+0) } keys %instance ) {###print " \%". join(' ',@@{$instance{$i}})."\n";### my ($nsamp, $time, $len, $dnsamp, $dtime, $dlen ) = @@{$instance{$i}};### if ( $nsamp != $dnsamp ) { ### print "\% following mismatch: nsamp $nsamp != dnsamp $dnsamp\n";### next LOOP; ### }### if ( !defined($least{$i}) ) { ### print "\% No lower bound for $i\n";### next LOOP; ### }### if ( $nsamp == 0 || $dnsamp == 0 ) {### print "\% nsamp $nsamp dnsamp $dnsamp\n";### next LOOP;### }######printf "%s \&\t%0.1f \&\t%0.1f \&\t%0.2f \&\t%0.2f\\%% \&\t%0.2f\\%% \&\t%0.2f\\ \\\\\n",### $i, $time/$nsamp, $dtime/$dnsamp, ($time/$nsamp)/($dtime/$dnsamp),### pct($len/$nsamp/$least{$i}), pct($dlen/$dnsamp/$least{$i}),### -pct($len/$nsamp/$least{$i})+ pct($dlen/$dnsamp/$least{$i});###}######exit 0;######sub pct {### my($a)=shift;### return ($a-1)*100;###}######sub nv { ### my ($a)=shift ;### $a =~ m/.*[^\d]+(\d+)/; ####print "a $a $1\n";### return $1+0;###}@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -