[Swift-commit] r5699 - in SwiftApps/SciColSim: . bin

jonmon at ci.uchicago.edu jonmon at ci.uchicago.edu
Thu Mar 1 11:04:12 CST 2012


Author: jonmon
Date: 2012-03-01 11:04:11 -0600 (Thu, 01 Mar 2012)
New Revision: 5699

Modified:
   SwiftApps/SciColSim/annealing.swift
   SwiftApps/SciColSim/bin/showbest.sh
   SwiftApps/SciColSim/evolve.sh
   SwiftApps/SciColSim/sumloss.sh
Log:
o the average time of each optimizer call is now calculated and reported



Modified: SwiftApps/SciColSim/annealing.swift
===================================================================
--- SwiftApps/SciColSim/annealing.swift	2012-03-01 01:25:50 UTC (rev 5698)
+++ SwiftApps/SciColSim/annealing.swift	2012-03-01 17:04:11 UTC (rev 5699)
@@ -11,6 +11,8 @@
 {
     float loss;
     float sdev;
+    float tloss;
+    float tsdev;
 }
 
 global boolean FIX_VARIABLES = true;
@@ -174,8 +176,8 @@
 
                 if ( mlres[i][j].loss < ALOT )
                 {
-                    fprintf( some_out_filename, "N, %i, %i, %f, %f, |, %i, %f, [, %f, %f, %f, %f, %f, ], %f\n",
-                             i-1, j, dx[i][j], rejection[i][j], @toint(target_innov), mlres[i][j].loss, try_x[0], try_x[1], try_x[2], try_x[3], try_x[4], mlres[i][j].sdev );  // Note i-1 field: print that way to match with C++ output
+                    fprintf( some_out_filename, "N, %fs, %i, %i, %f, %f, |, %i, %f, [, %f, %f, %f, %f, %f, ], %f\n",
+                             mlres[i][j].tloss, i-1, j, dx[i][j], rejection[i][j], @toint(target_innov), mlres[i][j].loss, try_x[0], try_x[1], try_x[2], try_x[3], try_x[4], mlres[i][j].sdev );  // Note i-1 field: print that way to match with C++ output
 
                     // fprintf( "max_dist_swift.txt", color( Red,"multi_annealing: AF: max_dist.txt - tbd\n" ) ); // FIXME: max_dist is global set in evolve()
                 }

Modified: SwiftApps/SciColSim/bin/showbest.sh
===================================================================
--- SwiftApps/SciColSim/bin/showbest.sh	2012-03-01 01:25:50 UTC (rev 5698)
+++ SwiftApps/SciColSim/bin/showbest.sh	2012-03-01 17:04:11 UTC (rev 5699)
@@ -1,8 +1,8 @@
 #! /bin/sh
 
 awk '{
-  printf( "N %2d %2d %10.5f %5.2f | %5.2f %10.5f [ %5.2f %5.2f %10.5f %10.5f %10.5f ] %10.5f\n",
-  $2, $3, $4, $5, $7, $8, $10, $11, $12, $13, $14, $16);
+  printf( "N %.2f %2d %2d %10.5f %5.2f | %5.2f %10.5f [ %5.2f %5.2f %10.5f %10.5f %10.5f ] %10.5f\n",
+  $2, $3, $4, $5, $7, $8, $10, $11, $12, $13, $14, $16, $17);
 }'
 
 

Modified: SwiftApps/SciColSim/evolve.sh
===================================================================
--- SwiftApps/SciColSim/evolve.sh	2012-03-01 01:25:50 UTC (rev 5698)
+++ SwiftApps/SciColSim/evolve.sh	2012-03-01 17:04:11 UTC (rev 5699)
@@ -3,17 +3,24 @@
 touch multi_loss.data
 shift 1
 NWORKERS=${23}
+START=$(date +%s)
 OMP_NUM_THREADS=$NWORKERS $(dirname $0)/openmp-optimizer $* 2>&1
-if [ $? == 127 ];
+RC=$?
+END=$(date +%s)
+if [ $RC == 127 ];
 then
     echo "Missing openmp-optimizer binary" >&2
     exit 1
 fi
 
-if [ $? != 0 ];
+if [ $RC != 0 ];
 then
     echo "Problem running the openmp-optimizer" >&2
     exit 1
 fi
 
 mv multi_loss.data $datafile
+DIFF=$(($END-$START))
+echo $DIFF >> $datafile
+
+exit $RC

Modified: SwiftApps/SciColSim/sumloss.sh
===================================================================
--- SwiftApps/SciColSim/sumloss.sh	2012-03-01 01:25:50 UTC (rev 5698)
+++ SwiftApps/SciColSim/sumloss.sh	2012-03-01 17:04:11 UTC (rev 5699)
@@ -2,26 +2,36 @@
 
 awk '
 
-BEGIN { n = 0; loss = 0; }
+BEGIN { RS = ""; FS="\n";  loss = 0; loss_sq = 0; tloss = 0; tloss_sq = 0; n = 0; tn = 0; }
 
 {
-  loss += $1
-  loss_sq += ($1*$1)
-  n++
+  for(i=1;i<NF;i++)
+  {
+      loss += $i
+      loss_sq += ($i*$i)
+      n++
+  }
+  tloss += $NF
+  tloss_sq += ($NF*$NF)
+  tn++
 }
 
-END { 
+END {
 
   loss /= n;
   loss_sq /= n;
+  tloss /= tn;
+  tloss_sq /= tn;
 
   x = (loss_sq - (loss*loss))/n
+  y = (tloss_sq - ( tloss*tloss))/tn
   sdev = 2.0 * sqrt(x)
-  printf "loss sdev\n"
-  printf "%f %f\n", loss, sdev
+  tsdev = 2.0 * sqrt(y)
+
+  printf "loss sdev tloss tsdev\n"
+  printf "%f %f %f %f\n", loss, sdev, tloss, tsdev
 } ' $*
 
-
 # the awk script above implements this c++ logic from optimizer.cpp:
 #
 #    for (int i=0; i<N; i++){
@@ -43,14 +53,23 @@
 
 # Older logic, literal transcription from C++ (didnt handle multiline files correctly):
 
+# awk '
+
+# BEGIN { n = 0; loss = 0; }
+
 # {
-#   loss += $1/n
-#   loss_sq += ($1*$1)/n
+#   loss += $1
+#   loss_sq += ($1*$1)
+#   n++
 # }
-# 
-# { 
+
+# END {
+
+#   loss /= n;
+#   loss_sq /= n;
+
 #   x = (loss_sq - (loss*loss))/n
 #   sdev = 2.0 * sqrt(x)
 #   printf "loss sdev\n"
 #   printf "%f %f\n", loss, sdev
-# }
+# } ' $*




More information about the Swift-commit mailing list