|
199 | 199 | <p class="p5">verbosity <–> (integer$)</p> |
200 | 200 | <p class="p6">The verbosity level, for SLiM’s logging of information about the simulation.<span class="Apple-converted-space"> </span>This is <span class="s1">1</span> by default, but can be changed at the command line with the <span class="s1">-l[ong]</span> option.<span class="Apple-converted-space"> </span>It is provided here so that scripts can consult it to govern the level of verbosity of their own output, or set the verbosity level for particular sections of their code.<span class="Apple-converted-space"> </span>A verbosity level of 0 suppresses most of SLiM’s optional output; 2 adds some extra output beyond SLiM’s standard output.</p> |
201 | 201 | <p class="p2"><i>5.3.2<span class="Apple-converted-space"> </span></i><span class="s1"><i>Community</i></span><i> methods</i></p> |
202 | | -<p class="p5">– (object<LogFile>$)createLogFile(string$ filePath, [Ns initialContents = NULL], [logical$ append = F], [logical$ compress = F], [string$ sep = ","], [Ni$ logInterval = NULL], [Ni$ flushInterval = NULL])</p> |
| 202 | +<p class="p5">– (object<LogFile>$)createLogFile(string$ filePath, [Ns initialContents = NULL], [logical$ append = F], [logical$ compress = F], [string$ sep = ","], [Ni$ logInterval = NULL], [Ni$ flushInterval = NULL], [logical$ header = T])</p> |
203 | 203 | <p class="p6">Creates and returns a new <span class="s1">LogFile</span> object that logs data from the simulation (see the documentation for the <span class="s1">LogFile</span> class for details).<span class="Apple-converted-space"> </span>Logged data will be written to the file at <span class="s1">filePath</span>, overwriting any existing file at that path by default, or appending to it instead if <span class="s1">append</span> is <span class="s1">T</span> (successive rows of the log table will always be appended to the previously written content, of course).<span class="Apple-converted-space"> </span>Before the header line for the log is written out, any <span class="s1">string</span> elements in <span class="s1">initialContents</span> will be written first, separated by newlines, allowing for a user-defined file header.<span class="Apple-converted-space"> </span>If <span class="s1">compress</span> is <span class="s1">T</span>, the contents will be compressed with <span class="s1">zlib</span> as they are written, and the standard <span class="s1">.gz</span> extension for gzip-compressed files will be appended to the filename in <span class="s1">filePath</span> if it is not already present.</p> |
204 | 204 | <p class="p6">The <span class="s1">sep</span> parameter specifies the separator between data values within a row.<span class="Apple-converted-space"> </span>The default of <span class="s1">","</span> will generate a “comma-separated value” (CSV) file, while passing <span class="s1">sep="\t"</span> will use a tab separator instead to generate a “tab-separated value” (TSV) file.<span class="Apple-converted-space"> </span>Other values for <span class="s1">sep</span> may also be used, but are less standard.</p> |
205 | 205 | <p class="p6">LogTable supports periodic automatic logging of a new row of data, enabled by supplying a non-<span class="s1">NULL</span> value for <span class="s1">logInterval</span>.<span class="Apple-converted-space"> </span>In this case, a new row will be logged (as if <span class="s1">logRow()</span> were called on the <span class="s1">LogFile</span>) at the end of every <span class="s1">logInterval</span> ticks (just before the tick counter increments, in both WF and nonWF models), starting at the end of the tick in which the <span class="s1">LogFile</span> was created.<span class="Apple-converted-space"> </span>A <span class="s1">logInterval</span> of <span class="s1">1</span> will cause automatic logging at the end of every tick, whereas a <span class="s1">logInterval</span> of <span class="s1">NULL</span> disables automatic logging.<span class="Apple-converted-space"> </span>Automatic logging can always be disabled or reconfigured later with the <span class="s1">LogFile</span> method <span class="s1">setLogInterval()</span>, or logging can be triggered manually by calling <span class="s1">logRow()</span>.</p> |
206 | 206 | <p class="p6">When compression is enabled, <span class="s1">LogFile</span> flushes new data lazily by default, for performance reasons, buffering data for multiple rows before writing to disk.<span class="Apple-converted-space"> </span>Passing a non-<span class="s1">NULL</span> value for <span class="s1">flushInterval</span> requests a flush every <span class="s1">flushInterval</span> rows (with a value of <span class="s1">1</span> providing unbuffered operation).<span class="Apple-converted-space"> </span>Note that flushing very frequently will likely result in both lower performance and a larger final file size (in one simple test, <span class="s1">48943</span> bytes instead of <span class="s1">4280</span> bytes, or more than a 10× increase in size).<span class="Apple-converted-space"> </span>Alternatively, passing a very large value for <span class="s1">flushInterval</span> will effectively disable automatic flushing, except at the end of the simulation (but be aware that this may use a large amount of memory for large log files).<span class="Apple-converted-space"> </span>In any case, the log file will be created immediately, with its requested initial contents; the initial write is not buffered.<span class="Apple-converted-space"> </span>When compression is not enabled, the <span class="s1">flushInterval</span> setting is ignored.</p> |
| 207 | +<p class="p6">The <span class="s1">header</span> parameter controls whether a header line is written out at the beginning of logging.<span class="Apple-converted-space"> </span>If it is <span class="s1">T</span> (the default), a header line is written out; if <span class="s1">F</span>, no header is written.<span class="Apple-converted-space"> </span>Suppressing the header output can be useful if you are using <span class="s1">LogFile</span> to append data to an existing file that already has a header line.</p> |
207 | 208 | <p class="p6">The <span class="s1">LogFile</span> documentation discusses how to configure and use <span class="s1">LogFile</span> to write out the data you are interested in from your simulation.</p> |
208 | 209 | <p class="p5">– (integer$)estimatedLastTick(void)</p> |
209 | 210 | <p class="p6">Returns SLiM’s current estimate of the last tick in which the model will execute.<span class="Apple-converted-space"> </span>Because script blocks can be added, removed, and rescheduled, and because the simulation may end prematurely (due to a call to <span class="s1">simulationFinished()</span>, for example), this is only an estimate, and may change over time.</p> |
|
651 | 652 | <p class="p6">You can get the <span class="s1">LogFile</span> instance, in order to call <span class="s1">logRow()</span> on it, from <span class="s1">community.logFiles</span>, or you can remember it in a global constant with <span class="s1">defineConstant()</span>.</p> |
652 | 653 | <p class="p5">– (void)setLogInterval([Ni$ logInterval = NULL])</p> |
653 | 654 | <p class="p6">Sets the automatic logging interval.<span class="Apple-converted-space"> </span>A <span class="s1">logInterval</span> of <span class="s1">NULL</span> stops automatic logging immediately.<span class="Apple-converted-space"> </span>Other values request that a new row should be logged (as if <span class="s1">logRow()</span> were called) at the end of every <span class="s1">logInterval</span> ticks (just before the tick count increment, in both WF and nonWF models), starting at the end of the tick in which <span class="s1">setLogInterval()</span> was called.</p> |
654 | | -<p class="p5">– (void)setFilePath(string$ filePath, [Ns initialContents = NULL], [logical$ append = F], [Nl$ compress = NULL], [Ns$ sep = NULL])</p> |
655 | | -<p class="p6">Redirects the <span class="s1">LogFile</span> to write new rows to a new <span class="s1">filePath</span>.<span class="Apple-converted-space"> </span>Any rows that have been buffered but not flushed will be written to the previous file first, as if <span class="s1">flush()</span> had been called.<span class="Apple-converted-space"> </span>With this call, new <span class="s1">initialContents</span> may be supplied, which will either replace any existing file or will be appended to it, depending upon the value of <span class="s1">append</span>.<span class="Apple-converted-space"> </span>New values may be supplied for <span class="s1">compress</span> and <span class="s1">sep</span>; the meaning of these parameters is identical to their meaning in <span class="s1">createLogFile()</span>, except that a value of <span class="s1">NULL</span> for these means “do not change this setting from its previous value”.<span class="Apple-converted-space"> </span>In effect, then, this method lets you start a completely new log file at a new path, without having to create and configure a new <span class="s1">LogFile</span> object.<span class="Apple-converted-space"> </span>The new file will be created (or appended) synchronously, with the specified initial contents.</p> |
| 655 | +<p class="p5">– (void)setFilePath(string$ filePath, [Ns initialContents = NULL], [logical$ append = F], [Nl$ compress = NULL], [Ns$ sep = NULL], [Nl$ header = NULL])</p> |
| 656 | +<p class="p6">Redirects the <span class="s1">LogFile</span> to write new rows to a new <span class="s1">filePath</span>.<span class="Apple-converted-space"> </span>Any rows that have been buffered but not flushed will be written to the previous file first, as if <span class="s1">flush()</span> had been called.<span class="Apple-converted-space"> </span>With this call, new <span class="s1">initialContents</span> may be supplied, which will either replace any existing file or will be appended to it, depending upon the value of <span class="s1">append</span>.<span class="Apple-converted-space"> </span>New values may be supplied for <span class="s1">compress</span>, <span class="s1">sep</span>, and <span class="s1">header</span>; the meaning of these parameters is identical to their meaning in <span class="s1">createLogFile()</span>, except that a value of <span class="s1">NULL</span> for these means “do not change this setting from its previous value”.<span class="Apple-converted-space"> </span>In effect, then, this method lets you start a completely new log file at a new path, without having to create and configure a new <span class="s1">LogFile</span> object.<span class="Apple-converted-space"> </span>The new file will be created (or appended) synchronously, with the specified initial contents.</p> |
656 | 657 | <p class="p5">– (void)setSuppliedValue(string$ columnName, +$ value)</p> |
657 | 658 | <p class="p6">Registers a value, passed in <span class="s1">value</span>, to be used for the supplied column named <span class="s1">columnName</span> when a row is next logged.<span class="Apple-converted-space"> </span>This column must have been added with <span class="s1">addSuppliedColumn()</span>.<span class="Apple-converted-space"> </span>A value of <span class="s1">NULL</span> may be passed to log <span class="s1">NA</span>, but logging <span class="s1">NA</span> is the default behavior for supplied columns in any case.<span class="Apple-converted-space"> </span>Otherwise, the value must be a singleton, and its type should match the values previously supplied for the column (otherwise the log file may be difficult to parse, since the values within the column will not be of one consistent type).<span class="Apple-converted-space"> </span>See <span class="s1">addSuppliedColumn()</span> for further details.</p> |
658 | 659 | <p class="p5">– (void)setValue(is$ key, * value)</p> |
|
0 commit comments