[Swift-commit] r6135 - in SwiftApps/SciColSim: . conf params
wilde at ci.uchicago.edu
wilde at ci.uchicago.edu
Sun Jan 6 22:24:07 CST 2013
Author: wilde
Date: 2013-01-06 22:24:06 -0600 (Sun, 06 Jan 2013)
New Revision: 6135
Added:
SwiftApps/SciColSim/genrec.sh
Modified:
SwiftApps/SciColSim/annealing.swift
SwiftApps/SciColSim/conf/local.xml
SwiftApps/SciColSim/params/MWtest02
SwiftApps/SciColSim/sumloss.sh
SwiftApps/SciColSim/swiftopt.sh
Log:
Add restart mechanism to annealing.swift and additional logging to sumloss (logs to runNNN/sumloss).
Modified: SwiftApps/SciColSim/annealing.swift
===================================================================
--- SwiftApps/SciColSim/annealing.swift 2013-01-06 07:54:35 UTC (rev 6134)
+++ SwiftApps/SciColSim/annealing.swift 2013-01-07 04:24:06 UTC (rev 6135)
@@ -15,6 +15,25 @@
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;
@@ -40,9 +59,9 @@
evolve @loss args /*stdout=@outfile*/; // FIXME: graph is passed implicitly
}
-app ( file x ) sumloss( file loss[] )
+app (file outfile, file logfile ) sumloss( file loss[] )
{
- sumloss @filenames(loss) stdout=@x;
+ sumloss @filename(logfile) @filenames(loss) stdout=@filename(outfile);
}
/*
@@ -57,7 +76,7 @@
sumloss()
*/
-(file bestfile, file maxfile) multi_annealing (string some_out_filename,
+(file bestfile, file maxfile) multi_annealing (string best_filename,
float T_start,
float T_end,
float Target_rejection,
@@ -77,18 +96,29 @@
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 );
+ file ckptFile <single_file_mapper; file=@strcat("ckpt.",target_innov)>;
+ Checkpoint ckpt;
+ int restartIndex;
- 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;
+ 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
@@ -97,130 +127,147 @@
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
-
- 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] );
+ if ( i < restartIndex ) {
+ tracef( "skipping index %i - less than restart index %i\n", i, restartIndex );
}
- 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 { 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;
}
- 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;
+ else { // i > restartIndex: proceed as normal whether restarting or not
- 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]
+ // 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 {
- 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)
- }
+ 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( @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()
+ 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 { // 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!
+ }
+ 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)
+ }
+ }
}
- else {
- rejection[i][j] = rejection[i-1][j] + 1.0; // FIXME: AR: Is this correct? incr rejection?
+ 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( 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()
}
- 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 { // 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 );
}
- else {
- rejection[i][j] = rejection[i-1][j]; // FIXME: AR: Is this correct? no incr of rejection?
+ 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] );
}
- 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 { // 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 {
- rj[k] = rejection[i-1][k]; // Not yet set, use previous
+ 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]);
+ }
}
- 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
}
- }
- 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) );
+ } until( j == (NEVOPARAMS-iterate_adjust) );
+ }} // of if/else
} until( iter_i == (annealing_cycles-iterate_adjust) );
}
@@ -260,7 +307,19 @@
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);
+
+ string anneal_cycle;
+ if(ci==0) {
+ anneal_cycle="init";
+ }
+ else {
+ anneal_cycle=@strcat(ci-1);
+ }
+
+ file sumfile<single_file_mapper; file=@strcat("sumloss/T",target_innov,".",anneal_cycle,".",cj,".sumloss")>;
+ file logfile<single_file_mapper; file=@strcat("sumloss/T",target_innov,".",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);
@@ -287,11 +346,11 @@
int target_innov = minrange + (i*rangeinc);
foreach rep in [1:nreps] {
- string some_out_filename = @strcat( "best.T", @strcat(target_innov), ".R", @strcat(rep), ".txt" );
+ 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(some_out_filename,
+ (outfile,lossfile) = multi_annealing(best_filename,
@tofloat(@arg("tstart", "2.0")),
@tofloat(@arg("tend", "0.01")),
@tofloat(@arg("trejection", "0.3")),
@@ -326,11 +385,11 @@
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" );
+ 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(some_out_filename,
+ (outfile,lossfile) = multi_annealing(best_filename,
@tofloat(@arg("tstart", "2.0")),
@tofloat(@arg("tend", "0.01")),
@tofloat(@arg("trejection", "0.3")),
Modified: SwiftApps/SciColSim/conf/local.xml
===================================================================
--- SwiftApps/SciColSim/conf/local.xml 2013-01-06 07:54:35 UTC (rev 6134)
+++ SwiftApps/SciColSim/conf/local.xml 2013-01-07 04:24:06 UTC (rev 6135)
@@ -1,7 +1,7 @@
<config>
<pool handle="local" >
<execution provider="local" url="none" />
- <profile namespace="karajan" key="jobThrottle">.03</profile>
+ <profile namespace="karajan" key="jobThrottle">.01</profile>
<profile namespace="karajan" key="initialScore">10000</profile>
<filesystem provider="local"/>
<workdirectory>_WORK_/local</workdirectory>
Added: SwiftApps/SciColSim/genrec.sh
===================================================================
--- SwiftApps/SciColSim/genrec.sh (rev 0)
+++ SwiftApps/SciColSim/genrec.sh 2013-01-07 04:24:06 UTC (rev 6135)
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+for f in $1/best.T*.R1.txt; do
+ ti=$(echo $f | sed -e 's/^.*T//' -e 's/\..*//')
+ (
+ echo "i j dx0 dx1 dx2 dx3 dx4 rej0 rej1 rej2 rej3 rej4 target_innov loss alpha_i alpha_m beta gamma delta sdev"
+ cycle=$(sed -e 's/\]//g' -e 's/[,|\[]//g' $f | awk '$4 == 4 {print $3}' | tail -1)
+ echo 1>&2 ti=$ti will restart at cycle $cycle
+ sed -e 's/\]//g' -e 's/[,|\[]//g' $f |
+ awk '
+ $3 == cycle { dx[$4] = $5; rej[$4] = $6 }
+
+ $3 == cycle && $4 == 4 {
+ print $3, $4,
+ dx[0], dx[1], dx[2], dx[3], dx[4],
+ rej[0], rej[1], rej[2], rej[3], rej[4],
+ $7, $8, $9, $10, $11, $12, $13, $14
+ }
+ ' cycle=$cycle |
+ tail -1
+ ) > ckpt.$ti
+ if [ $(wc -l <ckpt.$ti) != 2 ]; then
+ echo $0: WARNING: ckpt.$ti was not generated: input does not contain at least one complete annealing cycle.
+ rm -f ckpt.$ti
+ fi
+done
+
+# N AvgTime i j dx Rej TgtInno AvgLoss alpha_i alpha_m beta gamma delta LossSdev
Property changes on: SwiftApps/SciColSim/genrec.sh
___________________________________________________________________
Added: svn:executable
+ *
Modified: SwiftApps/SciColSim/params/MWtest02
===================================================================
--- SwiftApps/SciColSim/params/MWtest02 2013-01-06 07:54:35 UTC (rev 6134)
+++ SwiftApps/SciColSim/params/MWtest02 2013-01-07 04:24:06 UTC (rev 6135)
@@ -1,21 +1,21 @@
# Test with one target_innovation and few evolve_reruns to verify numeric behavior
-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
+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 100 # times to perform the simulated annealing loop for all non-fixed parameters
+annealing_cycles 20 # times to perform the simulated annealing loop for all non-fixed parameters
-evolve_reruns 20 # 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 20 # reruns_per_opt_invocation mod nworkers must == 0 !!! <=== NOTE WELL !!!
+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 4.0 # rest are varied by the optimization process
-gamma 50.0
-delta -1.0
-
-
\ No newline at end of file
+beta 0.0 # rest are varied by the optimization process
+gamma 0.0
+delta 0.0
+
+starting_jump 0.3
Modified: SwiftApps/SciColSim/sumloss.sh
===================================================================
--- SwiftApps/SciColSim/sumloss.sh 2013-01-06 07:54:35 UTC (rev 6134)
+++ SwiftApps/SciColSim/sumloss.sh 2013-01-07 04:24:06 UTC (rev 6135)
@@ -9,6 +9,12 @@
# tsdev = standard deviation of timing data
# process each file individually and treat each number as a field
+
+
+logfile=$1; shift
+
+outfile=$(mktemp sumloss.outfile.XXXXXX)
+
awk '
BEGIN { RS = ""; FS="\n"; loss = 0; loss_sq = 0; tavg = 0; tavg_sq = 0; n = 0; tn = 0; }
@@ -47,4 +53,27 @@
printf "loss sdev tavg tsdev\n" # header line must match Swift structure fields
printf "%f %f %f %f\n", avg_loss, serr_loss, avg_time, serr_time
-} ' $*
+
+ if ( sdev_loss >50000 ) {
+ printf("sumloss warning: high sdev_loss=%f\n", sdev_loss) > sdev_warning
+ }
+} ' $* 2>&1 | tee $outfile
+
+
+if [ _$logfile != _ -a _$logfile != "_none" ]; then
+( echo sumloss: $0 $*
+ if [ -f sdev_warning ]; then
+ cat sdve_warning
+ fi
+ echo
+ for f in $*; do
+ echo -e "\ninput file $f:\n"
+ cat $f
+ done
+ echo -e "\nsumloss output: \n"
+ cat $outfile
+
+) >$logfile
+fi
+
+rm -f $outfile
Modified: SwiftApps/SciColSim/swiftopt.sh
===================================================================
--- SwiftApps/SciColSim/swiftopt.sh 2013-01-06 07:54:35 UTC (rev 6134)
+++ SwiftApps/SciColSim/swiftopt.sh 2013-01-07 04:24:06 UTC (rev 6135)
@@ -32,14 +32,15 @@
-nworkers=$nworkers \
-rerunsperapp=$reruns_per_opt_invocation \
-wget=$wget \
- -longruns=$longruns
+ -longruns=$longruns \
+ -restart=$restart
}
# Default settings
execsite=local
paramfile=Fast01
-ram=2048M
+ram=6000M
dryrun=
escapecode=$(printf '\033')
variable_params=5 # Currently CONSTANT, will want to have this vary
@@ -49,11 +50,12 @@
# Process command line arguments
while [ $# -gt 0 ]; do
case $1 in
- -l) longruns=true; shift 1;;
+ -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;;
+ -w) wget=true; shift 1;; # FIXME
+ -r) resdir=$2; shift 2;;
*) echo $usage 1>&2
exit 1;;
esac
@@ -71,6 +73,18 @@
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
More information about the Swift-commit
mailing list