number cycles set by variable?

40 views
Skip to first unread message

bob

unread,
May 12, 2022, 6:01:27 PM5/12/22
to slim-discuss
is it possible to set the number of cycles/ticks/generations using a variable? like ticks 2:burnin early(){... with burnin an integer declared during the initialization call-back?

Ben Haller

unread,
May 12, 2022, 6:08:17 PM5/12/22
to slim-discuss
See section 20.2, a couple of paragraphs in.  It's not as smooth as one would like it to be, but that section explains how to do it.

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University

bob

unread,
May 14, 2022, 2:31:23 PM5/14/22
to slim-discuss

thanks ben! im still confused on how to set the number of cycles with a parameter. for example, i expected the following script (a modification of recipe 4.1) to run, but it throws an unexpected identifier error. im hoping to use this in another script where a burnin period is set so i don't have to adjust three different numbers each time i want to change the burnin period.

// Keywords:


// set up a simple neutral simulation

initialize()

{

   // set the overall mutation rate

   initializeMutationRate(1e-7);

   

   // m1 mutation type: neutral

   initializeMutationType("m1", 0.5, "f", 0.0);

   

   // g1 genomic element type: uses m1 for all mutations

   initializeGenomicElementType("g1", m1, 1.0);

   

   // uniform chromosome of length 100 kb

   initializeGenomicElement(g1, 0, 99999);

   

   // uniform recombination along the chromosome

   initializeRecombinationRate(1e-8);

   

   defineConstant("ncycles",10000);

}


// create a population of 500 individuals

1 early()

{

   sim.addSubpop("p1", 500);

}


// run to tick 10000

ncycles early()

{

   sim.simulationFinished();

}


Ben Haller

unread,
May 14, 2022, 2:39:19 PM5/14/22
to slim-discuss
Hi Bob.  Did you have a chance to read section 20.2?  As it explains, you cannot use a symbol in the generation range as you are trying to do.  Instead, you need to use an integer (any integer that is sufficiently large that the script block does not run accidentally before you intend it to), and then reschedule the script block to the desired tick(s) when your script starts running (i.e., in a 1 first() event, perhaps).  That is the only way to achieve what you are trying to do.  There are lots of reasons, under the hood, for why this is necessary; making it work the way you want it to work would be quite difficult and would involve ambiguities in the general case (since symbols, even "constants", can be redefined in Eidos).  Please do check out section 20.2 for a working solution.

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University

bob

unread,
May 14, 2022, 2:45:28 PM5/14/22
to slim-discuss
ah, thanks again ben! sorry about that, i assumed that section only referred to the case of command line input based on the first paragraph so didn't read the whole thing. will definitely read it all now!
Reply all
Reply to author
Forward
0 new messages