Commits

Shlomi Fish  committed 88e4a18

Fix bugs, refactor and add an --histogram opt.

  • Participants
  • Parent commits 3830d5a

Comments (0)

Files changed (1)

File fc-solve/source/scripts/compare-two-fc-pro-range-solver-dumps-solution-lengths.pl

 my $from_path;
 my $to_path;
 my $iters_threshold;
+my $should_histogram;
 
 GetOptions(
     'f|from=s' => \$from_path,
     't|to=s' => \$to_path,
-    'iters=i' => $iters_threshold,
+    'iters=i' => \$iters_threshold,
+    'histogram!' => \$should_histogram,
 ) or die "Cannot read get opts.";
 
 if (!defined $from_path)
         @{shift()}]
 }
 
-#my $mfi = l("./micro-finance-improved.fc-pro-dump.txt");
+# my $mfi = l("./micro-finance-improved.fc-pro-dump.txt");
 # my $mfi = l("./micro-finance-improved--flares-choice-fcpro.fc-pro-dump.txt");
 my $mfi = l($from_path);
 my $mfi_fcs = get_fcs($mfi);
     }
 }
 
+my %histogram;
+
 for my $i (keys @$new_iters)
 {
     if ($new_iters->[$i] >= 0 and $new_iters->[$i] < $iters_threshold)
     {
-        if ($new_fcpro->[$i] < $mfi_fcpro->[$i])
+        my $bef = $mfi_fcpro->[$i];
+        my $aft = $new_fcpro->[$i];
+        if ($aft < $bef)
         {
-            my $bef = $mfi_fcpro->[$i];
-            my $aft = $new_fcpro->[$i];
-            printf("I=%d %d -> %d Delta=%d%s\n", $i+1, $bef, $aft, $bef-$aft,
-                ($aft > $bef ? " (Worse)" : ""),
-            );
+            my $delta = $bef - $aft;
+            if ($should_histogram)
+            {
+                $histogram{$delta}++;
+            }
+            else
+            {
+                printf("I=%d %d -> %d Delta=%d%s\n", $i+1, $bef, $aft, $delta,
+                    ($aft > $bef ? " (Worse)" : ""),
+                );
+            }
         }
     }
 }
+
+if ($should_histogram)
+{
+    foreach my $delta (sort { $a <=> $b } keys %histogram)
+    {
+        print "$histogram{$delta}\t$delta\n";
+    }
+}