Skip to content

Commit b1d6658

Browse files
committed
shift some recipes over to using killIndividuals()
1 parent e4e45af commit b1d6658

7 files changed

Lines changed: 12 additions & 28 deletions

QtSLiM/recipes/Recipe 16.19 - Range expansion in a stepping-stone model II.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ reproduction() {
4444
early() {
4545
// non-overlapping generations; kill off the parental generation
4646
inds = sim.subpopulations.individuals;
47-
inds[inds.age > 0].fitnessScaling = 0.0;
47+
sim.killIndividuals(inds[inds.age > 0]);
4848

4949
// pre-migration density-dependent fitness for each subpop
5050
for (subpop in sim.subpopulations)
51-
{
52-
juvenileCount = sum(subpop.individuals.age == 0);
53-
subpop.fitnessScaling = K / juvenileCount;
54-
}
51+
subpop.fitnessScaling = K / subpop.individualCount;
5552
}
5653
survival() {
5754
// honor SLiM's survival decision

QtSLiM/recipes/Recipe 16.5 - A metapopulation extinction-colonization model.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ early() {
4040
for (subpop in sim.subpopulations)
4141
{
4242
if (runif(1) < e)
43-
subpop.fitnessScaling = 0.0;
43+
sim.killIndividuals(subpop.individuals);
4444
else
4545
subpop.fitnessScaling = K / subpop.individualCount;
4646
}

QtSLiM/recipes/Recipe 19.8 - Within-host reproduction in a host-pathogen model.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ species pathogen reproduction() {
4949

5050
ticks all 1 early() {
5151
monkey.addSubpop("p1", K_MONKEY);
52-
monkey.addSubpop("p2", 0); // temporary graveyard
5352

5453
// choose initial hosts carrying the infection
5554
initial_hosts = p1.sampleIndividuals(5, replace=F);
@@ -128,10 +127,9 @@ ticks all early() {
128127
}
129128
else if (runif(1) < P_death)
130129
{
131-
// the host has died; move to the graveyard until the next monkey cycle
130+
// the host has died; kill it and its pathogens
132131
host = monkey.individualsWithPedigreeIDs(pathogenSubpop.tag);
133-
host.color = "black";
134-
p2.takeMigrants(host);
132+
monkey.killIndividuals(host);
135133
pathogenSubpop.removeSubpopulation();
136134
}
137135
}
@@ -167,9 +165,5 @@ species monkey survival(p1) {
167165
}
168166
return NULL;
169167
}
170-
species monkey survival(p2) {
171-
// all monkeys in the temporary graveyard are dead
172-
return F;
173-
}
174168

175169
ticks all 2000 late() { }

SLiMgui/Recipes/Recipe 16.19 - Range expansion in a stepping-stone model II.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ reproduction() {
4444
early() {
4545
// non-overlapping generations; kill off the parental generation
4646
inds = sim.subpopulations.individuals;
47-
inds[inds.age > 0].fitnessScaling = 0.0;
47+
sim.killIndividuals(inds[inds.age > 0]);
4848

4949
// pre-migration density-dependent fitness for each subpop
5050
for (subpop in sim.subpopulations)
51-
{
52-
juvenileCount = sum(subpop.individuals.age == 0);
53-
subpop.fitnessScaling = K / juvenileCount;
54-
}
51+
subpop.fitnessScaling = K / subpop.individualCount;
5552
}
5653
survival() {
5754
// honor SLiM's survival decision

SLiMgui/Recipes/Recipe 16.5 - A metapopulation extinction-colonization model.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ early() {
4040
for (subpop in sim.subpopulations)
4141
{
4242
if (runif(1) < e)
43-
subpop.fitnessScaling = 0.0;
43+
sim.killIndividuals(subpop.individuals);
4444
else
4545
subpop.fitnessScaling = K / subpop.individualCount;
4646
}

SLiMgui/Recipes/Recipe 19.8 - Within-host reproduction in a host-pathogen model.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ species pathogen reproduction() {
4949

5050
ticks all 1 early() {
5151
monkey.addSubpop("p1", K_MONKEY);
52-
monkey.addSubpop("p2", 0); // temporary graveyard
5352

5453
// choose initial hosts carrying the infection
5554
initial_hosts = p1.sampleIndividuals(5, replace=F);
@@ -128,10 +127,9 @@ ticks all early() {
128127
}
129128
else if (runif(1) < P_death)
130129
{
131-
// the host has died; move to the graveyard until the next monkey cycle
130+
// the host has died; kill it and its pathogens
132131
host = monkey.individualsWithPedigreeIDs(pathogenSubpop.tag);
133-
host.color = "black";
134-
p2.takeMigrants(host);
132+
monkey.killIndividuals(host);
135133
pathogenSubpop.removeSubpopulation();
136134
}
137135
}
@@ -167,9 +165,5 @@ species monkey survival(p1) {
167165
}
168166
return NULL;
169167
}
170-
species monkey survival(p2) {
171-
// all monkeys in the temporary graveyard are dead
172-
return F;
173-
}
174168

175169
ticks all 2000 late() { }

VERSIONS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ development head (in the master branch):
125125
change fitness(NULL) callbacks to be called fitnessEffect() callbacks
126126
split registerFitnessCallback() into registerMutationEffectCallback() and registerFitnessEffectCallback()
127127
add display of the Git SHA-1 hash in slim and SLiMgui, to aid in debugging; works for builds under cmake and qmake, not under Xcode
128+
add a "progress indicator" in SLiMgui, in the Tick counter lineedit, that shows the progress towards the last tick the model will execute (assuming it doesn't stop early)
129+
shift recipes 16.5, 16.19, and 19.8 to use killIndividuals(), for pedagogical purposes
128130

129131

130132
version 3.7.1 (Eidos version 2.7.1):

0 commit comments

Comments
 (0)