[Swift-commit] r6112 - in SwiftApps/SciColSim: . conf

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Sun Dec 30 13:53:22 CST 2012


Author: wilde
Date: 2012-12-30 13:53:21 -0600 (Sun, 30 Dec 2012)
New Revision: 6112

Added:
   SwiftApps/SciColSim/evolve-wrapper.sh
Modified:
   SwiftApps/SciColSim/Makefile
   SwiftApps/SciColSim/README
   SwiftApps/SciColSim/TODO
   SwiftApps/SciColSim/annealing.swift
   SwiftApps/SciColSim/conf/local.cf
   SwiftApps/SciColSim/conf/local.xml
   SwiftApps/SciColSim/gengraphs.sh
   SwiftApps/SciColSim/optimizer.cpp
   SwiftApps/SciColSim/sumloss.sh
   SwiftApps/SciColSim/swiftopt.sh
   SwiftApps/SciColSim/testopt.py
Log:
Add dynamic loss-limits and fix std-dev code in optimizer.cpp. Revert swift script to pre-osg version; retain separate osg version. Adjust combine scripts for floating point errors in combining multiple graph-sim (optimizer.cpp) runs.

Modified: SwiftApps/SciColSim/Makefile
===================================================================
--- SwiftApps/SciColSim/Makefile	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/Makefile	2012-12-30 19:53:21 UTC (rev 6112)
@@ -6,6 +6,7 @@
 
 openmp-optimizer: optimizer.cpp
 	g++ -DP_OPENMP -static -O -fopenmp -I boost_1_47_0 -o openmp-optimizer optimizer.cpp
+#	g++ -static -O -I boost_1_47_0 -o openmp-optimizer optimizer.cpp
 
 #t: t.cpp
 #	g++ -DP_OPENMP -static -O -fopenmp -I boost_1_47_0 -o t t.cpp

Modified: SwiftApps/SciColSim/README
===================================================================
--- SwiftApps/SciColSim/README	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/README	2012-12-30 19:53:21 UTC (rev 6112)
@@ -246,7 +246,7 @@
 	-trejection=<float>
 
 	-evoreruns=<int>
-	   How many times to re-run the evolve.sh app
+	   How many times to re-run the evolve.sh app  // MW: # times to rerun evolve() not evolve.sh ???
 
 	-startingjump=<float>
 	    Controls the dx and/or rejection variable
@@ -314,7 +314,7 @@
 #        1 multi_loss to initialize
 # c)     100 Annealing_cycles (serial)
 # d)        5 repeats (1 per param, serial) of multi_loss:
-# e)          1000 to 10000 annealing_repeats (parallel) == multi_loss
+# e)          1000 to 10000 annealing_repeats (parallel) == multi_loss  
 # f)            evolve()
 
 Plots

Modified: SwiftApps/SciColSim/TODO
===================================================================
--- SwiftApps/SciColSim/TODO	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/TODO	2012-12-30 19:53:21 UTC (rev 6112)
@@ -1,11 +1,12 @@
 
+
 --- Questions and Open Issues ---
 
 When sampling the graph, we compress the node ids. Is this OK?
 
 Same 40K epoch count?  Is this really feasible?
 
-What values for otehr loop parameters?
+What values for other loop parameters?
 
 What sampling?
 
@@ -21,13 +22,53 @@
 
 Graph partitioning? => for greater total parallelism?
 
+*** NEW 12/25/2012:
 
+Code does 1 multi_loss to initialize : what if this returns "ALOT" ?
 
+Should one "alot" among the 1,000 to 10,000 reruns cause the whole batch to be ignored? (because just one causes the entire average to be greater than any possible minimum).
+
+
+
 x = done, - = in progress
 
-
 --- Top Prios ---
 
+For Andrey's Dec 2012 campaign:
+
+[ ]  generate test graph set
+[ ]  make graph file an optimizer parameter
+[ ]  check state of random number gens for both reprodicbility and diversity
+[ ]  count number of max_loss exceeded cases for sanity check
+[ ]  add timer to max_loss exit criter; track seeds that cause max_loss timer or value exceeding for repro testing.
+[ ]  constrain NUniverses to just those needed for the multiple threaded reruns
+[ ]  add a time check to ensure the dynamic limiter is kicking in to limit time
+[ ]  adjust rerunsPerApp to a dynamic value based on a scaling test
+[ ]  run good scaling tests to see if limiter is working
+[ ]  run actual annealing runs
+[ ]  improve output to validate the annealings and graphsims
+[ ]  do bug runs
+[ ]  get theresources for above: Beagle, Cloud, etc
+
+
+--- Older notes from graph studies with David:
+
+
+- Runtime, ram, science results (single floating pointer number called loss) for each param
+- Params = nodes, edges, and ti
+- As edges/nodes increase, time increases
+- 1000 osg jobs between 10 seconds and 24 hours
+- Example: iterate over ti in units of 100, graph sizes should be 
+- Automate, return eof when timed out, set max run time
+- Ability to see gprof output
+- Once with control structure he needs, then one run with large size to show hockey stick
+- Generate a table, then generate a graph
+- Email uc3 and midway account information
+
+
+
+From Jon's work:
+
 [x] Get code in shape for Andrey to do a comparison run between fast .py and .swift runs on his Mac.
 
 [-] Get initial tests run on Beagle at scale

Modified: SwiftApps/SciColSim/annealing.swift
===================================================================
--- SwiftApps/SciColSim/annealing.swift	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/annealing.swift	2012-12-30 19:53:21 UTC (rev 6112)
@@ -35,42 +35,6 @@
     // tracef("newx(%f,%f)=%f\n",x,dx,nx);
 }
 
-app (file outfile, file loss ) evolve_wget ( string args[], file graph )
-{
-   bash "-c" @strcat("wget http://www.ci.uchicago.edu/~davidk/SciColSim/evolve-wrapper.sh; ",
-                     "chmod +x ./evolve-wrapper.sh; ./evolve-wrapper.sh ", @loss, " ",
-                     args[0], " ", args[1], " ", args[2], " ", args[3], " ", args[4], " ", 
-                     args[5], " ", args[6], " ", args[7], " ", args[8], " ", args[9], " ", 
-                     args[10], " ", args[11], " ", args[12], " ", args[13], " ", args[14],
-                     " ", args[15], " ", args[16], " ", args[17], " ", args[18], " ", 
-                     args[19], " ", args[20], " ", args[21], " ", args[22], " ", args[23])
-   stdout=@outfile;
-}
-
-app (file outfile, file loss ) evolve_wget_short ( string args[], file graph )
-{
-   bash_short "-c" @strcat("wget http://www.ci.uchicago.edu/~davidk/SciColSim/evolve-wrapper.sh; ",
-                     "chmod +x ./evolve-wrapper.sh; ./evolve-wrapper.sh ", @loss, " ",
-                     args[0], " ", args[1], " ", args[2], " ", args[3], " ", args[4], " ", 
-                     args[5], " ", args[6], " ", args[7], " ", args[8], " ", args[9], " ", 
-                     args[10], " ", args[11], " ", args[12], " ", args[13], " ", args[14],
-                     " ", args[15], " ", args[16], " ", args[17], " ", args[18], " ", 
-                     args[19], " ", args[20], " ", args[21], " ", args[22], " ", args[23])
-   stdout=@outfile;
-}
-
-app (file outfile, file loss ) evolve_wget_long ( string args[], file graph )
-{
-   bash_long "-c" @strcat("wget http://www.ci.uchicago.edu/~davidk/SciColSim/evolve-wrapper.sh; ",
-                     "chmod +x ./evolve-wrapper.sh; ./evolve-wrapper.sh ", @loss, " ",
-                     args[0], " ", args[1], " ", args[2], " ", args[3], " ", args[4], " ", 
-                     args[5], " ", args[6], " ", args[7], " ", args[8], " ", args[9], " ", 
-                     args[10], " ", args[11], " ", args[12], " ", args[13], " ", args[14],
-                     " ", args[15], " ", args[16], " ", args[17], " ", args[18], " ", 
-                     args[19], " ", args[20], " ", args[21], " ", args[22], " ", args[23])
-   stdout=@outfile;
-}
-
 app  (file outfile, file loss ) evolve ( string args[], file graph )
 {
     evolve @loss args stdout=@outfile;  // graph is passed implicitly
@@ -86,315 +50,266 @@
   Program structure:
 
   main
-  optimizer_sweep() - formerly, python script
-  multi_annealing()
-  multi_loss()
-  evolve()
-  sumloss()
+    optimizer_sweep() - formerly, python script
+      multi_annealing()
+        multi_loss()
+         evolve()
+       sumloss()
 */
 
-( file bestfile, file maxfile ) multi_annealing ( string some_out_filename,
-                                                  float T_start,
-                                                  float T_end,
-                                                  float Target_rejection,
-                                                  int evolve_reruns,
-                                                  float starting_jump,
-                                                  float params0[],
-                                                  float target_innov,
-                                                  int annealing_cycles )
+(file bestfile, file maxfile) multi_annealing (string some_out_filename,
+                                               float T_start,
+                                               float T_end,
+                                               float Target_rejection,
+                                               int evolve_reruns,
+                                               float starting_jump,
+                                               float params0[],
+                                               float target_innov,
+                                               int annealing_cycles)
 {
-    int cycle      = 10;     // const
-    int NEVOPARAMS = 5;      // const - 5 params, alpha 1,m through delta, does not include target_innovation
+  int cycle      = 10;     // const
+  int NEVOPARAMS = 5;      // const - 5 params, alpha 1,m through delta, does not include target_innovation
 
-    float rejection[][];  // [i][j] where i is cycle and j is evolve-parameter (alpha_i, alpha_m, beta, gamma, delta)
-    float trejection[][];
+  float rejection[][];  // [i][j] where i is cycle and j is evolve-parameter (alpha_i, alpha_m, beta, gamma, delta)
+  float trejection[][];
 
-    float x[][], dx[][], curr_loss[], curr_sdev[];
+  float x[][], dx[][], curr_loss[], curr_sdev[];
 
-    Res mlres[][];
+  Res mlres[][];
 
-    mlres[0][0] = multi_loss( T_start, T_end, annealing_cycles, Target_rejection, starting_jump, 0, 0, params0, target_innov, evolve_reruns ); // FIXME: serves for all evolve-params ???
-    tracef( "multi_annealing: AR: initial: %f +- %f\n", mlres[0][0].loss, mlres[0][0].sdev );
+  mlres[0][0] = multi_loss(T_start, T_end, annealing_cycles, Target_rejection,
+                          starting_jump, 0, 0, params0, target_innov, evolve_reruns ); // FIXME: serves for all evolve-params ???
+  tracef( "multi_annealing: AR: initial: %f +- %f\n", mlres[0][0].loss, mlres[0][0].sdev );
 
-    foreach j in [0:NEVOPARAMS-1]
-    {
-        x[0][j]         = params0[j];
-        dx[0][j]        = starting_jump;
-        rejection[0][j] = 0.0;
-        curr_loss[j]    = mlres[0][0].loss;
-        curr_sdev[j]    = mlres[0][0].sdev;
-    }
+  foreach j in [0:NEVOPARAMS-1] {
+    x[0][j]         = params0[j];
+    dx[0][j]        = starting_jump;
+    rejection[0][j] = 0.0;
+    curr_loss[j]    = mlres[0][0].loss;
+    curr_sdev[j]    = mlres[0][0].sdev;
+  }
 
-    iterate iter_i   // number of annealing cycles
-    {
-        int i = iter_i + 1;  // i ranges [1:n] in the swift script so that [0] can be the initial condition
+  iterate iter_i {  // number of annealing cycles
+    int i = iter_i + 1;  // i ranges [1:n] in the swift script so that [0] can be the initial condition
 
-        // set new temperature, rejection threshold, and dx values for this cycle
-        float temperature = T_start*exp( @tofloat( i-1 ) * ( jlog( T_end ) - jlog( T_start ) ) / @tofloat( annealing_cycles ) );
+    // set new temperature, rejection threshold, and dx values for this cycle
+    float temperature = T_start*exp( @tofloat( i-1 ) * ( jlog( T_end ) - jlog( T_start ) ) / @tofloat( annealing_cycles ) );
 
-        tracef( @strcat( "multi_annealing: AR: i=%i ....T = ", color( 3, "%f" ),"\n" ), i, temperature );
+    tracef( @strcat( "multi_annealing: AR: i=%i ....T = ", color( 3, "%f" ),"\n" ), i, temperature );
 
-        // On each new "major" cycle within the annealing_cycles (other than the first) set new rejection and dx values
+    // On each new "major" cycle within the annealing_cycles (other than the first) set new rejection and dx values
 
-        if ( i %% cycle == 1 && i > 1 )
-        {
-            tracef( "multi_annealing: new cycle at i=%i\n", i );
-            tracef( color( Pink, "multi_annealing: AR: New cycle at %i: prev dx[0-4]=[%f %f %f %f %f]\n" ), i, dx[i-1][0], dx[i-1][1], dx[i-1][2], dx[i-1][3], dx[i-1][4] );
-            foreach k in [0:NEVOPARAMS-1]
-            {
-                float newrejection = rejection[i-1][k] / @tofloat( cycle );
-                if ( newrejection > 0.0 )
-                {
-                    dx[i][k] = dx[i-1][k] / ( newrejection / Target_rejection );
-                    // FIXME: re-enable: rejection[i][k]=0.0;
-                    trejection[i][k]=0.0;
-                }
-                else
-                {
-                    dx[i][k] = dx[i-1][k] * 2.0;
-                    // FIXME: re-enable: rejection[i][k]=rejection[i-1][k];
+    if (i %% cycle == 1 && i > 1) {
+      tracef( "multi_annealing: new cycle at i=%i\n", i );
+      tracef( color( Pink, "multi_annealing: AR: New cycle at %i: prev dx[0-4]=[%f %f %f %f %f]\n" ),
+                     i, dx[i-1][0], dx[i-1][1], dx[i-1][2], dx[i-1][3], dx[i-1][4] );
+      foreach k in [0:NEVOPARAMS-1] {
+        float newrejection = rejection[i-1][k] / @tofloat( cycle );
+        if (newrejection > 0.0) {
+          dx[i][k] = dx[i-1][k] / ( newrejection / Target_rejection );
+          // FIXME: re-enable: rejection[i][k]=0.0;
+          trejection[i][k]=0.0;
+        }
+        else {
+          dx[i][k] = dx[i-1][k] * 2.0;
+          // FIXME: re-enable: rejection[i][k]=rejection[i-1][k];
                     trejection[i][k]=newrejection;
-                }
+        }
                 // FIXME: HANGS? : tracef(color(Red,"Recomputed rejection: i=%d k=%d dx[i][k]=%f\n"), i, k, dx[i][k]);
+      }
+      tracef( color( Blue, "multi_annealing: AR: New cycle at %i: dx[0-4]=[%f %f %f %f %f]\n" ),
+                             i, dx[i][0], dx[i][1], dx[i][2], dx[i][3], dx[i][4] );
+    }
+    else { // If not new cycle, set dx[i][*] from previous dx ([i-1]). rejection[i][j] is set later.
+      foreach k in [0:NEVOPARAMS-1] {
+        dx[i][k] = dx[i-1][k];
+      }
+    }
+    iterate j {  // Try a new value for each non-fixed param; then write results and accept or reject
+      int curr = ( i * NEVOPARAMS ) + j;
+      int prev = curr-1;
+
+      if ( /* (!FIX_VARIABLES) || */ ( var_fixed[j] == 0 ) ) {  // Adjustable vars
+           // fixed=1,1,0,0,0: FIXME: FIX_VARIABLES flag has faulty logic but OK when TRUE
+        float try_x[];
+        foreach k in [0:NEVOPARAMS-1] { // Select the evolve params to try
+          if (k < j) {
+            try_x[k] = x[i][k]; // already set x[i][k]
+          }
+          else {
+            if (k == j) {
+              try_x[k] = newx(x[i-1][j], dx[i-1][j]); // permute x[i-1][j]
             }
-            tracef( color( Blue, "multi_annealing: AR: New cycle at %i: dx[0-4]=[%f %f %f %f %f]\n" ), i, dx[i][0], dx[i][1], dx[i][2], dx[i][3], dx[i][4] );
-        }
-        else  // If not new cycle, set dx[i][*] from previous dx ([i-1]). rejection[i][j] is set later.
-        {
-            foreach k in [0:NEVOPARAMS-1]
-            {
-                dx[i][k] = dx[i-1][k];
+            else { // k > j
+              try_x[k] = x[i-1][k]; // use x[i-1][k] (from prior cycle)
             }
+          }
         }
+        tracef( @strcat( "multi_annealing: AR: ", color( 10,"%f" ), " ", color( 9,"%i" ),"\n" ), try_x[j], j );
+        mlres[i][j] = multi_loss( T_start, T_end, annealing_cycles, Target_rejection, starting_jump,
+                                  i, j, try_x, target_innov, evolve_reruns ); // do the N evolve()'s, N=evolve_rerusn
+        tracef( "multi_annealing: AR: %f +- %f\n", mlres[i][j].loss, mlres[i][j].sdev );
+        // Beyond this point, x[] and dx[] are being set for this i,j
+        float ALOT = 100000000000.0; // 100,000,000,000. = 10^11
+        if (mlres[i][j].loss < ALOT) {
+          fprintf( some_out_filename, "N, %fs, %i, %i, %f, %f, |, %i, %f, [, %f, %f, %f, %f, %f, ], %f\n",
+                  mlres[i][j].tavg, 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
 
-        iterate j   // Try a new value for each non-fixed param; then write results and accept or reject
-        {
-            int curr = ( i * NEVOPARAMS ) + j;
-            int prev = curr-1;
-
-            if ( /* (!FIX_VARIABLES) || */ ( var_fixed[j] == 0 ) ) {  // Adjustable vars
-                // fixed=1,1,0,0,0: FIXME: FIX_VARIABLES flag has faulty logic but OK when TRUE
-                float try_x[];
-                foreach k in [0:NEVOPARAMS-1] // Select the evolve params to try
-                {
-                    if ( k < j )
-                    {
-                        try_x[k] = x[i][k]; // already set x[i][k]
-                    }
-                    else
-                    {
-                        if ( k == j )
-                        {
-                            try_x[k] = newx(x[i-1][j], dx[i-1][j]); // permute x[i-1][j]
-                        }
-                        else // k > j
-                        {
-                            try_x[k] = x[i-1][k]; // use x[i-1][k] (from prior cycle)
-                        }
-                    }
-                }
-                tracef( @strcat( "multi_annealing: AR: ", color( 10,"%f" ), " ", color( 9,"%i" ),"\n" ), try_x[j], j );
-
-                mlres[i][j] = multi_loss( T_start, T_end, annealing_cycles, Target_rejection, starting_jump, i, j, try_x, target_innov, evolve_reruns ); // do the N evolve()'s, N=evolve_rerusn
-
-                tracef( "multi_annealing: AR: %f +- %f\n", mlres[i][j].loss, mlres[i][j].sdev );
-                // Beyond this point, x[] and dx[] are being set for this i,j
-
-                float ALOT = 100000000000.0; // 100,000,000,000. = 10^11
-
-                if ( mlres[i][j].loss < ALOT )
-                {
-                    fprintf( some_out_filename, "N, %fs, %i, %i, %f, %f, |, %i, %f, [, %f, %f, %f, %f, %f, ], %f\n",
-                             mlres[i][j].tavg, 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()
-                }
-                else // does this ever occur? if so did we want to still do the ratio computation above???
-                {
-                    fprintf( some_out_filename, "A, %fs, %i, %i, %f, %f, |, %i, %f, [, %f, %f, %f, %f, %f, ], %f\n",
-                             mlres[i][j].tavg, 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
-
-                    //tracef( "multi_annealing: Loss %f > ALOT at [i][j] = [%d][%d]\n", mlres[i][j].loss, i ,j );
-                }
-
-                float ratio = min( 1.0, exp( -( mlres[i][j].loss - curr_loss[prev] ) / temperature ) );
-                float r     = (random()); //Java already returns a random float between [0.0-1.0]
-
-                tracef("multi_annealing: AR: %f vs %f\n", r, ratio);
-
-                if (r > ratio) // Reject new parameter
-                {
-                    x[i][j]         = x[i-1][j];
-                    if ( i %% cycle == 1 && i > 1 )
-                    {
-                      rejection[i][j] = trejection[i][j] + 1.0;    // FIXME: triple-check this!
-                    }
-                    else
-                    {
-                      rejection[i][j] = rejection[i-1][j] + 1.0;  // FIXME: AR: Is this correct? incr rejection?
-                    }
-                    curr_loss[curr] = curr_loss[prev];
-                    curr_sdev[curr] = curr_sdev[prev];
-                    // FIXME: AR: the following prints seem to replicate values in the .cpp version - please clarify.
-                    tracef( "multi_annealing: AR: %i,%i %i Did not accept: %f (%i)\n", i, j, i, try_x[j], j );
-                    tracef( "multi_annealing: AR: %f %f %f %f %f\n", try_x[0],try_x[1],try_x[2],try_x[3],try_x[4] );
-                }
-                else // Accept new parameter
-                {
-                    tracef( "multi_annealing: Accepting try_x[j], i=%i j=%i\n",i,j );
-
-                    x[i][j]         = try_x[j];
-                    if ( i %% cycle == 1 && i > 1 )
-                    {
-                      rejection[i][j] = trejection[i][j];    // FIXME: triple-check this!
-                    }
-                    else
-                    {
-                      rejection[i][j] = rejection[i-1][j];  // FIXME: AR: Is this correct? no incr of rejection?
-                    }
-                    curr_loss[curr] = mlres[i][j].loss;
-                    curr_sdev[curr] = mlres[i][j].sdev;
-
-                    tracef( "multi_annealing: Accepting try_x[j], i=%i j=%i try_x[j]=%f\n", i, j, try_x[j] );
-                    float rj[];
-                    foreach k in [0:NEVOPARAMS-1]
-                    {
-                        if (k <= j)
-                        {
-                            rj[k] = rejection[i][k]; // Was either set from previous j or just set for this j
-                        }
-                        else
-                        {
-                            rj[k] = rejection[i-1][k]; // Not yet set, use previous
-                        }
-                    }
-                    tracef(@strcat("multi_annealing: AR: [%i][%i] ", color(8,"Rejection counts: "),
-                                   color(1,"%f"), " ", color(7,"%f"), " ", color(5,"%f"), " ", color(9,"%f"), " ", color(6,"%f"), "\n\n"),
-                           i, j, rj[0], rj[1], rj[2], rj[3], rj[4]);
-                    tracef(@strcat("multi_annealing: AR: %i ", color(8,"***** Did accept! "),
-                                   color(1,"%f"), " ", color(7,"%f"), " ", color(5,"%f"), " ", color(9,"%f"), " ", color(6,"%f"), "\n\n"),
-                           i, try_x[0], try_x[1], try_x[2], try_x[3], try_x[4]);
-                }
+                  // fprintf( "max_dist_swift.txt", color( Red,"multi_annealing: AF: max_dist.txt - tbd\n" ) );
+                  // FIXME: max_dist is global set in evolve()
+        }
+        else { // does this ever occur? if so did we want to still do the ratio computation above???
+          fprintf( some_out_filename, "A, %fs, %i, %i, %f, %f, |, %i, %f, [, %f, %f, %f, %f, %f, ], %f\n",
+                   mlres[i][j].tavg, 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
+          //tracef( "multi_annealing: Loss %f > ALOT at [i][j] = [%d][%d]\n", mlres[i][j].loss, i ,j );
+        }
+        float ratio = min( 1.0, exp( -( mlres[i][j].loss - curr_loss[prev] ) / temperature ) );
+        float r = (random()); //Java already returns a random float between [0.0-1.0]
+        tracef("multi_annealing: AR: %f vs %f\n", r, ratio);
+        if (r > ratio) { // Reject new parameter
+          x[i][j] = x[i-1][j];
+          if (i %% cycle == 1 && i > 1) {
+            rejection[i][j] = trejection[i][j] + 1.0;    // FIXME: triple-check this!
+          }
+          else {
+            rejection[i][j] = rejection[i-1][j] + 1.0;  // FIXME: AR: Is this correct? incr rejection?
+          }
+          curr_loss[curr] = curr_loss[prev];
+          curr_sdev[curr] = curr_sdev[prev];
+          // FIXME: AR: the following prints seem to replicate values in the .cpp version - please clarify.
+          tracef( "multi_annealing: AR: %i,%i %i Did not accept: %f (%i)\n", i, j, i, try_x[j], j );
+          tracef( "multi_annealing: AR: %f %f %f %f %f\n", try_x[0],try_x[1],try_x[2],try_x[3],try_x[4] );
+        }
+        else { // Accept new parameter
+          tracef( "multi_annealing: Accepting try_x[j], i=%i j=%i\n",i,j );
+          x[i][j] = try_x[j];
+          if (i %% cycle == 1 && i > 1) {
+            rejection[i][j] = trejection[i][j];    // FIXME: triple-check this!
+          }
+          else {
+            rejection[i][j] = rejection[i-1][j];  // FIXME: AR: Is this correct? no incr of rejection?
+          }
+          curr_loss[curr] = mlres[i][j].loss;
+          curr_sdev[curr] = mlres[i][j].sdev;
+          tracef( "multi_annealing: Accepting try_x[j], i=%i j=%i try_x[j]=%f\n", i, j, try_x[j] );
+          float rj[];
+          foreach k in [0:NEVOPARAMS-1] {
+            if (k <= j) {
+              rj[k] = rejection[i][k]; // Was either set from previous j or just set for this j
             }
-            else // Fixed Vars
-            {
-                x[i][j]         = x[i-1][j];
-                rejection[i][j] = rejection[i-1][j];
-                curr_loss[curr] = curr_loss[prev];
-                curr_sdev[curr] = curr_sdev[prev];
-                // dx[i][j] not set for fixed vars
+            else {
+              rj[k] = rejection[i-1][k]; // Not yet set, use previous
             }
-        } until( j == (NEVOPARAMS-1) );
+          }
+          tracef(@strcat("multi_annealing: AR: [%i][%i] ", color(8,"Rejection counts: "),
+                         color(1,"%f"), " ", color(7,"%f"), " ", color(5,"%f"), " ", color(9,"%f"), " ", color(6,"%f"), "\n\n"),
+                         i, j, rj[0], rj[1], rj[2], rj[3], rj[4]);
+          tracef(@strcat("multi_annealing: AR: %i ", color(8,"***** Did accept! "),
+                         color(1,"%f"), " ", color(7,"%f"), " ", color(5,"%f"), " ", color(9,"%f"), " ", color(6,"%f"), "\n\n"),
+                         i, try_x[0], try_x[1], try_x[2], try_x[3], try_x[4]);
+          }
+        }
+        else {// Fixed Vars
+          x[i][j] = x[i-1][j];
+          rejection[i][j] = rejection[i-1][j];
+          curr_loss[curr] = curr_loss[prev];
+          curr_sdev[curr] = curr_sdev[prev];
+          // dx[i][j] not set for fixed vars
+        }
+      } until( j == (NEVOPARAMS-1) );
     } until( iter_i == (annealing_cycles-1) );
 }
 
-(Res r) multi_loss( float t_start, float t_end, int annealing_steps, float t_rejection, float starting_jump, int ci, int cj, float x[], float target_innov, int evolve_reruns )
+(Res r) multi_loss(float t_start, float t_end, int annealing_steps, float t_rejection, float starting_jump,
+                   int ci, int cj, float x[], float target_innov, int evolve_reruns)
 {
-    tracef("%q\n", x);
-    file rfile[];
-    file ofile[]; // FIXME: to obtain timings and otehr stats
+  tracef("%q\n", x);
+  file rfile[];
+  file ofile[]; // FIXME: to obtain timings and otehr stats
 
-    tracef( "multi_loss: entered: ci=%i cj=%i target_innov=%f evolve_reruns=%i x=%q\n",ci, cj, target_innov,evolve_reruns,x );
+  tracef( "multi_loss: entered: ci=%i cj=%i target_innov=%f evolve_reruns=%i x=%q\n",ci, cj, target_innov,evolve_reruns,x );
 
-    int appCalls = @toint(@tofloat(evolve_reruns) / @tofloat(rerunsPerApp));  // FIXME: handle fractional issues and rounding etc. For now must divide evenly
+  int appCalls = @toint(@tofloat(evolve_reruns)/@tofloat(rerunsPerApp)); // FIXME: handle fractional issues and rounding etc.
+                                                                         // For now must divide evenly
+  tracef("multi_loss appCalls=%i\n", appCalls);
 
-    tracef("multi_loss appCalls=%i\n", appCalls);
-
-    foreach i in [1:appCalls]
-    {  // repeats of the evolove() - same as n_reruns
-        file outfile; // FIXME: map and save in future
-        string args[] = [ // FIXME: move this to a setargs() function
+  foreach i in [1:appCalls] { // repeats of the evolove() - same as n_reruns
+    file outfile; // FIXME: map and save in future
+    string args[] = [ // FIXME: move this to a setargs() function
             //    alpha_i           alpha_m        beta           gamma          delta          target_innov
                  @strcat(x[0]),  @strcat(x[1]), @strcat(x[2]), @strcat(x[3]), @strcat(x[4]), @strcat(target_innov),
-
             //     n_epochs n_steps   evolve_reruns           range
             //    "40000",   "20",  @strcat(evolve_reruns),    "2",
                   "40000",   "20",  @strcat(rerunsPerApp),     "2",
-
             //    verbose_level
                     "1",
-
-            //    T_start             T_end          Annealing_steps         Target_rejection         Starting_jump
-                 @strcat(t_start), @strcat(t_end), @strcat(annealing_steps), @strcat(t_rejection), @strcat(starting_jump),
-
+            //    T_start           T_end           Annealing_steps           Target_rejection      Starting_jump
+                  @strcat(t_start), @strcat(t_end), @strcat(annealing_steps), @strcat(t_rejection), @strcat(starting_jump),
             //    FREEZE: alpha_i alpha_m beta gamma delta
-                            "0",    "0",  "0",  "0",  "0",
+                          "0",    "0",    "0", "0",  "0",
+            //    operation-code:(m,a)  Nworkers           seed
+                  "m",                  @strcat(Nworkers), @arg("seed", "0" ) ];
 
-            //   operation-code:(m,a)    Nworkers           seed
-                      "m",            @strcat(Nworkers), @arg("seed", "0" ) ];
+    file graph <"movie_graph.txt">;
 
-        file graph <"movie_graph.txt">;
+    (outfile, rfile[i]) = evolve(args, graph);
+    tracef("multi_loss: i=%i calling evolve, args=%q\n", i, args);
+    // tracef("multi_loss: after evolve: i=%i %k %k\n", i, outfile, rfile[i]);
+  }
+  file sumfile = sumloss(rfile);
+  r = readData(sumfile);
 
-        if(@arg("wget") == "true") {
-
-           // Separate long runs from short runs when longruns option is set
-           if(@arg("longruns") == "true") {
-              float mean = @tofloat(@arg("minrange")) + @tofloat(@arg("maxrange")) / 2.0;
-              if(target_innov <= mean) {
-                 ( outfile, rfile[i] ) = evolve_wget_short( args, graph );
-              } 
-              else {
-                 ( outfile, rfile[i] ) = evolve_wget_long( args, graph );
-              }
-           }
-
-          ( outfile, rfile[i] ) = evolve_wget( args, graph );
-        }
-         
-        else {
-           ( outfile, rfile[i] ) = evolve( args, graph );
-        }
-
-        tracef("multi_loss: i=%i calling evolve, args=%q\n", i, args);
-        // tracef("multi_loss: after evolve: i=%i %k %k\n", i, outfile, rfile[i]);
-    }
-    file sumfile = sumloss(rfile);
-    r            = readData(sumfile);
-
-    tracef("multi_loss: returning: ci=%i cj=%i r.loss=%f r.sdev=%f\n",ci,cj,r.loss,r.sdev);
-    // file statfile = sumstats(ofile);  FIXME: to obtain timings and otehr stats
-    // s = readStat(statsfile);          FIXME: to obtain timings and otehr stats
+  tracef("multi_loss: returning: ci=%i cj=%i r.loss=%f r.sdev=%f\n",ci,cj,r.loss,r.sdev);
+  // file statfile = sumstats(ofile);  FIXME: to obtain timings and other stats
+  // s = readStat(statsfile);          FIXME: to obtain timings and other stats
 }
 
 optimizer_sweep() // Implements logic of python driver script
 {
 
-    int minrange = @toint(@arg("minrange", "58"));
-    int maxrange = @toint(@arg("maxrange", "59"));
-    int rangeinc = @toint(@arg("rangeinc", "50"));
+  int minrange = @toint(@arg("minrange", "58"));
+  int maxrange = @toint(@arg("maxrange", "59"));
+  int rangeinc = @toint(@arg("rangeinc", "50"));
 
-    // FIXME: add provision for random priming and random param values when x[i] == -100 (see optimizer.cpp main())
+  // FIXME: add provision for random priming and random param values when x[i] == -100 (see optimizer.cpp main())
 
-    int nreps = @toint(@arg("nreps", "1"));
+  int nreps = @toint(@arg("nreps", "1"));
 
-//    file bestfile <single_file_mapper; file=@strcat("output/T",target,".R",rep,".best_opt_some")>;
-//    file maxfile <single_file_mapper; file=@strcat("output/T",target,".R",rep,".max_dist")>;
+//file bestfile <single_file_mapper; file=@strcat("output/T",target,".R",rep,".best_opt_some")>;
+//file maxfile <single_file_mapper; file=@strcat("output/T",target,".R",rep,".max_dist")>;
 
-    foreach target_innov in [minrange:maxrange:rangeinc]
-    {
-        foreach rep in [1:nreps]
-        {
-            string some_out_filename = @strcat( "best.T", @strcat(target_innov), ".R", @strcat(rep), ".txt" );
-            file outfile;  // <single_file_mapper; file=@strcat("output/T",target_innov,".R",rep,".out")>;
-            file lossfile; // <single_file_mapper; file=@strcat("output/T",target_innov,".R",rep,".loss_data")>;
+  foreach target_innov in [minrange:maxrange:rangeinc] {
+    foreach rep in [1:nreps] {
 
-            ( outfile,lossfile ) = multi_annealing(
-                                                    some_out_filename,
-						                            @tofloat(@arg("tstart", "2.0")),
-                                                    @tofloat(@arg("tend", "0.01")),
-                                                    @tofloat(@arg("trejection", "0.3")),
-                                                    @toint(@arg("evoreruns", "100")),
-                                                    @tofloat(@arg("startingjump", "2.3")),
-                                                    [@tofloat(@arg("alphai", "0.0")), @tofloat(@arg("alpham", "0.0")), @tofloat(@arg("beta", "4.0")), @tofloat(@arg("gamma", "50.0")), @tofloat(@arg("delta", "-1.0"))],
-                                                    @tofloat(target_innov),
-                                                    @toint(@arg("annealingcycles", "50")) );
-        }
+      string some_out_filename = @strcat( "best.T", @strcat(target_innov), ".R", @strcat(rep), ".txt" );
+      file outfile;  // <single_file_mapper; file=@strcat("output/T",target_innov,".R",rep,".out")>;
+      file lossfile; // <single_file_mapper; file=@strcat("output/T",target_innov,".R",rep,".loss_data")>;
+
+      (outfile,lossfile) = multi_annealing(some_out_filename,
+		                           @tofloat(@arg("tstart", "2.0")),
+                                           @tofloat(@arg("tend", "0.01")),
+                                           @tofloat(@arg("trejection", "0.3")),
+                                           @toint(@arg("evoreruns", "100")),
+                                           @tofloat(@arg("startingjump", "2.3")),
+                                           [ @tofloat(@arg("alphai", "0.0")),
+                                             @tofloat(@arg("alpham", "0.0")),
+                                             @tofloat(@arg("beta", "4.0")),
+                                             @tofloat(@arg("gamma", "50.0")),
+                                             @tofloat(@arg("delta", "-1.0"))
+                                           ],
+                                           @tofloat(target_innov),
+                                           @toint(@arg("annealingcycles", "50")) );
     }
+  }
 }
 
 main()
 {
-    optimizer_sweep();
+  optimizer_sweep();
 }
 
 main();

Modified: SwiftApps/SciColSim/conf/local.cf
===================================================================
--- SwiftApps/SciColSim/conf/local.cf	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/conf/local.cf	2012-12-30 19:53:21 UTC (rev 6112)
@@ -4,6 +4,7 @@
 lazy.errors=true
 status.mode=provider
 use.provider.staging=false
+use.wrapper.staging=false
 provider.staging.pin.swiftfiles=false
 
 #app sumloss=$PWD/../sumloss.sh

Modified: SwiftApps/SciColSim/conf/local.xml
===================================================================
--- SwiftApps/SciColSim/conf/local.xml	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/conf/local.xml	2012-12-30 19:53:21 UTC (rev 6112)
@@ -1,7 +1,7 @@
 <config>
   <pool handle="local" >
     <execution provider="local" url="none" />
-    <profile namespace="karajan" key="jobThrottle">_JOB_THROTTLE_</profile>
+    <profile namespace="karajan" key="jobThrottle">.03</profile>
     <profile namespace="karajan" key="initialScore">10000</profile>
     <filesystem provider="local"/>
     <workdirectory>_WORK_/local</workdirectory>

Added: SwiftApps/SciColSim/evolve-wrapper.sh
===================================================================
--- SwiftApps/SciColSim/evolve-wrapper.sh	                        (rev 0)
+++ SwiftApps/SciColSim/evolve-wrapper.sh	2012-12-30 19:53:21 UTC (rev 6112)
@@ -0,0 +1,42 @@
+#!/bin/bash -x
+
+crash()
+{
+    MSG=$1
+    echo ${MSG}  >&2
+    exit 1
+}
+
+launchDirectory=$PWD
+echo Viewing first input
+echo Arguments are $@
+
+# Verify WN_TMP is defined
+if [ -z "$OSG_WN_TMP" ]; then
+   crash "OSG_WN_TMP is undefined"
+fi
+
+# Verify engage subdirectory of OSG_WN_TMP
+mkdir -p $OSG_WN_TMP/engage
+if [ ! -d "$OSG_WN_TMP/engage" ]; then
+   crash "OSG_WN_TMP/engage does not exist"
+fi
+
+tmpDirectory=`mktemp -d $OSG_WN_TMP/engage/SciColSim.XXXXXX`
+cd $tmpDirectory
+
+# Retrieve software
+wget http://www.ci.uchicago.edu/~davidk/SciColSim/evolve.sh 
+chmod +x evolve.sh
+wget http://www.ci.uchicago.edu/~davidk/SciColSim/openmp-optimizer 
+chmod +x openmp-optimizer
+wget http://www.ci.uchicago.edu/~davidk/SciColSim/movie_graph.txt
+
+# Run evolve
+mkdir -p $( dirname $1)
+./evolve.sh "$@"
+cp $1 $launchDirectory/$( dirname $1 )
+
+# Finish
+cd $launchDirectory
+rm -rf $tmpDirectory

Modified: SwiftApps/SciColSim/gengraphs.sh
===================================================================
--- SwiftApps/SciColSim/gengraphs.sh	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/gengraphs.sh	2012-12-30 19:53:21 UTC (rev 6112)
@@ -2,21 +2,8 @@
 
 mkdir -p graph
 
-# for s in $(seq 1000 1000 10000); do
-for s in 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000; do
-  ./trimgraph.sh $s 1.0 > graph/$s.100
-  ./trimgraph.sh $s 0.1 > graph/$s.10
-  ./trimgraph.sh  $s 0.5 > graph/$s.50
+for p in .001 .002 .003 .004 .005 .006 .007 .008 .009 .010; do
+  for ((i=0;i<10;i++)); do
+    ./samplegraph.sh $p > g/bg${p}.${i}
+  done
 done
-
-# Runtime, ram, science results (single floating pointer number called loss) for each param
-# Params = nodes, edges, and ti
-# As edges/nodes increase, time increases
-# 1000 osg jobs between 10 seconds and 24 hours
-# Example: iterate over ti in units of 100, graph sizes should be 
-# Automate, return eof when timed out, set max run time
-# Ability to see gprof output
-# Once with control structure he needs, then one run with large size to show hockey stick
-# Generate a table, then generate a graph
-# Email uc3 and midway account information
-

Modified: SwiftApps/SciColSim/optimizer.cpp
===================================================================
--- SwiftApps/SciColSim/optimizer.cpp	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/optimizer.cpp	2012-12-30 19:53:21 UTC (rev 6112)
@@ -11,7 +11,7 @@
 #define MAXNworkers 24
 int Nworkers=MAXNworkers;
 
-#define NUniverse 240
+#define NUniverse 24
 
 // Add operation code to enable existing code to be used at lower level from Swift scripts:
 
@@ -71,8 +71,6 @@
 
 #define FIX_VARIABLES 1
 
-#define MAX_LOSS 160
-
 using namespace boost;
 using namespace std;
 using namespace boost::numeric::ublas;
@@ -98,6 +96,7 @@
 typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
 typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
 
+double max_loss = -1.0; // intialized to "unset"; set by first Universe constructor to run.
 
 //================================================
 string strDouble(double number)
@@ -262,8 +261,8 @@
 
 	int current_epoch;
 	double current_loss;
-	int current_repeat;
-    double current_novelty;
+  int current_repeat;
+  double current_novelty;
 
 	int mode_identify_failed;
     int verbose_level; // 0 is silent, higher is more
@@ -300,7 +299,22 @@
 
         base_generator_type gene(42u);
         generator = gene;
-        generator.seed(static_cast<unsigned int>(std::time(0)));
+//        generator.seed(static_cast<unsigned int>(std::time(0)));
+
+
+    if ( initSeed != 0.0 ) {
+        generator.seed(static_cast<unsigned int>(initSeed));
+      }
+    else {
+        timeval t;
+        gettimeofday(&t, NULL);
+        generator.seed(static_cast<unsigned int>(t.tv_usec));
+      }
+
+
+
+
+
         boost::uniform_real<> uni_d(0,1);
         uni_dist = uni_d;
 
@@ -490,8 +504,7 @@
 				}
 			}
 		}
-
-
+		if(max_loss <= 0.0) set_max_loss(N_nodes, M_edges, TargetNovelty);
     }
 
 
@@ -992,6 +1005,7 @@
     void evolve_to_target_and_save(int istart, int iend, double* storage, int* counters){
 
         double ALOT=100000000000.;
+
         double ratio = 0.0;
         int check = 0;
 
@@ -1001,82 +1015,25 @@
 
             for(int i=0; i< N_epochs &&  current_novelty < TargetNovelty; i++){
 
-                if(ratio < max_loss_value((int)TargetNovelty)){
+                if(ratio < max_loss){
                     update_world();
                 }
                 else{
-                    check = 1;
+		  cout << "k=" << k << " i=" << i << " ratio=" << ratio << " max_loss=" << max_loss << endl;
                     break;
                 }
                 ratio = current_loss/current_novelty;
             }
-            if( check ){
-                storage[k]=ALOT;
-            }
-            else{
+            if( ratio < max_loss )
                 storage[k]=current_loss/current_novelty;
-            }
+            else
+                storage[k]=ALOT;
             counters[k]=1;
-
             reset_world();
         }
-
     }
 
     //==============================================
-    double Omax_loss_value(int tn){
-
-        if( tn == 58 )           return 128.286;
-        else if( tn == 108 )     return 131.866;
-        else if( tn == 158 )     return 135.551;
-        else if( tn == 208 )     return 139.694;
-        else if( tn == 258 )     return 144.163;
-        else if( tn == 308 )     return 148.967;
-        else if( tn == 358 )     return 154.201;
-        else if( tn == 408 )     return 159.962;
-        else if( tn == 458 )     return 166.441;
-        else if( tn == 508 )     return 173.655;
-        else if( tn == 558 )     return 181.921;
-        else if( tn == 608 )     return 191.246;
-        else if( tn == 658 )     return 202.150;
-        else if( tn == 708 )     return 215.197;
-        else if( tn == 758 )     return 202.150;  // Verify with Andrey. Same as TargetNovelty of 658
-        else if( tn == 808 )     return 251.698;
-        else if( tn == 858 )     return 279.201;
-        else if( tn == 908 )     return 320.112;
-        else if( tn == 958 )     return 394.774;
-        else if( tn == 1008 )    return 1052.38;  // Huge number here. Why?
-        else                      return 10000.;   /* Pray that this does not occur. Ask Andrey what to do */
-    }
-    double max_loss_value(int tn){
-
-      switch(tn) {
-        case 58:      return 128.286;
-        case 108:     return 131.866;
-        case 158:     return 135.551;
-        case 208:     return 139.694;
-        case 258:     return 144.163;
-        case 308:     return 148.967;
-        case 358:     return 154.201;
-        case 408:     return 159.962;
-        case 458:     return 166.441;
-        case 508:     return 173.655;
-        case 558:     return 181.921;
-        case 608:     return 191.246;
-        case 658:     return 202.150;
-        case 708:     return 215.197;
-        case 758:     return 202.150;  // Verify with Andrey. Same as TargetNovelty of 658
-        case 808:     return 251.698;
-        case 858:     return 279.201;
-        case 908:     return 320.112;
-        case 958:     return 394.774;
-        case 1008:    return 1052.38;  // Huge number here. Why?
-        default:      return 10000.;   /* Pray that this does not occur. Ask Andrey what to do */
-      }
-    }
-
-
-    //==============================================
     int get_reruns(void){
         return N_repeats;
     }
@@ -1185,140 +1142,53 @@
         return 0;
     }
 
-#ifdef notdef
-    //=================================================================
-    void try_annealing(double starting_jump, int iterations,
-                       double temp_start, double temp_end, double target_rejection){
+//--------
 
-        double dx[5]={0.,0.,0.,0.,0};
-        double x[5]={0.,0.,0.,0.,0};
-        double rejection[5]={0., 0., 0., 0., 0.};
-        double curr_x, curr_err, x_tmp;
-        double temperature;
-        double ratio, r;
-        int cycle=10;
-        boost::variate_generator<base_generator_type&, boost::uniform_real<> > uni(generator, uni_dist);
+void set_max_loss(long long v, long long e, long long t) {
 
-        // set up parameter for annealing
+  cout << "set_max_loss v=" << v << " e=" << e << " t=" << t << " max_loss=" << max_loss << endl;
 
-        x[0]=alpha_i;
-        x[1]=alpha_m;
-        x[2]=beta;
-        x[3]=gamma;
-        x[4]=delta;
+  // Based on formulas from random_analytical.pdf
 
-        for(int i=0;i<5;i++){
-            dx[i] = starting_jump;
-        }
+  double sum, ERLt, VarRLt;
 
-        // establish the current value
+  // (9): E[RLt] = (1/t) * SUM(i=0 to T of: (V*(V-1) / (2 * (E-i))
 
-        //..........................................
-        evolve_to_target();
-        std::cout << CumulativeRelativeLoss << " +- " << CRLsquare << std::endl;
+  sum = 0;
+  for(int i=0;i<t;i++) {
+    sum += ((double)(v*(v-1))) / ((double)(2*(e-i)));
+  }
+  ERLt = (1.0/(double) t) * sum;
 
-        curr_x   = CumulativeRelativeLoss;
-        curr_err = CRLsquare;
-        CumulativeRelativeLoss = 0;
-        CRLsquare = 0;
-        //...........................................
+  // (12): Var[RLt] = 1 / (T**2) * SUM( i=0 to T of: ((V*(V-1))/2) - E + 1 ) / ((E-i)**2)
 
-        // optimization cycle
-        for(int i=0; i<iterations; i++){
-
-            temperature = temp_start*exp( i*(log(temp_end)-log(temp_start))/(double)iterations);
-            std::cout  << std::endl << "....T = " << wrap_double(temperature,3) << std::endl << std::endl;
-
-            if (i % cycle == 0 && i > 0){
-
-                for (int k=0; k<5; k++){
-
-                    rejection[k]/=(double)cycle;
-                    if (rejection[k] > 0){
-                        dx[k] = dx[k]/(rejection[k]/target_rejection);
-                        rejection[k]=0.;
-                    }
-                    else{
-                        dx[k]*=2.;
-                    }
-                    std::cout  << dx[k] << " ";
-                }
-                std::cout  << std::endl;
-            }
-
-
-            for (int j=0; j<5; j++){
-
-                // get new value of x[j]
-                x_tmp = get_new_x(x[j],dx[j]);
-
-
-
-                //.............................................
-                set_parameter(x_tmp, j);
-
-
-                evolve_to_target();
-
-                std::cout  << std::endl << "......... " << std::endl;
-                std::cout << "Trying... " << CumulativeRelativeLoss << " +- " << CRLsquare << std::endl;
-
-                ratio = min(1.,exp(-(CumulativeRelativeLoss-curr_x)/temperature));
-                r = uni();
-                std::cout << r << " vs " << ratio << std::endl;
-
-                if (r > ratio){
-
-                    std::cout << string_wrap(id, 4) <<" "<< (i+1) << ","<< (j)
-                    <<" "<< (i+1) << " Did not accept "
-                    << x_tmp << "(" << j << ")" << std::endl;
-                    std::cout << alpha_i << " "<< alpha_m << " "
-                    << beta << " " << gamma << " "
-                    << delta << " " << std::endl;
-                    set_parameter(x[j], j);
-                    CumulativeRelativeLoss = 0;
-                    CRLsquare = 0;
-
-                    rejection[j]+=1.;
-                }
-
-                else {
-
-                    curr_x   = CumulativeRelativeLoss;
-                    curr_err = CRLsquare;
-                    x[j] = x_tmp;
-                    CumulativeRelativeLoss = 0;
-                    CRLsquare = 0;
-                    std::cout << (i+1) << string_wrap((string) " Rejection counts: ", 8)
-                    << wrap_double(rejection[0],2)
-                    << " "<< wrap_double(rejection[1], 7) << " "
-                    << wrap_double(rejection[2],5) << " " << wrap_double(rejection[2],9) << " "
-                    << wrap_double(rejection[4],6) << " "
-                    << std::endl << std::endl;
-
-                    std::cout << string_wrap(id, 4) <<" "<< (i+1) <<","<< (j)
-                    <<" "
-                    << string_wrap((string) "***** Did accept! ", 3)
-                    << wrap_double(alpha_i,2)
-                    << " "<< wrap_double(alpha_m, 7) << " "
-                    << wrap_double(beta,5) << " "
-                    << wrap_double(gamma,9) << " "
-                    << wrap_double(delta,6) << " "
-                    << std::endl << std::endl;
-
-                }
-                //........................................................
-
-            }
-
-        }
-
+  sum = 0;
+  for(int i=0;i<t;i++) {
+    sum +=  
+      ( (((double)(v*(v-1)))/ 2.0) - (double)e + (double)i )
+      /  
+      (double)((e-i)*(e-i))
+      ;
+    if ( (double)((e-i)*(e-i)) == 0.0 ) {
+      printf( "set_max_loss: while doing variance: zero denom: %d %d\n", e, i);
+      exit(1);
     }
+  }
+  int tmp = t*t;
+  VarRLt = (1.0/(double)((t) * t)) * sum;
+  if (VarRLt < 0.0) {
+    printf( "set_max_loss: while doing variance: VarRLT %d < 0\n", VarRLt);
+    exit(1);
+  }
 
-#endif
+  // (9) + 3sigma = E[RLt] + 3 * SQRT(Var)
 
-};
+  max_loss = ERLt + (3.0 * sqrt(VarRLt));
+  printf("set_max_loss: %12d %12.3f %12.8e %12.3f\n", t, ERLt, VarRLt, max_loss);
+}
 
+}; // End of class Universe
+
 //============================================================
 
 #ifdef P_DISPATCH
@@ -1385,14 +1255,30 @@
      }
 #endif
 
+/*
     for (int i=0; i<N; i++){
         Loss+=Results[i]/(double)N;
         LossSquare+=Results[i]*Results[i]/(double)N;
     }
 
     double two_std = ((LossSquare - Loss*Loss)/(double)N);
+    double two_std_dev = 2.*sqrt(two_std);
+*/
 
-    two_std = 2.*sqrt(two_std);
+    double sumsqdel;
+    Loss = 0.0, sumsqdel = 0.0;
+    for (int i=0; i<N; i++) {
+      Loss+=Results[i];
+    }
+    Loss /= (double)N;
+    for (int i=0; i<N; i++) {
+      double delta = Results[i] - Loss;
+      sumsqdel += delta*delta;
+    }
+    double variance = sumsqdel / double(N);
+    double two_std = 2.0 * sqrt(variance);
+
+    cout << "multi_loss: Loss=" << Loss << " sumsqdel=" << sumsqdel << " variance=" << variance << " two_std=" << two_std << endl;
     std::pair<double,double> Res;
     Res.first=Loss;
     Res.second=two_std;

Modified: SwiftApps/SciColSim/sumloss.sh
===================================================================
--- SwiftApps/SciColSim/sumloss.sh	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/sumloss.sh	2012-12-30 19:53:21 UTC (rev 6112)
@@ -34,6 +34,7 @@
 
   x = (loss_sq - (loss*loss))/n
   y = (tavg_sq - ( tavg*tavg))/tn
+  if(x<0.0) x=0.0;
   sdev = 2.0 * sqrt(x)
   tsdev = 2.0 * sqrt(y)
 

Modified: SwiftApps/SciColSim/swiftopt.sh
===================================================================
--- SwiftApps/SciColSim/swiftopt.sh	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/swiftopt.sh	2012-12-30 19:53:21 UTC (rev 6112)
@@ -11,7 +11,7 @@
 
 # Function to run Swift
 runswift() {
-   SWIFT_HEAP_MAX=$ram SWIFT_LIB=.. $swift >> swift.out 2>&1 -tc.file tc.data -sites.file $1 -config cf annealing.swift -e33="$escapecode" \
+   SWIFT_HEAP_MAX=$ram SWIFT_LIB=.. swift >> swift.out 2>&1 -tc.file tc.data -sites.file $1 -config cf annealing.swift -e33="$escapecode" \
                                             \
    -minrange=$min_target_innovation         \
    -maxrange=$max_target_innovation         \
@@ -78,7 +78,7 @@
 cp params/$paramfile $rundir/paramfile
 sed -e '/^[[:space:]]*\(#.*\)*$/d' -e 's/#.*//' -e 's/  */=/' -e 's/^/export /' <params/$paramfile >$rundir/params.annealing
 source $rundir/params.annealing
-swift=../swift/bin/swift # relative to runNNN/ dirs
+#swift=../swift/bin/swift # relative to runNNN/ dirs
 echo Optimization $rundir: site=$execsite paramfile=$paramfile
 
 # Report an error if configuration files are missing
@@ -129,13 +129,14 @@
 # Run gensites
 if [ ! "$USE_SCS" == 1 ]; then
    cp ../conf/$execsite.cf cf
-   SWIFT_HOME=../swift/bin ../swift/bin/gensites -p ../conf/$execsite.cf ../conf/$execsite.xml > $execsite.xml
+   # SWIFT_HOME=../swift/bin ../swift/bin/gensites -p ../conf/$execsite.cf ../conf/$execsite.xml > $execsite.xml
+   gensites -p ../conf/$execsite.cf ../conf/$execsite.xml > $execsite.xml
 fi
 
 echo "Run dir=$rundir" >> ABOUT
 echo "Work dir=$WORK" >> ABOUT
 echo "Total jobs=$total_jobs" >> ABOUT
-echo "Run Command: SWIFT_HEAP_MAX=$ram SWIFT_LIB=.. $swift >> swift.out 2>&1 -tc.file tc.data -sites.file $execsite.xml -config cf annealing.swift -minrange=$min_target_innovation -maxrange=$max_target_innovation-rangeinc=$target_innovation_increment -nreps=$annealing_repeats -annealingcycles=$annealing_cycles -evoreruns=$evolve_reruns -alphai=$alpha_i -alpham=$alpha_m -beta=$beta -gamma=$gamma -delta=$delta -nworkers=$nworkers -rerunsperapp=$reruns_per_opt_invocation -e33="$escapecode"" >> ABOUT
+echo "Run Command: SWIFT_HEAP_MAX=$ram SWIFT_LIB=.. swift >> swift.out 2>&1 -tc.file tc.data -sites.file $execsite.xml -config cf annealing.swift -minrange=$min_target_innovation -maxrange=$max_target_innovation-rangeinc=$target_innovation_increment -nreps=$annealing_repeats -annealingcycles=$annealing_cycles -evoreruns=$evolve_reruns -alphai=$alpha_i -alpham=$alpha_m -beta=$beta -gamma=$gamma -delta=$delta -nworkers=$nworkers -rerunsperapp=$reruns_per_opt_invocation -e33="$escapecode"" >> ABOUT
 
 if [ _$dryrun != _ ]; then
   exit 0

Modified: SwiftApps/SciColSim/testopt.py
===================================================================
--- SwiftApps/SciColSim/testopt.py	2012-12-29 00:38:49 UTC (rev 6111)
+++ SwiftApps/SciColSim/testopt.py	2012-12-30 19:53:21 UTC (rev 6112)
@@ -11,8 +11,7 @@
 
 #paramset="default"
 paramset="mw2"
-#paramset="VERYFASTTEST"
-#paramset="VERYFASTTEST"
+verboseLevel = "1"
 
 print("Running with parameter set " + paramset + "\n\n");
 
@@ -112,21 +111,25 @@
   openmp           = "OMP_NUM_THREADS=" + NWorkers
   operation        = "n"  # n=normal, m=manual (runs 1 multi_loss call)
   seed             = "1234567"
-  app              = "./openmp-optimizer";
+  app              = "./openmp-optimizer"
 
 elif paramset == "mw2":  # Timing TEST PARAMETERS by Mike
   
   startTarget      = 58
-  endTarget        = 209
+  endTarget        = 59
   incrTarget       = 50
   optimizerRepeats = 1
   evolveReruns     = 240
+  evolveReruns     = 8
   annealingSteps   = 1
-  NWorkers         = "8"
+  NWorkers         = "1"
   openmp           = "OMP_NUM_THREADS=" + NWorkers
+  openmp           = ""
+
   operation        = "m"  # n=normal, m=manual (runs 1 multi_loss call)
   seed             = "123456"
-  app              = "./openmp-optimizer";
+  app              = "./openmp-optimizer"
+  verboseLevel     = "1"
 
 # Ensure we dont pass new parameters to original optimizer versions
 # (but they would be ignored)
@@ -142,7 +145,7 @@
   for i in range(optimizerRepeats):
     args = "rm -f bestdb.txt; " + \
            openmp + " " + app + " 0 0 0 0 0 " + str(target) + " 40000 20 " + str(evolveReruns) + \
-           " 2 1 2. 0.01 " + str(annealingSteps) + " 0.3 2.3 0 0 0 0 0 " + operation + " " + NWorkers + " " + seed + \
+           " 2 " + verboseLevel + " 2. 0.01 " + str(annealingSteps) + " 0.3 2.3 0 0 0 0 0 " + operation + " " + NWorkers + " " + seed + \
            " >& out.T"+str(target)+".i"+str(i) + "; #mv bestdb.txt best.T" + str(target) + ".i" + str(i) 
     print("\n**** Calling optimizer: "+args+"\n")
     os.system(args);




More information about the Swift-commit mailing list