-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmp-tables.pl
executable file
·86 lines (74 loc) · 2.13 KB
/
cmp-tables.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl
#
# Script to compare table output from NetLogo to see which parameters have
# been varied.
use strict;
use FindBin;
use lib $FindBin::Bin; # Needed to find nlogo2R
use nlogo2R;
my %param;
my %first_param;
my $first = 1;
my %other_param;
foreach my $file (@ARGV) {
my ($headers, $data) = nlogo2R::readfile($file, 0);
if($first) {
$first = 0;
foreach my $header (@$headers) {
next if $header eq 'run';
last if $header eq 'step';
$first_param{$header} = 1;
}
}
for(my $i = 1; $i <= $#$headers && $$headers[$i] ne "step"; $i++) {
$param{$$headers[$i]}->{$$data[0][$i]}++;
if(!$first && !defined($first_param{$$headers[$i]})) {
$other_param{$$headers[$i]} = 1;
}
}
print "Read \"$file\"\n";
}
print "Single parameter settings\nParameter,Value\n";
foreach my $parm (sort { $a cmp $b } keys(%param)) {
if(!defined($other_param{$parm})) {
my $valuet = $param{$parm};
if(scalar(keys(%$valuet)) == 1) {
print $parm, ",", join(",", keys(%$valuet)), "\n";
}
}
}
print "\nSingle parameter settings (not in all files)\nParameter,Value,N\n";
foreach my $parm (sort { $a cmp $b } keys(%param)) {
if(defined($other_param{$parm})) {
my $valuet = $param{$parm};
if(scalar(keys(%$valuet)) == 1) {
print $parm, ",", join(",", keys(%$valuet)), ",", join(",", values(%$valuet)), "\n";
}
}
}
print "\nMultiple settings\nParameter,Value1,N1,...\n";
foreach my $parm (sort { $a cmp $b } keys(%param)) {
if(!defined($other_param{$parm})) {
my $valuet = $param{$parm};
if(scalar(keys(%$valuet)) > 1) {
print "$parm";
foreach my $value (sort { $a cmp $b } keys(%$valuet)) {
print ",$value,$$valuet{$value}";
}
print "\n";
}
}
}
print "\nMultiple settings (not in all files)\nParameter,Value1,N1,...\n";
foreach my $parm (sort { $a cmp $b } keys(%param)) {
if(defined($other_param{$parm})) {
my $valuet = $param{$parm};
if(scalar(keys(%$valuet)) > 1) {
print "$parm";
foreach my $value (sort { $a cmp $b } keys(%$valuet)) {
print ",$value,$$valuet{$value}";
}
print "\n";
}
}
}