rescheduleScriptBlock: SLiM method rescheduleScriptBlock

Description Usage Arguments Details Value Copyright Author(s)

View source: R/slim_lang.R

Description

Documentation for SLiM function rescheduleScriptBlock, which is a method of the SLiM class SLiMSim. Note that the R function is a stub, it does not do anything in R (except bring up this documentation). It will only do anything useful when used inside a slim_block function further nested in a slim_script function call, where it will be translated into valid SLiM code as part of a full SLiM script.

Usage

1
rescheduleScriptBlock(block, start, end, generations)

Arguments

block

An object of type SLiMEidosBlock object. Must be of length 1 (a singleton). See details for description.

start

An object of type integer. Must be of length 1 (a singleton). See details for description.

end

An object of type null or integer. Must be of length 1 (a singleton). The default value is NULL. See details for description.

generations

An object of type null or integer. The default value is NULL. See details for description.

Details

Reschedule the target script block given by block to execute in a specified set of generations. The first way to specify the generation set is with start and end parameter values; block will then execute from start to end, inclusive. In this case, block is returned. The second way to specify the generation set is using the generations parameter; this is more flexible but more complicated. Since script blocks execute across a contiguous span of generations defined by their start and end properties, this may result in the duplication of block; one script block will be used for each contiguous span of generations in generations. The block object itself will be rescheduled to cover the first such span, whereas duplicates of block will be created to cover subsequent contiguous spans. A vector containing all of the script blocks scheduled by this method, including block, will be returned; this vector is guaranteed to be sorted by the (ascending) scheduled execution order of the blocks. Any duplicates of block created will be given values for the active, source, tag, and type properties equal to the current values for block, but will be given an id of -1 since script block identifiers must be unique; if it is necessary to find the duplicated blocks again later, their tag property should be used. The vector supplied for generations does not need to be in sorted order, but it must not contain any duplicates. Because this method can create a large number of duplicate script blocks, it can sometimes be better to handle script block scheduling in other ways. If an early() event needs to execute every tenth generation over the whole duration of a long model run, for example, it would not be advisable to use a call like sim.rescheduleScriptBlock(s1, generations=seq(10, 100000, 10)) for that purpose, since that would result in thousands of duplicate script blocks. Instead, it would be preferable to add a test such as if (sim.generation event. It is legal to reschedule a script block while the block is executing; a call like sim.rescheduleScriptBlock(self, sim.generation + 10, sim.generation + 10); made inside a given block would therefore also cause the block to execute every tenth generation, although this sort of self-rescheduling code is probably harder to read, maintain, and debug. Whichever way of specifying the generation set is used, the discussion in section 24.9 applies: block may continue to be executed during the current life cycle stage even after it has been rescheduled, unless it is made inactive using its active property, and similarly, the block may not execute during the current life cycle stage if it was not already scheduled to do so. Rescheduling script blocks during the generation and life cycle stage in which they are executing, or in which they are intended to execute, should be avoided. Note that new script blocks can also be created and scheduled using the register...() methods of SLiMSim; by using the same source as a template script block, the template can be duplicated and scheduled for different generations. In fact, rescheduleScriptBlock() does essentially that internally.

Value

An object of type SLiMEidosBlock object.

Copyright

This is documentation for a function in the SLiM software, and has been reproduced from the official manual, which can be found here: http://benhaller.com/slim/SLiM_Manual.pdf. This documentation is Copyright © 2016–2020 Philipp Messer. All rights reserved. More information about SLiM can be found on the official website: https://messerlab.org/slim/

Author(s)

Benjamin C Haller (bhaller@benhaller.com) and Philipp W Messer (messer@cornell.edu)


rdinnager/slimrlang documentation built on June 20, 2020, 8:17 p.m.