3.4 Ending a simulation
We can explicitly end a simulation using the command sim.simulationFinished()
.
10000 late()
{
sim.simulationFinished();
}
This simply ends the simulation. Typically, we want to output something for the user. We’ll go into more options throughout the course. For now, know that we can output a sample of our population using the following syntax:
10000 late()
{
p1.outputSample(500);
}
where 500
is the number of individuals to output from population p1
. This outputs a lot of information that is typically sent to a downstream application.
A simpler output is to use the function sim.outputFixedMutations()
, which outputs a list of all mutations that have reached fixation (are present in two copies in all individuals).
10000 late()
{
sim.outputFixedMutations();
}