Add write_mod option to write population at regular time intervals (two-site/two...
authorDariusz Murakowski <murakdar@mit.edu>
Thu, 26 Sep 2013 22:38:00 +0000 (18:38 -0400)
committerDariusz Murakowski <murakdar@mit.edu>
Thu, 26 Sep 2013 22:38:00 +0000 (18:38 -0400)
wf.cpp
wf.h

diff --git a/wf.cpp b/wf.cpp
index 6294977..fa6e343 100644 (file)
--- a/wf.cpp
+++ b/wf.cpp
@@ -72,7 +72,10 @@ void run(RunParameters &r, unsigned seed) {
                 
                     //printf("%d\t%d\n",n,i);
                     P.next_generation(H, rnd, r.useRelative, r.useVerbose);
-                    P.write_two_site_population(popout,H,i+1);
+
+                    if ((i+1) % r.write_mod == 0) {
+                        P.write_two_site_population(popout,H,i+1);
+                    }
 
                     //if (r.runUntilEscape && P.escaped(H)) break;
 
@@ -255,6 +258,7 @@ void usage()
 "                     (note the sign convention on these is P ~ exp(-H),\n"
 "                      H = sum_i h_i s_i + sum_{i<j} J_{ij} s_i s_j\n"
 "                      although internal representation is opposite)\n"
+" -write_mod  (int)   write out state every 'write_mod' generations\n"
 ;   std::cout.flush();
 }
 
@@ -320,6 +324,8 @@ int main(int argc, char *argv[]) {
 
         else if (strcmp(argv[i],"-seed")==0) { if (++i==argc) break; else seed=(unsigned)strtodouble(argv[i]); }
 
+        else if (strcmp(argv[i],"-write_mod")==0) { if (++i==argc) break; else r.write_mod=(unsigned int)strtodouble(argv[i]); }
+
         else if (strcmp(argv[i],"-h")==0)   { usage(); return 0;    }
         
         else printf("Unrecognized command! '%s'\n",argv[i]);
diff --git a/wf.h b/wf.h
index ddb376e..eb9eb51 100644 (file)
--- a/wf.h
+++ b/wf.h
@@ -98,6 +98,8 @@ public:
     double h1;
     double h2;
     double J12;
+
+    unsigned int write_mod;     // Write state of the population every __ generations
     
     std::vector<std::set<unsigned int> > initPop;   // Initial population sequences
     std::vector<double>                  initFrac;  // Initial population fraction
@@ -137,6 +139,8 @@ public:
         h1  = 0.0;
         h2  = 0.0;
         J12 = 0.0;
+
+        write_mod = 1;
         
     }
     void setFiles() {