home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TIERRA40.ZIP / DOC / DIVERSE.DOC < prev    next >
Text File  |  1992-09-11  |  13KB  |  313 lines

  1. ====== DIVERSE DOCUMENTATION =================================================
  2.  
  3. Usage:  The diverse tool will prompt you for input parameters.
  4.         Start by typing "diverse" to the prompt.
  5.         To accept default values, hit Enter.
  6.  
  7. What Diverse Does:
  8.  
  9.      Diverse reads the files of birth and death records (break.X) that are
  10. written to disk by the Tierra simulator, and prepares new files that
  11. contain several indices of diversity.  These indices may be recomputed and
  12. output after each birth or death, or they may be averaged over an interval
  13. of your choice and output at the end of each interval (this keeps the volume
  14. of output down to reasonable levels).
  15.  
  16. Diverse reads the break.1 ... break.X files that are written to the \td
  17. directory, and outputs files whose default names are averages, divdat.X,
  18. divrange and brkrange.  The files divdat.X contain eight parameters
  19. related to diversity and turn over of size classes and genotypes in the soup.
  20.  
  21. The file divrange contains the ranges and averages of the eight variables for
  22. the entire run.  The file brkrange contains the ranges of the variables for
  23. each of the divdat.X files.  Diverse takes a long time to run, so it prints a
  24. statement after every million Tierran instructions processed, just to let you
  25. know it is still ticking.  Diverse does a lot of floating point calculations,
  26. so it will be very slow if it is run on any machine without a math
  27. co-processor.
  28.  
  29. To compile diverse on a Unix system: cc diverse.c -lm -o diverse
  30.  
  31. There are two basic dialog scenarios:
  32.  
  33. input file (default: break.1) = 
  34. threshold (default: 2) = 
  35. Frequency for Average Output (default: 1000000) = 
  36. output birth death records: y or n (default: n) = 
  37.  
  38. and:
  39.  
  40. input file (default: break.1) = 
  41. threshold (default: 2) = 
  42. Frequency for Average Output (default: 1000000) = 
  43. output birth death records: y or n (default: n) = y 
  44. output file (default: divdat.1) = 
  45. output format: binary or ascii (default: binary) = 
  46. break size (default: 4096) = 
  47.  
  48. In both scenarios, you must respond to the first four questions:
  49.  
  50. input file (default: break.1) = 
  51. threshold (default: 2) = 
  52. Frequency for Average Output (default: 1000000) = 
  53. output birth death records: y or n (default: n) = y 
  54.  
  55. If you choose to output diversity indices for each birth and death, then
  56. you must answer three more questions:
  57.  
  58. output file (default: divdat.1) = 
  59. output format: binary or ascii (default: binary) = 
  60. break size (default: 4096) = 
  61.  
  62. ====== DIVERSE ===============================================================
  63.  
  64.      The following is an explanation of each of the lines of the dialog:
  65.  
  66. input file (default: break.1) = 
  67.  
  68.      The name of the file containing the birth and death records, which
  69. will be read by the diverse program.  The default is break.1, which is
  70. the default name of the file output by the Tierra program.
  71.  
  72. threshold (default: 2) = 
  73.  
  74.      The threshold for including size or genotype classes in the calculations
  75. of the diversity indices.  The default is 2, which means that genotypes for
  76. which there is only a single individual (probably mostly inviable mutants)
  77. will not be included in the calculations.
  78.  
  79. Frequency for Average Output (default: 1000000) = 
  80.  
  81.      If this parameter is non-zero, averages for the diversity indices will
  82. be calculated over the interval indicated, and output only at then end of
  83. each interval.  The default is once every million instructions.
  84.  
  85. output birth death records: y or n (default: n) =
  86.  
  87.      This line asks if diversity indices should be output for each record of
  88. birth and death.  The default is no because this generates a huge volume
  89. of data.  The file produced by this option will be about four times the
  90. size of the break files used as input.
  91.  
  92. output file (default: divdat.1) = 
  93.  
  94.      If one chooses to output diversity indices for each birth and death
  95. record, this option allows you to specify the name of the output file(s).
  96. The default is divdat.1.
  97.  
  98. output format: binary or ascii (default: binary) = 
  99.  
  100.      There are two possible file formats for the file containing diversity
  101. indices for each birth and death record: binary and ascii.  The default is
  102. binary, because the binary format is more compact than the ascii format.  This
  103. is important because the even the binary output file (divdat.X) will be about
  104. four times as large as the input file (break.X).
  105.  
  106. break size (default: 4096) = 
  107.  
  108.      If diversity indices are output for each birth and death, they will be
  109. broken into a series of files, and this variable specifies the size of the
  110. files in K (1024 bytes).  The default size is 4 Mb.  If there is more than
  111. 4 Mb of output, the file will be broken into pieces.
  112.  
  113. ====== DIVERSE OUTPUT FORMATS ================================================
  114.  
  115. from divdat.1:
  116.  
  117. 11 0.0
  118. 0 1 1 0 0 1 0 0
  119. 33a 2 1 0 33a 1 0 33a
  120. 62c 3 1 0 966 1 0 966
  121. ac 4 1 0 a12 1 0 a12
  122. b6e 5 1 0 1580 1 0 1580
  123. 57 6 1 0 15d7 1 0 15d7
  124. ...
  125. 34f 341 32 1.98219 20795c 163 4.43486 72ed46
  126. 216 342 32 1.99079 207b72 164 4.44187 724167
  127. 70 343 32 1.98692 207be2 165 4.44885 72aa9b
  128. 2 342 32 1.99079 207be4 165 4.44592 72aa9d
  129. 21e 343 32 1.98692 207e02 165 4.43891 72acbb
  130. 2 342 32 1.98663 207e04 165 4.445 72acbd
  131. 41e 341 32 1.99052 208222 164 4.438 724837
  132.  
  133. from divdat.2:
  134.  
  135. 11 12472882.0
  136. 56 342 32 1.98663 208278 164 4.44095 72488d
  137. 1e3 341 32 1.97801 20845b 163 4.43394 7299d8
  138. d26 342 32 1.97415 209181 164 4.44095 730fc0
  139. 2 341 32 1.96972 209183 163 4.43394 739114
  140. 355 340 32 1.9736 2094d8 162 4.42689 73252f
  141. 1a1 339 32 1.97749 209679 162 4.42544 7326d0
  142. ...
  143. 50 362 27 2.17167 3e4a3d 156 4.35437 a084a7
  144. 6a 363 27 2.16879 3e4aa7 156 4.34815 a08511
  145. 376 362 27 2.16406 3e4e1d 155 4.34112 a09769
  146. 0 363 27 2.16879 3e4e1d 156 4.34815 a08882
  147. 76 364 27 2.16591 3e4e93 157 4.35515 9fd231
  148. 2 363 27 2.16118 3e4e95 156 4.34815 a0a811
  149. 5a 362 27 2.16406 3e4eef 156 4.34803 a0a86b
  150.  
  151.      Note that each divdat.X file begins with a line that specifies the
  152. format and starting time of that file.  The first byte specifies if the
  153. file is binary (0) or ascii (1).  The second byte specifies if the file
  154. contains data on genotype diversity (1) or size diversity only (0).  After
  155. the two format bytes, there is a double precision floating point number
  156. which specifies the start time, in Tierran instructions of this file
  157. (actually the end time of the previous divdat.X file, or zero for the first
  158. file).
  159.  
  160.      The following code writes the format line of the divdat.X files:
  161.  
  162.     if(format) /* ASCII format */
  163.     {   ouf = fopen(ofile,"w");
  164.         if(genotypes)
  165.             fprintf(ouf,"11 %.1lf\n", totals.time);
  166.         else
  167.             fprintf(ouf,"10 %.1lf\n", totals.time);
  168.     }
  169.     else /* binary format */
  170.     {   ouf = fopen(ofile,"wb");
  171.         c = (char) format;
  172.         fwrite(&c,sizeof(char),1,ouf);
  173.         c = (char) genotypes;
  174.         fwrite(&c,sizeof(char),1,ouf);
  175.         fwrite(&totals.time,sizeof(double),1,ouf);
  176.     }
  177.  
  178.      After the format line, the divdat.X files contain an eight column data
  179. stream (if genotypes are included), or a five column output if only size
  180. class data is included.  A typical output line from an ASCII file looks like
  181. the following:
  182.  
  183. 34f 341 32 1.98219 20795c 163 4.43486 72ed46
  184.  
  185.      The first column (Time) is the time increment since the last birth or
  186. death in hexadecimal format.  In order to determine the actual time associated
  187. with a particular output line, the values in the first column must be summed.
  188.  
  189.      The second column (NumCell) is the total population, the number of cells,
  190. in decimal format.  The third column (NumSize) is the number of size classes,
  191. in decimal format.  The fourth column (SizeDiv) is the size diversity as a
  192. floating point number.  Size diversity is the negative sum of p log p, where
  193. p is the proportion of the population occupied by a particular size class,
  194. summed over all size classes.  The fifth column (AgeSize) is the average age
  195. of the size classes, as a hexidecimal number.  When a new size class appears,
  196. or an extinct size class reappears, its age is set to zero.  The age then
  197. increments with time.  At each time increment, the age of all size classes
  198. is summed, and divided by the number of size classes to compute the average
  199. age of size classes.
  200.  
  201.      If genotype data is displayed, the the sixth column (NumGeno) contains
  202. the number of genotypes as a decimal number.  The seventh column (GenoDiv)
  203. contains the genotype diversity as a floating point number.  Genotype
  204. diversity is the negative sum of p log p, where p is the proportion of the
  205. population occupied by a particular genotype class, summed over all genotype
  206. classes.  The eighth column (AgeGeno) contains the average age of the
  207. genotypes as a hexidecimal number.  When a new genotype class appears, or an
  208. extinct genotype class reappears, its age is set to zero.  The age then
  209. increments with time.  At each time increment, the age of all genotype classes
  210. is summed, and divided by the number of genotype classes to compute the
  211. average age of genotype classes.
  212.  
  213.      The code that produces the data lines in the divdat.X files follows:
  214.  
  215. struct siz {
  216.     long   Time;
  217.     long   NumCell;
  218.     long   NumSize;
  219.     float  SizeDiv;
  220.     long   AgeSize;
  221.     } si;
  222.  
  223. struct gen {
  224.     long   NumGeno;
  225.     float  GenoDiv;
  226.     long   AgeGeno;
  227.     } ge;
  228.  
  229.     if(format) /* ASCII format */
  230.     {   if(genotypes)
  231.             fsize += 1 + fprintf(ouf,"%lx %ld %ld %g %lx %ld %g %lx\n",
  232.             rlo.itime, totals.TotPop, divdat.NumSize, divdat.SizeDiv,
  233.             (Ulong) AgeSize, divdat.NumGeno, divdat.GenoDiv,
  234.             (Ulong) AgeGeno);
  235.         else fsize += 1 + fprintf(ouf,"%lx %ld %ld %g %lx\n",
  236.             rlo.itime, totals.TotPop, divdat.NumSize, divdat.SizeDiv,
  237.             (Ulong) AgeSize);
  238.     }
  239.     else /* binary format */
  240.     {   si.Time = rlo.itime;
  241.         si.NumCell = totals.TotPop;
  242.         si.NumSize = divdat.NumSize;
  243.         si.SizeDiv = divdat.SizeDiv;
  244.         si.AgeSize = (Ulong) AgeSize;
  245.         fwrite(&si, sizeof(struct siz), 1, ouf);
  246.         fsize += sizeof(struct siz);
  247.         if(genotypes)
  248.         {   ge.NumGeno = divdat.NumGeno;
  249.             ge.GenoDiv = divdat.GenoDiv;
  250.             ge.AgeGeno = (Ulong) AgeGeno;
  251.             fwrite(&ge, sizeof(struct gen), 1, ouf);
  252.             fsize += sizeof(struct gen);
  253.         }
  254.     }
  255.  
  256. from brkrange:
  257.  
  258.      divdat.1 0 0 0 0 0 0 0 0
  259.      divdat.1 12472882 351 32 2.01064 3456383 166 4.45098 7989488
  260.      divdat.2 23007672 456 36 2.27044 4583906 212 4.78146 10726890
  261.      divdat.3 32218752 456 43 2.71956 5252442 240 5.19617 14721618
  262.      divdat.4 41767554 465 51 2.95793 7448691 240 5.19617 20849185
  263.      divdat.5 48183196 467 51 2.95793 7722602 242 5.19617 22182141
  264.  
  265.      The brkrange file contains lines with the same eight numeric columns
  266. as the lines in the divdat.X files.  However, in the brkrange file, all
  267. columns are expressed in decimal format (no hexidecimal), and each entry
  268. represents the cumulative maximum value of the corresponding entry at the
  269. end of the divdat.X file named in the first column.  An exception is that
  270. there are two lines for the divdat.1 file, the first line represents the
  271. values of the eight variables at the beginning of the file, while the
  272. second line represents the maximum values of each variable at the end
  273. of the file.  Another exception is that the first numeric column represents
  274. the cumulative time at the end of the file (not the maximum time increment).
  275. The data is provides so that individual divdat.X files can be plotted, and
  276. the user can know the range of the variables when configuring the plot.
  277.  
  278. from divrange:
  279.  
  280.            Minimum      Maximum      Average Number
  281.  
  282. Time             0    103717758              226162
  283. NumCell          0          374        262.2 226162
  284. NumSize          0           21          9.9 226162
  285. SizeDiv   0.000000     2.503943     1.177503 226162
  286. AgeSize          0     26892940   12170879.1 226162
  287. NumGeno          0           92         56.8 226162
  288. GenoDiv   0.000000     4.346522     3.372861 226162
  289. AgeGeno          0      6710709    3274868.8 226162
  290.  
  291.      The divrange file is fairly self explanatory.  It lists the minimum,
  292. maximum and average values for each of the eight variables computer by
  293. the diversity tool.  The last column shows the sample size (the number of
  294. births and deaths that went into the computation).
  295.  
  296. from averages:
  297.  
  298.        Time NumCell NumSize SizeDiv    AgeSize NumGeno GenoDiv    AgeGeno
  299.  
  300.     1001395   230.7     1.7    0.05     436052    13.9    0.86     321276
  301.     2000507   279.0     5.9    0.27     925677    32.4    1.63     823193
  302.     3000940   274.8     6.8    0.35    1354576    36.8    1.83    1220080
  303.     4001155   276.5     5.3    0.34    2059764    38.8    1.96    1524246
  304.     5000097   274.8     7.4    0.52    2147820    35.4    1.86    1681769
  305.     6000879   274.8     7.3    0.79    2476165    36.6    2.08    1841812
  306.     7000084   277.1     6.8    0.96    3315557    39.7    2.30    1713698
  307.     8001588   304.5     8.1    0.97    3324491    40.6    2.32    1676695
  308.  
  309.      The averages file is also self-explanatory.  It lists the average
  310. value of each parameter over a user defined interval.  The time at the
  311. end of the interval is shown in the first column.  All numbers are expressed
  312. in decimal format.
  313.