[Swift-commit] r7761 - in SwiftApps/SimulatedAnnealing: . params

wilde at ci.uchicago.edu wilde at ci.uchicago.edu
Sun Apr 6 17:47:27 CDT 2014


Author: wilde
Date: 2014-04-06 17:47:26 -0500 (Sun, 06 Apr 2014)
New Revision: 7761

Added:
   SwiftApps/SimulatedAnnealing/README
   SwiftApps/SimulatedAnnealing/annealing.swift
   SwiftApps/SimulatedAnnealing/colortext.swift
   SwiftApps/SimulatedAnnealing/math.swift
   SwiftApps/SimulatedAnnealing/params/
   SwiftApps/SimulatedAnnealing/params/ARFull
   SwiftApps/SimulatedAnnealing/params/ARtest01
   SwiftApps/SimulatedAnnealing/params/ARtest02
   SwiftApps/SimulatedAnnealing/params/ARtest03
   SwiftApps/SimulatedAnnealing/params/ARtest04
   SwiftApps/SimulatedAnnealing/params/ARtest05
   SwiftApps/SimulatedAnnealing/params/ARtest06
   SwiftApps/SimulatedAnnealing/params/BetaTest
   SwiftApps/SimulatedAnnealing/params/Fast01
   SwiftApps/SimulatedAnnealing/params/KMtest01
   SwiftApps/SimulatedAnnealing/params/MWtest01
   SwiftApps/SimulatedAnnealing/params/MWtest02
   SwiftApps/SimulatedAnnealing/params/MWtest03
   SwiftApps/SimulatedAnnealing/params/MWtest04
   SwiftApps/SimulatedAnnealing/params/MWtest05
   SwiftApps/SimulatedAnnealing/params/MWtest06
   SwiftApps/SimulatedAnnealing/params/MWtest07
   SwiftApps/SimulatedAnnealing/swiftopt.sh
Log:
Initial revision. Started recoding SciCol to generalize as an example annealing function.

Added: SwiftApps/SimulatedAnnealing/README
===================================================================
--- SwiftApps/SimulatedAnnealing/README	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/README	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,338 @@
+
+*** Getting started
+
+
+To run shorter tests on single local hosts (Mac, Linux, Beagle
+Sandbox, Swift lab machines):
+
+  cd $HOME
+  svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftApps/SciColSim
+  cd SciColSim
+
+  ./setup.sh  # just do this once. Will install Boost and Swift, and compile the optimizer
+
+  ./swiftopt.sh -s local -p Fast01 &    # Tells you what run dir its in.  Note the "&" !!!
+
+  cd runNNN                             # cd to that run dir eg run007
+  tail -f swift.out                     # to view progress
+  tail -f best_some_opt_swift.txt       # to view optimization results
+
+  ./swiftopt.sh -s pads  -p params/ARtest01    # Etc.
+
+
+swiftopt.sh command line arguments:
+
+  -s site to run on: can be local, pads, beagle 
+
+  -p param set to use, from param/ dir
+
+  FIXME: specify the variants and how to speciy params.
+  
+  FIXME: Params for gensites can also be in the -p file I think.
+
+  FIXME: create a few more tet variations
+
+
+Contents of parameter file:
+
+#--------  params/Fast01
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         109    # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount 
+
+annealing_repeats             1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              10     # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 8      # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      1      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     2      # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0 
+  
+#-------
+
+You can add new param sets in the param dir (or anywhere): just copy an existing one and change the params.
+
+You can add new sites in the conf/ dir.  FIXME: for now, add gen.SITENAME files. Limited flexibility w/ tc
+
+
+*** QuickStart
+
+mkdir $HOME/SciColSim # scientific collaboration simulation application
+cd SciColSim
+svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftApps/SciColSim src
+cd src
+cp /home/wilde/AndreysOptimizer/src/
+
+wget http://sourceforge.net/projects/boost/files/boost/1.47.0/boost_1_47_0.tar.gz/download
+tar zxf boost_1_47_0.tar.gz
+
+make  # should make openmp-optimizer executable
+
+./testopt.py >& testopt.out
+
+# Needs Swift 0.93 in PATH
+
+./test-swift.sh >& test-swift.out
+
+*** OSG
+
+To run on OSG, run the following commands;
+voms-proxy-init -voms Engage -valid 72:00
+./start-osg <number of nodes to request>
+./swiftopt.sh -s grid -p Fast01 -w &
+
+This has only been tested with the Fast01 parameter set as of now. The "-w" 
+option sets file transfers to be handled by using wget. If you are using OSG
+with another site, you can use the -l option of swiftopt to separate short and 
+long runs based on the value of target_innovation. For example, you can use 
+Ranger for short runs, and OSG for long runs. Adjust conf/grid.cf app
+definitions for bash_short and bash_long according to your needs.
+
+*** Overview
+
+The code simulates the exploration of a chemical network by a research
+community.  The five major parameters determine the strategy of
+exploration, "target" is the number of new interactions discovered and
+"loss" is the number of experiments per one new positive finding.
+
+Terminology and application logic:
+
+  optimizer: the C++ based optimizer that performs simulated annealing
+             optimizetion of parameters to the evolve() function.
+
+  evolve(): the actual science code which does the "collaboration
+            simulation" desribed in Overview above.  Implemented as a
+            function within optimizer. Uses the boost graph lib.
+            Calculates "loss" - amount of effort expended in rerunning
+            scientific experiments.
+
+  multi_annealing(): the function within optimizer that does the 
+            simulated annealing optimization logic (multiple times)
+
+  multi_loss: performs a total of N independent repetitions of evolve()
+           on NWorker cores, in parallel. Each evolve() returns one loss
+           value, a scalar double. Returns average loss over all evolve()
+           simulations, and std dev.
+
+*** Files
+
+Code:
+
+testopt.py: top-most script to run the C++ optimizer (with no
+            swift). Based on a simpler Python script provided by
+            Andrey to run the C++ optimizer.
+
+test-orig.sh: original python script test script for optimizer,
+            provided by Andrey with some mods by Mike.
+
+optirun.swift: replaces top-level py script for the outermost loops
+            (temporarily deprecated: has not been maintained to match changes in optimizer)
+
+annealing.swift: the annealing logic of optimizer, moved to
+             swift. Calls optimizer(op=m) to run 1 multi_loss() of N
+             evolve() runs on NWorker cores. Implements a higher-level multi_loss
+             which spreads the N reruns of evolve() between M runs of optimizer(m)
+             each of which does R evolve runs. N = P*R.  Eg, n=2400, P=100, R=24, 
+             would use 100 nodes (invocations) of 24 cores each.
+
+
+tc specifies:
+
+   optimizer.sh (old) / evolve.sh (current)
+
+   sumloss.sh: calculates avg loss and its std dev
+     did this as a separate app because it was hard to do the sum()
+     logic in swift.  How best to do that?  Try recursion? fold()?
+   
+
+Data:
+
+  input:	movie_data.txt
+  
+  output: best_???  max?  itermiediate?   FIX
+
+
+*** How to build
+
+Copy and untar boost graph library to the current dir:
+Needs: boost_1_47_0.tar.gz
+Available for now from: CI: /home/wilde/AndreysOptimizer/src
+
+Should create dir "boost_1_47_0" in the current directory
+(svn checkout dir, which is:
+  https://svn.ci.uchicago.edu/svn/vdl2/SwiftApps/SciColSim
+)
+
+Then run "make" -> uses Makefile
+
+  on mac, makes:  openmp-optimizer (multi_loss() changed to use OpenMP),
+                  dispatch-optimizer (orig code logic, only slight corrections)
+
+  on linux, makes: openmp-optimizer
+
+
+*** How to Run
+
+* Non-swift tests (py calling C++ optimizer app):
+
+  cp testopt.py t1.py etc; then edit t1.py etc to set the params you want.
+
+An example of a modified parameter set for testing a fast optimization
+loop on communicado/local.xml is:
+
+> paramset="mw"
+71a73,86
+> elif paramset == "mw":  # FAST TEST PARAMETERS by Mike
+>   
+>   startTarget      = 58
+>   endTarget        = 59
+>   incrTarget       = 50
+>   optimizerRepeats = 1
+>   evolveReruns     = 100
+>   annealingSteps   = 5
+>   NWorkers         = "4"
+>   openmp           = "OMP_NUM_THREADS=" + NWorkers
+>   operation        = "n"  # n=normal, m=manual (runs 1 multi_loss call)
+>   seed             = "1234567"
+>   app              = "./openmp-optimizer";
+> 
+
+Sample output is in sample.testopt.py.output
+
+* Swift tests:
+
+   /test-swift.sh >&ts3.out &
+
+(currently, parameters are set in a few different places in annealing.swift)
+
+Sample output (w/ bugs remaining) is in sample.test-swift.output
+
+
+Optimizer output (both from C++ optimizer and Swift) generates text
+with escape sequences to display colored text. Some versions of more
+and less need special options set (eg in env var?) to display the
+colors correctly.
+
+
+*** C++ Command line args
+
+Usage: super_optimizer alpha_i alpha_m beta gamma delta target_innov [n_epochs n_steps n_reruns] [range] [verbose_level]
+         [T_start T_end Annealing_steps Target_rejection Starting_jump]
+         [FREEZE_alpha_i FREEZE_alpha_m FREEZE_beta FREEZE_gamma FREEZE_delta]
+
+*** Swift command line args and internal control vars
+    The command line options are:
+        -nworkers=<int>
+
+	-minrange=<int>
+	    Starting number for the target innovation value(Inclusive)
+
+	-maxrange=<int>
+	    Ending number for the target innovation value(exclusive)
+
+	-rangeinc=<int>
+	    How much to increment the target innovation value by
+
+	-tstart=<float>
+
+	-tend=<float>
+
+	-trejection=<float>
+
+	-evoreruns=<int>
+	   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
+
+	-alphai=<float>
+            parameter to the annealing process
+
+	-alpham=<float>
+            parameter to the annealing process
+
+	-beta=<float>
+            parameter to the annealing process
+
+	-gamma=<float>
+            parameter to the annealing process
+
+	-delta=<float>
+            parameter to the annealing process
+
+	-annealingcycles=<int>
+	    Number of times to run the annealing process for a given target innovation
+
+	-rerunsperapp=<int>
+	    Number of evolve reruns to do per app call
+
+	-nreps=<int>
+	    How many times to repeat the annealing process for a given target innovation
+
+
+*** C++ app flow logic ===
+
+for target in range(58, 1009 (used 209), 50):  // 20 values    Target Values
+  for i in range(15):                                          Optimization repeats (runs?)
+    #         P0:                 P1:               D:  P2:                   P3:
+    optimizer |0 0 4 50 -1 target | 40000 20 1000 2 | 1 | 2. 0.01 100 0.3 2.3 | 1 1 0 0 0
+
+    multi_annealing( un[NW], T_start, T_end, Target_rejection, Annealing_repeats, 
+                       starting_jump, Results, Counters, params0, Annealing_repeats);
+
+        Res = multi_loss(un, Results, Counters, x); // Initial
+        curr_x   = Res.first;
+        curr_err = Res.second;
+
+        for i = 0 to annealing_cycles - 1 (100 from .py script)
+          for j = 0 to 4 // 5X: 0..4 is fixed constant  - one iteration for each of 5 evolve() parameters
+            setParameters (for a round of parallel Annealing_repeats
+            Res = multi_loss(un, Results, Counters, Annealing_repeats);
+              In parallel: for 1 to AnnealingRepeats (1,000; 10,000 desired)
+                group repeats among NWorkers
+                  evolve()
+            setParameters  again here, conditionally? (check)
+
+TODO: Merge these two outlines into one:
+
+P  20 targets - py  (target loss)
+P    15 repeats - py
+S      1 initial multi_loss: 1000 to 10000 annealing_repeats
+S      100 Annealing_cycles (groups of 10? : cycle=10 ) (fast:50)
+S         5 repeats (fast: 1)
+P           multi_loss: 1000 to 10000 evolve re-runs
+S             evolve() (leaf) => 2 mins to 10 mins (is that time for one or for 1000?)
+
+# a) 20 targets (parallel)
+# b)   15 repeats (parallel) of optimizer (optimizer == multi_annealing):
+#        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  
+# f)            evolve()
+
+Plots
+=====
+
+In order to generate plots from the swift stdout/stderr file, do the following
+
+./extract4plots <swift.out>
+gnuplot plotit
+
+gnuplot must be installed and should be in PATH.
+
+Following plots will be generated:
+activeplot.png: number of active jobs over time
+cumulativeplot.png: Cumulative number of jobs completed
+cumulativeplot-openmp.png: Cumulative number of openmp threads completed
+scs.png: SciColSim T value evolution
+scs_loss.png: Scicolsim Loss 
+multiloss.png: Scicolsim loss with stddev
+
+

Added: SwiftApps/SimulatedAnnealing/annealing.swift
===================================================================
--- SwiftApps/SimulatedAnnealing/annealing.swift	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/annealing.swift	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,487 @@
+import "math";
+import "colortext";
+
+type file;
+
+type Res
+{
+    float loss;
+    float sdev;
+    float tavg;
+    float tsdev;
+}
+
+type Checkpoint
+{
+  int i;
+  int j;
+  float dx0, dx1, dx2, dx3, dx4;
+  float rej0, rej1, rej2, rej3, rej4;
+  float target_innov;
+  float loss;
+  float alpha_i;
+  float alpha_m;
+  float beta;
+  float gamma;
+  float delta;
+  float sdev;
+}
+
+global boolean restart = (@arg("restart","false") == "true");
+tracef("Restart flag is %b\n", restart);
+
+global int iterate_adjust = @toint(@arg("iterate_adjust","1")); // FIXME!!! : 1 for 0.93, 0 for 0.94
+
+global boolean FIX_VARIABLES = true;
+global int var_fixed[] = [0,0,0,0,0];
+global int Nworkers = @toint(@arg("nworkers","4"));
+global int rerunsPerApp= @toint(@arg("rerunsperapp", "100"));
+
+( float nx ) newx( float x, float dx )
+{
+  float r = (random());
+
+  if (r > 0.5) {
+    nx = x + (random())*dx; //Java already returns a float between [0-1]
+  }
+  else {
+    nx = x - (random())*dx;
+  }
+  // tracef("newx(%f,%f)=%f\n",x,dx,nx);
+}
+
+app  (/*file outfile,*/  file objout ) orig_objective ( string args[], file objdata )
+{
+  # evolve @objout  args /*stdout=@outfile*/;  // FIXME: objdata file is passed implicitly
+}
+
+/*
+function y = simple_objective(x)
+   y = (4 - 2.1*x(1)^2 + x(1)^4/3)*x(1)^2 + x(1)*x(2) + ...
+       (-4 + 4*x(2)^2)*x(2)^2;
+*/
+
+(float y) objective ( float x[], file objdata )
+{
+   float x0 = x[0];
+   float x1 = x[1];
+   float x0s = x0 * x0;
+   float x1s = x1 * x1;
+   y = (4.0 - 2.1*x0s + pow(x[0],4.0/3.0))*x0s + x0*x1 + (-4.0 + 4.0*x1s)*x1s;
+}
+
+app (file outfile, file logfile ) sumobjective( file loss[] )
+{
+  sumloss @filename(logfile) @filenames(loss) stdout=@filename(outfile);
+}
+
+/* Program structure:
+
+   main
+     optimizer_sweep() - do N complete annealing optimizations
+       multi_annealing()
+         N_objective()
+           objective()
+         sumobjective()
+*/
+
+(file bestfile, file maxfile) multi_annealing (string best_filename,  # app
+                                               float T_start,         # ann
+                                               float T_end,           # ann
+                                               float Target_rejection,# ann
+                                               int obj_runs,          # app
+                                               float starting_jump,   # ann
+                                               float params0[],       # app f(x)
+                                               int annealing_cycles)  # ann
+{
+  int cycle      = 10;     // const
+  int NEVOPARAMS = 5;      // const - 5 params: alpha_i, alpha_m, beta, gamma, delta
+
+  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[];
+
+  Res mlres[][];
+
+  file ckptFile <single_file_mapper; file=@strcat("ckpt.",target_innov)>;
+  Checkpoint ckpt;
+  int restartIndex;
+
+  if (restart) {
+    ckpt = readData(ckptFile);
+    restartIndex = ckpt.i;
+  }
+  else {
+    restartIndex = -1;
+    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;
+    }
+  }
+  
+  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 ) );
+
+    tracef( @strcat( "multi_annealing: AR: i=%i ....T = ", color( 3, "%f" ),"\n" ), i, temperature );
+
+    if ( i <  restartIndex ) { 
+      tracef( "skipping index %i - less than restart index %i\n", i, restartIndex );
+    }
+    else { if ( i == restartIndex ) { // reset variables from the restart file
+      dx[i] = [ckpt.dx0, ckpt.dx1, ckpt.dx2, ckpt.dx3, ckpt.dx4];
+      rejection[i] = [ckpt.rej0, ckpt.rej1, ckpt.rej2, ckpt.rej3, ckpt.rej4];
+      x[i][0] = ckpt.alpha_i;
+      x[i][1] = ckpt.alpha_m;
+      x[i][2] = ckpt.beta;
+      x[i][3] = ckpt.gamma;
+      x[i][4] = ckpt.delta;
+      curr_loss[((i+1)*NEVOPARAMS)-1] = ckpt.loss;
+      curr_sdev[((i+1)*NEVOPARAMS)-1] = ckpt.sdev;
+    }
+    else { // i > restartIndex: proceed as normal whether restarting or not
+
+      // 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];
+                      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]
+              }
+              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 );
+
+          # Call objective function here:
+
+#         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
+          mlres[i][j] = multi_loss( try_x, target_innov, evolve_reruns ); // do the N evolve()'s, N=evolve_reruns
+
+          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( best_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( best_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]);
+            }
+          }
+          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-iterate_adjust) );
+      }} // of if/else 
+    } until( iter_i == (annealing_cycles-iterate_adjust) );
+}
+
+/*
+(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) N_objective(float x[], int obj_runs)
+{
+  tracef("%q\n", x);
+  file rfile[];
+  //file ofile[]; // FIXME: to obtain timings and other stats
+
+  tracef( "N_objective: entered: obj_runs=%i x=%q\n", obj_runs, x );
+
+  int appCalls = @toint(@tofloat(obj_runs)/@tofloat(runsPerApp)); // FIXME: handle fractional issues and rounding etc.
+                                                                         // For now must divide evenly
+  tracef("N_objective appCalls=%i\n", appCalls);
+
+  foreach i in [1:appCalls] { // repeats of the objective() - 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
+                 @strcat(x[0]),  @strcat(x[1]), @strcat(x[2]), @strcat(x[3]), @strcat(x[4]),
+            //     n_epochs n_steps   n_runs                  range
+                  "40000",   "20",  @strcat(rerunsPerApp),     "2",
+            //    verbose_level
+                    "1",
+            //    operation-code:(m,a)  Nworkers           seed
+                  "m",                  @strcat(Nworkers), @arg("seed", "0" ) ];
+
+    file graph <"movie_graph.txt">;
+
+    (/*outfile,*/ rfile[i]) = objective(args, graph);
+    tracef("multi_loss: i=%i calling objective, args=%q\n", i, args);
+    // tracef("multi_objective: after objective: i=%i %k %k\n", i, outfile, rfile[i]);
+  }
+
+  string anneal_cycle;
+  if(ci==0) {
+    anneal_cycle="init";
+  }
+  else {
+    anneal_cycle=@strcat(ci-1);
+  }
+    
+  file sumfile<single_file_mapper; file=@strcat("sumloss/",anneal_cycle,".",cj,".sumloss")>;
+  file logfile<single_file_mapper; file=@strcat("sumloss/",anneal_cycle,".",cj,".sumlog")>;
+
+  (sumfile, logfile) = 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 other stats
+  // s = readStat(statsfile);          FIXME: to obtain timings and other stats
+}
+
+optimizer_serial_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"));
+
+  // FIXME: add provision for random priming and random param values when x[i] == -100 (see optimizer.cpp main())
+
+  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")>;
+
+#  foreach target_innov in [minrange:maxrange:rangeinc] {
+  iterate i {
+    int target_innov = minrange + (i*rangeinc);
+    foreach rep in [1:nreps] {
+
+      string best_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(best_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")) );
+    }
+  } until(target_innov >= (maxrange-rangeinc));
+}
+
+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"));
+
+  // FIXME: add provision for random priming and random param values when x[i] == -100 (see optimizer.cpp main())
+
+  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")>;
+
+  foreach target_innov in [minrange:maxrange:rangeinc] {
+    foreach rep in [1:nreps] {
+
+      string best_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(best_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();
+}
+
+main();
+
+/*
+
+  Program structure:
+
+  main
+  optimizer_sweep()
+  multi_annealing()
+  multi_loss()
+  evolve()
+  sumloss()
+
+  Example parameter sets:
+
+  for target in range(58,59,50):
+  for i in range(1):
+  args="./toptimizer 0 0 4 50 -1 "+target+" 40000 20 75    2 1 2. 0.01 2 0.3 2.3 1 1 1 0 0 m // > out.T"+str(target)+".i"+str(i)
+  os.system(args);
+
+  string fastargs1[] = [
+  "0", "0", "4", "50", "-1", @strcat(target),
+  "40000", "20", "1000", "2",
+  "1",
+  "2.", "0.01", "100", "0.3", "2.3",
+  "1", "1", "0", "0", "0"];
+  string fastargs2[] = [
+  "0", "0", "4", "50", "-1", @strcat(target),
+  "40000", "20", "1000", "2",
+  "1",
+  "2.", "0.01",  "5", "0.3", "2.3",
+  "1", "1", "0", "0", "0", "m"];
+  string fastargs3[] = [
+  "0", "0", "4", "50", "-1", @strcat(target),
+  "40000", "20", @strcat(repeats), "2",
+  "1",
+  "2.", "0.01",  "2", "0.3", "2.3",
+  "1", "1", "0", "0", "0", "m"];
+*/
+
+(string args[]) setargs()
+{
+    // string longargs[] = @strcat("0 0 4 50 -1 ",target," 40000 20 1000 2 1 2. 0.01 100 0.3 2.3 1 1 0 0 0 m");
+
+    //  [alpha_i alpha_m beta gamma delta target_innov
+    //  [n_epochs n_steps n_reruns] [range]
+    //  [verbose_level]
+    //  [T_start T_end Annealing_steps Target_rejection Starting_jump]
+    //  [FREEZE_alpha_i FREEZE_alpha_m FREEZE_beta FREEZE_gamma FREEZE_delta] [operation-code:(m,a) Nworkers]
+}
+
+////////////////// HOLD JUNK
+
+//                    tracef(@strcat("multi_annealing: AR: %i ", color(8,"Rejection counts: "),
+//                                   color( /* 2 */ 1," %f"), "\n\n"),
+//                                   i, rejection[i][j] ); // , rejection[i][1], rejection[i][2], rejection[i][3], rejection[i][4]);
+// FIXME: determine correct rejection[] values to avoid hanging:
+//                    tracef(@strcat("multi_annealing: AR: %i ", color(8,"Rejection counts: "),
+//                                   color( /* 2 */ 1," %f"), color(7," %f"), color(5," %f"), color(9," %f"), color(6," %f"), "\n\n"),
+//                                   rejection[i][0], rejection[i][1], rejection[i][2], rejection[i][3], rejection[i][4]);
+// END FIXME

Added: SwiftApps/SimulatedAnnealing/colortext.swift
===================================================================
--- SwiftApps/SimulatedAnnealing/colortext.swift	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/colortext.swift	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,90 @@
+global string e33; // = @sprintf("\\e") or  @arg("e33");
+
+if( @arg("e33","null") == "null" ) {
+  e33 = @sprintf("\\e");
+}
+else {
+  e33 = @arg("e33");
+}
+
+global string endEscape = "[0m";
+
+// Color codes used in Andrey's cpp optimizer:
+
+global int Black = 0;
+global int Blue = 1;
+global int BlackOnBlue = 2;
+global int Pink = 3;
+global int GoldOnBlue = 4;
+global int BlueOnGray = 5;
+global int Red = 6;
+global int Gold = 7;
+global int BlueOnGold = 8;
+global int Gray = 9;
+global int BlackOnGray = 10;
+
+# Black = 0;	   
+# Blue = 1;	   
+# BlackOnBlue = 2; 
+# Pink = 3;	   
+# GoldOnBlue = 4;  
+# BlueOnGray = 5;  
+# Red = 6;	   
+# Gold = 7;	   
+# BlueOnGold = 8;  
+# Gray = 9;	   
+# BlackOnGray = 10;
+
+global string colorCode[] = [
+ "[1;29m",      # Black = 0;	   
+ "[1;34m",	# Blue = 1;	   
+ "[1;44m",	# BlackOnBlue = 2; 
+ "[1;35m",	# Pink = 3;	   
+ "[1;33;44m",	# GoldOnBlue = 4;  
+ "[1;47;34m",	# BlueOnGray = 5;  
+ "[1;1;31m",	# Red = 6;	   
+ "[1;1;33m",	# Gold = 7;	   
+ "[1;1;43;34m",	# BlueOnGold = 8;  
+ "[1;1;37m",	# Gray = 9;	   
+ "[1;30;47m",	# BlackOnGray = 10;
+];
+
+(string s) color(int c, string ins)
+{
+  s = @strcat(e33,colorCode[c],ins,e33,endEscape);
+}
+
+(string s) ncolor(int c, string ins) // Can use this version if \\e handling is available in current Swift
+{
+  s = @sprintf(@strcat("\\e",colorCode[c],ins,"\\e",endEscape));  // sprintf applies \\e escape processing
+}
+
+(string s) OLDcolor(int c, string ins)
+{
+    switch(c){
+        case 0:
+            s = @strcat(e33,"[1;29m",ins,e33,"[0m");
+        case 1:
+            s = @strcat(e33,"[1;34m",ins,e33,"[0m");
+        case 2:
+            s = @strcat(e33,"[1;44m",ins,e33,"[0m");
+        case 3:
+            s = @strcat(e33,"[1;35m",ins,e33,"[0m");
+        case 4:
+            s = @strcat(e33,"[1;33;44m",ins,e33,"[0m");
+        case 5:
+            s = @strcat(e33,"[1;47;34m",ins,e33,"[0m");
+        case 6:
+            s = @strcat(e33,"[1;1;31m",ins,e33,"[0m");
+        case 7:
+            s = @strcat(e33,"[1;1;33m",ins,e33,"[0m");
+        case 8:
+            s = @strcat(e33,"[1;1;43;34m",ins,e33,"[0m");
+        case 9:
+            s = @strcat(e33,"[1;1;37m",ins,e33,"[0m");
+        case 10:
+            s = @strcat(e33,"[1;30;47m",ins,e33,"[0m");
+        default:
+            s = ins;
+    }
+}

Added: SwiftApps/SimulatedAnnealing/math.swift
===================================================================
--- SwiftApps/SimulatedAnnealing/math.swift	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/math.swift	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,76 @@
+
+(float result) sin(float x)
+{
+   result = @java("java.lang.Math", "sin", x);
+}
+
+(float result) exp(float x)
+{
+   result = @java("java.lang.Math", "exp", x);
+}
+
+(float result) jlog(float x)
+{
+   result = @java("java.lang.Math", "log", x);
+}
+
+(float result) log10(float x)
+{
+   result = @java("java.lang.Math", "log10", x);
+}
+
+(float result) ceil(float x)
+{
+   result = @java("java.lang.Math", "ceil", x);
+}
+
+(float result) floor (float x)
+{
+   result = @java("java.lang.Math", "floor", x);
+}
+
+(float result) min (float a, float b)
+{
+   //result = @java("java.lang.Math", "min", a, b);
+   if ( a < b ) {
+       result = a;
+   }
+   else {
+       result = b;
+   }
+   tracef("math/min: result=%f\n",result);
+}
+
+(float result) pow (float x, float y)
+{
+   result = @java("java.lang.Math", "pow", x, y);
+}
+
+(float result) random ()
+{
+  result = @java("java.lang.Math","random");
+}
+
+// Functions below are exprimental and do not work
+// FIXME: fix 0.93 problems casting ints as doubles internally.
+//  This breaks the @java interface for Swift ints.
+
+(string result) itos (int i)
+{
+  result = @java("java.lang.Integer","toString",i);
+}
+
+(string result) itos2 (int i)
+{
+  result = @java("java.lang.String","valueOf",i);
+}
+
+(string result) ctos (int i)
+{
+  result = @java("java.lang.Character","valueOf",i);
+}
+
+(string result) format (string f, int c)
+{
+  result = @java("java.lang.String", "format", f, c );
+}

Added: SwiftApps/SimulatedAnnealing/params/ARFull
===================================================================
--- SwiftApps/SimulatedAnnealing/params/ARFull	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/ARFull	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,18 @@
+
+min_target_innovation        58     # starting target innovation value to try
+max_target_innovation        1009    # stops before this target innovation value
+target_innovation_increment  50     # increment target innovation by this amount
+
+annealing_repeats            1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles             100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                10000   # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                     24      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation    240     # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                      0.0     # 5 evolve() parameters: must be decimal values !!!
+alpha_m                      0.0
+beta                         4.0
+gamma                        50.0
+delta                        -1.0
+

Added: SwiftApps/SimulatedAnnealing/params/ARtest01
===================================================================
--- SwiftApps/SimulatedAnnealing/params/ARtest01	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/ARtest01	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,18 @@
+
+min_target_innovation       = 58     # starting target innovation value to try
+max_target_innovation       = 209    # stops before this target innovation value
+target_innovation_increment = 50     # increment target innovation by this amount 
+
+annealing_repeats           = 15     # times to repeate the entire optimization process for each target_innovation
+annealing_cycles            = 100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns               = 1000   # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                    = 2      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation   = 100    # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                     = 0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                     = 0.0    # alpha_i and alpha_m are fixed for now
+beta                        = 4.0    # rest are varied by the optimization process
+gamma                       = 50.0
+delta                       = -1.0 
+ 

Added: SwiftApps/SimulatedAnnealing/params/ARtest02
===================================================================
--- SwiftApps/SimulatedAnnealing/params/ARtest02	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/ARtest02	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,18 @@
+
+min_target_innovation        58     # starting target innovation value to try
+max_target_innovation        59    # stops before this target innovation value
+target_innovation_increment  50     # increment target innovation by this amount 
+
+annealing_repeats            1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles             100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                10000   # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                     24      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation    48     # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                      0.0     # 5 evolve() parameters: must be decimal values !!!
+alpha_m                      0.0     # alpha_i and alpha_m are fixed for now
+beta                         4.0     # rest are varied by the optimization process
+gamma                        50.0
+delta                        -1.0 
+ 

Added: SwiftApps/SimulatedAnnealing/params/ARtest03
===================================================================
--- SwiftApps/SimulatedAnnealing/params/ARtest03	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/ARtest03	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,18 @@
+
+min_target_innovation        50    # starting target innovation value to try
+max_target_innovation        51    # stops before this target innovation value
+target_innovation_increment  135    # increment target innovation by this amount 
+
+annealing_repeats            1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles             25     # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                96     # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                     24     # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation    24     # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                      0.0     # 5 evolve() parameters: must be decimal values !!!
+alpha_m                      0.0     # alpha_i and alpha_m are fixed for now
+beta                         0.0     # rest are varied by the optimization process
+gamma                        0.0
+delta                        0.0 
+ 

Added: SwiftApps/SimulatedAnnealing/params/ARtest04
===================================================================
--- SwiftApps/SimulatedAnnealing/params/ARtest04	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/ARtest04	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,18 @@
+
+min_target_innovation        270     # starting target innovation value to try
+max_target_innovation        1357    # stops before this target innovation value
+target_innovation_increment  540     # increment target innovation by this amount 
+
+annealing_repeats            1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles             100      # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                10080    # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                     24     # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation    24     # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                      0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                      0.0    # alpha_i and alpha_m are fixed for now
+beta                         0.0    # rest are varied by the optimization process
+gamma                        0.0
+delta                        0.0 
+ 

Added: SwiftApps/SimulatedAnnealing/params/ARtest05
===================================================================
--- SwiftApps/SimulatedAnnealing/params/ARtest05	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/ARtest05	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,17 @@
+
+min_target_innovation        67     # starting target innovation value to try: 67 134 201 268 335 402 469 536 603 670
+max_target_innovation        672    # stops before this target innovation value
+target_innovation_increment  67     # increment target innovation by this amount 
+
+annealing_repeats            1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles             100      # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                5040   # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                     24     # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation    240    # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                      0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                      0.0    # alpha_i and alpha_m are fixed for now
+beta                         0.0    # rest are varied by the optimization process
+gamma                        0.0
+delta                        0.0 

Added: SwiftApps/SimulatedAnnealing/params/ARtest06
===================================================================
--- SwiftApps/SimulatedAnnealing/params/ARtest06	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/ARtest06	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,19 @@
+
+min_target_innovation        67     # starting target innovation value to try: 67 134 201 268 335 402 469 536 603 670
+max_target_innovation        672    # stops before this target innovation value
+target_innovation_increment  67     # increment target innovation by this amount 
+
+annealing_repeats            1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles             100      # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                5040   # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                     24     # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation    120    # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                      0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                      0.0    # alpha_i and alpha_m are fixed for now
+beta                         0.0    # rest are varied by the optimization process
+gamma                        0.0
+delta                        0.0 
+
+starting_jump                0.3

Added: SwiftApps/SimulatedAnnealing/params/BetaTest
===================================================================
--- SwiftApps/SimulatedAnnealing/params/BetaTest	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/BetaTest	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,20 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         59     # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount
+
+annealing_repeats             1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              100     # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 60      # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      1      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     2      # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+
+
+JOB_THROTTLE                      .26

Added: SwiftApps/SimulatedAnnealing/params/Fast01
===================================================================
--- SwiftApps/SimulatedAnnealing/params/Fast01	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/Fast01	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,20 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         59    # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount
+
+annealing_repeats             1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              10     # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 100      # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      24      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     48      # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+
+
+JOB_THROTTLE                      .05

Added: SwiftApps/SimulatedAnnealing/params/KMtest01
===================================================================
--- SwiftApps/SimulatedAnnealing/params/KMtest01	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/KMtest01	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,20 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         70    # stops before this target innovation value
+target_innovation_increment   1     # increment target innovation by this amount
+
+annealing_repeats             1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              100     # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 1000      # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      20      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     200      # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+
+
+JOB_THROTTLE                  9.99

Added: SwiftApps/SimulatedAnnealing/params/MWtest01
===================================================================
--- SwiftApps/SimulatedAnnealing/params/MWtest01	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/MWtest01	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,17 @@
+
+min_target_innovation       = 58
+max_target_innovation       = 1009
+target_innovation_increment = 50
+
+annealing_repeats           = 1
+annealing_cycles            = 100
+evolve_reruns               = 1000
+
+alpha_i                     = 0.0  # 5 parameters: must be decimal values !!!
+alpha_m                     = 0.0
+beta                        = 4.0
+gamma                       = 50.0
+delta                       = -1.0 
+ 
+nworkers                    = 2
+reruns_per_opt_invocation   = 100    # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!

Added: SwiftApps/SimulatedAnnealing/params/MWtest02
===================================================================
--- SwiftApps/SimulatedAnnealing/params/MWtest02	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/MWtest02	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,21 @@
+
+#   Test with one target_innovation and few evolve_reruns to verify numeric behavior
+
+min_target_innovation         67     # starting target innovation value to try
+max_target_innovation         68     # stops before this target innovation value
+target_innovation_increment   135    # increment target innovation by this amount 
+
+annealing_repeats             1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              20     # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 4     # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      1      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     4     # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          0.0    # rest are varied by the optimization process
+gamma                         0.0
+delta                         0.0 
+
+starting_jump                 0.3

Added: SwiftApps/SimulatedAnnealing/params/MWtest03
===================================================================
--- SwiftApps/SimulatedAnnealing/params/MWtest03	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/MWtest03	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,19 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         109    # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount
+
+annealing_repeats             3      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 16      # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      8       # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     16      # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+
+JOB_THROTTLE                  .10

Added: SwiftApps/SimulatedAnnealing/params/MWtest04
===================================================================
--- SwiftApps/SimulatedAnnealing/params/MWtest04	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/MWtest04	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,19 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         1009   # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount
+
+annealing_repeats             1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 160    # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      8      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     80     # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+
+JOB_THROTTLE                  3.99

Added: SwiftApps/SimulatedAnnealing/params/MWtest05
===================================================================
--- SwiftApps/SimulatedAnnealing/params/MWtest05	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/MWtest05	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,19 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         109    # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount
+
+annealing_repeats             3      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 48      # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      24      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     48      # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+
+JOB_THROTTLE                  .10

Added: SwiftApps/SimulatedAnnealing/params/MWtest06
===================================================================
--- SwiftApps/SimulatedAnnealing/params/MWtest06	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/MWtest06	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,18 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         1009   # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount
+
+annealing_repeats             2      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 960     # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      24      # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     240     # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+

Added: SwiftApps/SimulatedAnnealing/params/MWtest07
===================================================================
--- SwiftApps/SimulatedAnnealing/params/MWtest07	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/params/MWtest07	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,18 @@
+
+min_target_innovation         58     # starting target innovation value to try
+max_target_innovation         1009   # stops before this target innovation value
+target_innovation_increment   50     # increment target innovation by this amount
+
+annealing_repeats             1      # times to repeate the entire optimization process for each target_innovation
+annealing_cycles              100    # times to perform the simulated annealing loop for all non-fixed parameters
+
+evolve_reruns                 400     # times to perform evolve_to_target_and_save() (objective function - is batched)
+nworkers                      8       # number of parallel threads (cores) to use per invocation of C++ optimizer
+reruns_per_opt_invocation     40      # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+
+alpha_i                       0.0    # 5 evolve() parameters: must be decimal values !!!
+alpha_m                       0.0    # alpha_i and alpha_m are fixed for now
+beta                          4.0    # rest are varied by the optimization process
+gamma                         50.0
+delta                         -1.0
+

Added: SwiftApps/SimulatedAnnealing/swiftopt.sh
===================================================================
--- SwiftApps/SimulatedAnnealing/swiftopt.sh	                        (rev 0)
+++ SwiftApps/SimulatedAnnealing/swiftopt.sh	2014-04-06 22:47:26 UTC (rev 7761)
@@ -0,0 +1,191 @@
+#!/bin/bash
+
+# Usage: swiftopt.sh [-s sitename] [-p paramfile] [-w] [-n # for dryrun ]
+#
+# NOTE: this command expects symlink "swift" in the cur dir to point
+# to relese installed by setup.sh If you want to run with a different
+# swift release, replace symlink "swift" with a link to your swift
+# release dir.
+
+usage="$0 [-s sitename] [-p paramfile] [-n] [-w] [-l] # -n for dryrun: just print params and time estimates"
+
+# 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" \
+                                            \
+   -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                            \
+                                            \
+   -startingjump=$starting_jump             \
+                                            \
+   -nworkers=$nworkers                      \
+   -rerunsperapp=$reruns_per_opt_invocation \
+   -wget=$wget				    \
+   -longruns=$longruns                      \
+   -restart=$restart
+}
+
+
+# Default settings
+execsite=local
+paramfile=Fast01
+ram=6000M
+dryrun=
+escapecode=$(printf '\033')
+variable_params=5     # Currently CONSTANT, will want to have this vary
+wget=false
+longruns=false
+
+# Process command line arguments
+while [ $# -gt 0 ]; do
+  case $1 in
+    -l) longruns=true; shift 1;; # FIXME
+    -n) dryrun=true; shift 1;;
+    -p) paramfile=$2; shift 2;;
+    -s) execsite=$2; shift 2;;
+    -w) wget=true; shift 1;;     # FIXME
+    -r) resdir=$2; shift 2;;
+    *) echo $usage 1>&2
+       exit 1;;
+  esac
+done
+
+# Create next unique run id and run directory
+rundir=$( echo run??? | sed -e 's/^.*run//' | awk '{ printf("run%03d\n", $1+1)}' )
+
+#Exit if rundir already exits. Something is funky
+if [ -d $rundir ];
+then
+    echo "$rundir already exists! exiting." >&2
+    exit 2
+else
+    mkdir $rundir
+fi
+
+if [ _$resdir != _ ]; then
+  if [ -d resdir ]; then
+    restart=true
+    cp $resdir/ckpt.* $rundir
+  else
+    echo $0: no restart directory $resdir found.
+    exit 1
+  fi
+else
+  restart=false
+fi
+
+# Get optimization parameters
+if [ ! -f params/$paramfile ];
+then
+    echo "Could not find parameter file $paramfile in params!"
+    exit 1
+fi
+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
+echo Optimization $rundir: site=$execsite paramfile=$paramfile
+
+# Report an error if configuration files are missing
+if [ ! -f "conf/$execsite.xml" ] && [ ! -f "conf/$execsite.conf" ]; then
+   echo Unable to find requested configuration file for site $execsite
+   exit 1
+fi
+
+# Use start-coaster-service if site is a .conf file
+if [ -f "conf/$execsite.conf" ]; then
+   USE_SCS=1
+fi
+
+# Check for missing .cf files
+if [ -f "conf/$execsite.xml" ] && [ ! -f "conf/$execsite.cf" ]; then
+   echo Missing configuration file $execsite.cf
+fi
+
+cp movie_graph.txt $rundir
+cp annealing.swift $rundir
+cp colortext.swift $rundir
+cp math.swift $rundir
+
+# Echo parameters
+echo Annealing parameters:
+echo
+cat $rundir/params.annealing
+echo
+
+# Echo runtime estimates
+total_jobs=`python -c "from math import ceil; print int(ceil(($max_target_innovation.00 - $min_target_innovation.00)/$target_innovation_increment.00) * $annealing_repeats * $variable_params * $annealing_cycles * $evolve_reruns/$reruns_per_opt_invocation)"`
+echo Total jobs = $total_jobs
+
+cd $rundir
+
+# Do the run
+export WORK=$PWD/swiftwork
+mkdir -p $PWD/swiftwork/workers
+
+# Use start-coaster-service if the site uses a .conf file
+if [ "$USE_SCS" == "1" ]; then
+   cp ../conf/$execsite.conf coaster-service.conf
+   cp ../conf/$execsite.cf cf
+   sed -i -e "s at _RUNDIR_@$rundir@" coaster-service.conf
+   start-coaster-service
+fi
+
+# 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
+   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
+
+if [ _$dryrun != _ ]; then
+  exit 0
+fi
+
+if [ "$USE_SCS" == "1" ]; then
+   runswift "sites.xml"
+   stop-coaster-service
+else
+   runswift "$execsite.xml"
+fi
+
+# Run the convertbest.sh script on the generated txt files from within the rundir
+../bin/convertbest.sh *.txt
+
+exit
+
+# @arg("nworkers","4")
+# @arg("rerunsperapp", "100")
+# @arg("seed", "0" )          FIXME
+# @arg("minrange", "58")
+# @arg("maxrange", "59")
+# @arg("rangeinc", "50")
+# @arg("nreps", "1")
+# @arg("tstart", "2.0")       FIXME
+# @arg("tend", "0.01")        FIXME
+# @arg("trejection", "0.3")   FIXME
+# @arg("evoreruns", "100")
+# @arg("startingjump", "2.3")
+# @arg("alphai", "0.0")
+# @arg("alpham", "0.0")
+# @arg("beta", "4.0")
+# @arg("gamma", "50.0")
+# @arg("delta", "-1.0")
+# @arg("annealingcycles", "50")
+


Property changes on: SwiftApps/SimulatedAnnealing/swiftopt.sh
___________________________________________________________________
Added: svn:executable
   + *




More information about the Swift-commit mailing list