-
Notifications
You must be signed in to change notification settings - Fork 1
/
1_singleRunExploration.Rmd
932 lines (779 loc) · 44.8 KB
/
1_singleRunExploration.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
---
site: bookdown::bookdown_site
output:
bookdown::gitbook: default
---
# Single runs
```{r 1_setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, # hide code and messages
cache=TRUE, autodep=TRUE)
source("library/hpcModel.run.R")
source("library/hpcModel.exploration.R")
source("library/hpcModel.plot.R")
# pre-load packages used in this script or in source code
require(reshape2)
require(ggplot2)
require(scales)
require(kableExtra)
require(purrr)
require(magick)
```
```{r 1_table-functions}
source("library/plotting/printTableRun.R")
```
```{r 1_default-values, cache=TRUE}
# this is the 'default' parameter setting (end state is 'fast coevolution'):
# initial populations
initial_population_humans_default = 10
initial_population_plants_default = 10
# number of discrete types
number_types_humans_default = 30
number_types_plants_default = 30
# undirected variation
undirected_variation_humans_default = 0.15
undirected_variation_plants_default = 0.15
# intrinsic growth rate
intrinsic_growth_rate_humans_default = 0.04
intrinsic_growth_rate_plants_default = 0.1
# Utility per capita of individuals of type N
utility_per_capita_type_n_plants_to_humans_default = 1.5
utility_per_capita_type_n_humans_to_plants_default = 1
# Utility per capita of individuals of type 1
utility_per_capita_type_1_plants_to_humans_default = 0.15
utility_per_capita_type_1_humans_to_plants_default = 0
# basic resources:
# population of type N that can be sustained by resources independent of HP relationship
utility_other_to_type_n_humans_default = 10
utility_other_to_type_n_plants_default = 20
# population of type 1 that can be sustained by resources independent of HP relationship
utility_other_to_type_1_humans_default = 80
utility_other_to_type_1_plants_default = 100
# maximum local area to be used by populations (multiplier or scaling effect)
max_area_default = 200
# settings
# simulation flow & data
max_iterations_default = 5000
relreltol_exponential_exponential_default = 6
coevolution_threshold_default = 0.5
save_trajectories_default = TRUE
messages_default = TRUE
# plotting and other
plot_preview_default = FALSE
plot_sleep_default = 0.05
plot_save_default = TRUE
plot_save_every_default = 5
```
```{r 1_plot-functions, include=FALSE}
# this chunk is specific for this exploration
# for creating animates GIF, you need to install purrr and magick packages.
runPlotDirectory <- "plots/runPlot/" # directory holding animation files
dataDirectory <- "data/1_run_"
source("library/plotting/plotTrajectory.R")
source("library/plotting/animateTrajectory.R")
```
Attractors are system stable states, in which all variables become, at some level, predictable (i.e., they attract trajectories). For most of the conditions explored, the HPC model displays stationary points, which are attractors where variables converge and do not change unless the system is perturbed.
Another kind of attractor, oscillations, exists. A special case of oscillation occurs when either the iteration unit or at least one of the intrinsic growth rates are greater than the unit ( dt > 1 or rA > 1 ). Such behaviour is a common feature of logistic growth models and was already observed and analysed by Hastings (1997). More interestingly, certain, less extreme parameter configurations also produce oscillatory states (see last section in this chapter).
\newpage
## Fast coevolution (default)
```{r 1_run_coevolution_sameTiming-name, cache=TRUE}
run_coevolution_sameTiming_name <- "coevolution-sameTiming"
run_coevolution_sameTiming_runDataFileName = paste0(dataDirectory, run_coevolution_sameTiming_name,'.RData')
run_coevolution_sameTiming_animationFileName = paste0(runPlotDirectory, run_coevolution_sameTiming_name, "-anim.gif")
```
```{r 1_run_coevolution_sameTiming, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_coevolution_sameTiming-name')}
if(!file.exists(run_coevolution_sameTiming_runDataFileName) | !file.exists(run_coevolution_sameTiming_animationFileName))
{
run_coevolution_sameTiming <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = utility_per_capita_type_n_plants_to_humans_default,
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = utility_per_capita_type_1_plants_to_humans_default,
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = max_area_default,
max_iterations = max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_coevolution_sameTiming_name, "-runPlot")
)
# save
save(run_coevolution_sameTiming, file = run_coevolution_sameTiming_runDataFileName)
}
# load
load(file = run_coevolution_sameTiming_runDataFileName)
```
```{r 1runcoevolutionsametimingparshtml, eval=!params$ispdf, cache=TRUE, dependson='run_coevolution_sameTiming', fig.align='center', results='asis'}
printTableRun(run_coevolution_sameTiming, caption = 'Parameter setting')
```
```{r 1runcoevolutionsametimingparspdf, eval=params$ispdf, cache=TRUE, dependson=c('1_table-functions', 'run_coevolution_sameTiming'), fig.align='center', results='asis'}
printTableRun(run_coevolution_sameTiming, caption = 'Parameter setting', output = "latex")
```
\vspace{1cm}
Abbreviation | Value
------------ | ---------------------
`time_end` | `r run_coevolution_sameTiming$END$time_end`
`coevolution_coefficient_humans` | `r run_coevolution_sameTiming$END$coevolution_coefficient_humans`
`coevolution_coefficient_plants` | `r run_coevolution_sameTiming$END$coevolution_coefficient_plants`
`dependency_coefficient_humans` | `r run_coevolution_sameTiming$END$dependency_coefficient_humans`
`dependency_coefficient_plants` | `r run_coevolution_sameTiming$END$dependency_coefficient_plants`
`timing_humans` | `r run_coevolution_sameTiming$END$timing_humans`
`timing_plants` | `r run_coevolution_sameTiming$END$timing_plants`
Table: Output variables (values at end state)
\newpage
```{r 1_run_coevolution_sameTiming-defaultPlot, warning=FALSE, dependson='1_run_coevolution_sameTiming'}
png(paste0("plots/1_singleRun_", run_coevolution_sameTiming_name, "_defaultPlot.png"),
width = 1000, height = 1000)
hpcModel.plot(run_coevolution_sameTiming)
invisible(dev.off())
```
```{r 1runcoevolutionsametimingdefaultplot, echo=FALSE, cache=TRUE, dependson='run_coevolution_sameTiming', out.width = '100%', fig.cap='Plotting the end state, i.e. both populations become stationary'}
knitr::include_graphics(paste0("plots/1_singleRun_", run_coevolution_sameTiming_name, "_defaultPlot.png"))
```
\newpage
```{r 1_run_coevolution_sameTiming-ggplot, warning=FALSE, cache=TRUE, dependson='run_coevolution_sameTiming'}
run_coevolution_sameTiming_melted <-
data.frame(humans = run_coevolution_sameTiming$TRAJECTORIES$humans,
plants = run_coevolution_sameTiming$TRAJECTORIES$plants)[!is.na(run_coevolution_sameTiming$TRAJECTORIES$humans), ]
run_coevolution_sameTiming_melted$time <- 1:nrow(run_coevolution_sameTiming_melted)
run_coevolution_sameTiming_melted <- melt(run_coevolution_sameTiming_melted, measure.vars = c('humans', 'plants'))
plotScale = 10
#svg('plots/1_singleRun-ggplot.svg', width=plotScale, height=plotScale)
png(paste0("plots/1_singleRun_", run_coevolution_sameTiming_name, "_ggplot.png"),
width = 200 * plotScale, height = 100 * plotScale)
plotTrajectory(run_coevolution_sameTiming_melted, plot_scale = plotScale)
invisible(dev.off())
```
```{r 1runcoevolutionsametimingggplotprint, echo=FALSE, dependson='run_coevolution_sameTiming-ggplot', out.width = '100%', fig.cap='Plotting population trajectories with ggplot2'}
knitr::include_graphics(paste0("plots/1_singleRun_", run_coevolution_sameTiming_name, "_ggplot.png"))
```
\newpage
```{r 1_run_coevolution_sameTiming-clear, include=FALSE}
rm(run_coevolution_sameTiming, run_coevolution_sameTiming_melted)
```
```{r 1_run_coevolution_sameTiming-frames, include=FALSE, dependson=c('1_default-values', '1_run_coevolution_sameTiming-name')}
if(!file.exists(run_coevolution_sameTiming_animationFileName))
{
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_coevolution_sameTiming_name)
}
```
```{r 1runcoevolutionsametiminganimation, eval=!params$ispdf, dependson='run_coevolution_sameTiming-frames', fig.cap='Animated GIF showing the sequence of states throughout the simulation (only on the html version)'}
knitr::include_graphics(paste0(runPlotDirectory, run_coevolution_sameTiming_name, "-anim.gif"))
```
\FloatBarrier
\newpage
## No coevolution
```{r 1_run_noCoevolution-name, cache=TRUE}
run_noCoevolution_name <- "no-coevolution"
run_noCoevolution_runDataFileName = paste0(dataDirectory, run_noCoevolution_name,'.RData')
run_noCoevolution_animationFileName = paste0(runPlotDirectory, run_noCoevolution_name, "-anim.gif")
```
```{r 1_run_noCoevolution, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_noCoevolution-name')}
if(!file.exists(run_noCoevolution_runDataFileName) | !file.exists(run_noCoevolution_animationFileName))
{
run_noCoevolution <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = utility_per_capita_type_n_plants_to_humans_default,
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = 0, # utility of type 1 plants has utility zero
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = max_area_default,
max_iterations = max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_noCoevolution_name, "-runPlot")
)
# save
save(run_noCoevolution, file = run_noCoevolution_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_noCoevolution)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_noCoevolution_name)
}
```
```{r 1_run_noCoevolution-animation, eval=!params$ispdf, dependson='run_noCoevolution'}
knitr::include_graphics(run_noCoevolution_animationFileName)
```
```{r 1_run_noCoevolution-plot, cache=TRUE, eval=params$ispdf, dependson='run_noCoevolution', fig.width=8, fig.height=8}
# load
load(run_noCoevolution_runDataFileName)
hpcModel.plot(run_noCoevolution, scale_override = 1)
```
```{r 1_run_noCoevolution-clear, include=FALSE}
rm(run_noCoevolution)
```
\newpage
## Coevolution with early cultivation
```{r 1_run_coevolution_earlyHumanChange-name, cache=TRUE}
run_coevolution_earlyHumanChange_name <- "coevolution-early-cultivation"
run_coevolution_earlyHumanChange_runDataFileName = paste0(dataDirectory, run_coevolution_earlyHumanChange_name,'.RData')
run_coevolution_earlyHumanChange_animationFileName = paste0(runPlotDirectory, run_coevolution_earlyHumanChange_name, "-anim.gif")
```
```{r 1_run_coevolution_earlyHumanChange, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_coevolution_earlyHumanChange-name')}
if(!file.exists(run_coevolution_earlyHumanChange_runDataFileName) | !file.exists(run_coevolution_earlyHumanChange_animationFileName))
{
run_coevolution_earlyHumanChange <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = 2, # utility type n plant is higher than default
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = 1, # lutility type 1 plant is higher than default
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = max_area_default,
max_iterations = max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_coevolution_earlyHumanChange_name, "-runPlot")
)
# save
save(run_coevolution_earlyHumanChange, file = run_coevolution_earlyHumanChange_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_coevolution_earlyHumanChange)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_coevolution_earlyHumanChange_name)
}
```
```{r 1_run_coevolution_earlyHumanChange-animation, eval=!params$ispdf, dependson='run_coevolution_earlyHumanChange'}
knitr::include_graphics(run_coevolution_earlyHumanChange_animationFileName)
```
```{r 1_run_coevolution_earlyHumanChange-plot, cache=TRUE, eval=params$ispdf, dependson='run_coevolution_earlyHumanChange', fig.width=8, fig.height=8}
# load
load(run_coevolution_earlyHumanChange_runDataFileName)
hpcModel.plot(run_coevolution_earlyHumanChange, scale_override = 1)
```
```{r 1_run_coevolution_earlyHumanChange-clear, include=FALSE}
rm(run_coevolution_earlyHumanChange)
```
\newpage
## Coevolution with early domestication
```{r 1_run_coevolution_earlyPlantChange-name, cache=TRUE}
run_coevolution_earlyPlantChange_name <- "coevolution-early-domestication"
run_coevolution_earlyPlantChange_runDataFileName = paste0(dataDirectory, run_coevolution_earlyPlantChange_name,'.RData')
run_coevolution_earlyPlantChange_animationFileName = paste0(runPlotDirectory, run_coevolution_earlyPlantChange_name, "-anim.gif")
```
```{r 1_run_coevolution_earlyPlantChange, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_coevolution_earlyPlantChange-name')}
if(!file.exists(run_coevolution_earlyPlantChange_runDataFileName) | !file.exists(run_coevolution_earlyPlantChange_animationFileName))
{
run_coevolution_earlyPlantChange <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = 1, # utility type n plant is the same than type 1 plants
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = 1, # utility type 1 plant is the same than type n plants
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = 20, # baseline carrying capacity of type 1 plant is the same than type n plants
max_area = max_area_default,
max_iterations = max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_coevolution_earlyPlantChange_name, "-runPlot")
)
# save
save(run_coevolution_earlyPlantChange, file = run_coevolution_earlyPlantChange_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_coevolution_earlyPlantChange)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_coevolution_earlyPlantChange_name)
}
```
```{r 1_run_coevolution_earlyPlantChange-animation, eval=!params$ispdf, dependson='run_coevolution_earlyPlantChange'}
knitr::include_graphics(run_coevolution_earlyPlantChange_animationFileName)
```
```{r 1_run_coevolution_earlyPlantChange-plot, cache=TRUE, eval=params$ispdf, dependson='run_coevolution_earlyPlantChange', fig.width=8, fig.height=8}
# load
load(run_coevolution_earlyPlantChange_runDataFileName)
hpcModel.plot(run_coevolution_earlyPlantChange, scale_override = 1)
```
```{r 1_run_coevolution_earlyPlantChange-clear, include=FALSE}
rm(run_coevolution_earlyPlantChange)
```
\newpage
## Cultivation without domestication
```{r 1_run_partialCoevolution_noPlantChange-name, cache=TRUE}
run_partialCoevolution_noPlantChange_name <- "coevolution-no-plant-change"
run_partialCoevolution_noPlantChange_runDataFileName = paste0(dataDirectory, run_partialCoevolution_noPlantChange_name,'.RData')
run_partialCoevolution_noPlantChange_animationFileName = paste0(runPlotDirectory, run_partialCoevolution_noPlantChange_name, "-anim.gif")
```
```{r 1_run_partialCoevolution_noPlantChange, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_partialCoevolution_noPlantChange-name')}
if(!file.exists(run_partialCoevolution_noPlantChange_runDataFileName) | !file.exists(run_partialCoevolution_noPlantChange_animationFileName))
{
run_partialCoevolution_noPlantChange <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = 2.5, # utility type n plant is higher than default
utility_per_capita_type_n_humans_to_plants = 0.45, # utility type n humans is lower than default
utility_per_capita_type_1_plants_to_humans = utility_per_capita_type_1_plants_to_humans_default,
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = max_area_default,
max_iterations= max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_partialCoevolution_noPlantChange_name, "-runPlot")
)
# save
save(run_partialCoevolution_noPlantChange, file = run_partialCoevolution_noPlantChange_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_partialCoevolution_noPlantChange)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_partialCoevolution_noPlantChange_name)
}
```
```{r 1_run_partialCoevolution_noPlantChange-animation, eval=!params$ispdf, dependson='run_partialCoevolution_noPlantChange'}
knitr::include_graphics(run_partialCoevolution_noPlantChange_animationFileName)
```
```{r 1_run_partialCoevolution_noPlantChange-plot, cache=TRUE, eval=params$ispdf, dependson='run_partialCoevolution_noPlantChange', fig.width=8, fig.height=8}
# load
load(run_partialCoevolution_noPlantChange_runDataFileName)
hpcModel.plot(run_partialCoevolution_noPlantChange, scale_override = 1)
```
```{r 1_run_partialCoevolution_noPlantChange-clear, include=FALSE}
rm(run_partialCoevolution_noPlantChange)
```
\newpage
## Coevolution with population "bleep"
```{r 1_run_coevolution_bleep-name, cache=TRUE}
run_coevolution_bleep_name <- "coevolution-bleep"
run_coevolution_bleep_runDataFileName = paste0(dataDirectory, run_coevolution_bleep_name,'.RData')
run_coevolution_bleep_animationFileName = paste0(runPlotDirectory, run_coevolution_bleep_name, "-anim.gif")
```
```{r 1_run_coevolution_bleep, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_coevolution_bleep-name')}
if(!file.exists(run_coevolution_bleep_runDataFileName) | !file.exists(run_coevolution_bleep_animationFileName))
{
run_coevolution_bleep <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = utility_per_capita_type_n_plants_to_humans_default,
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = utility_per_capita_type_1_plants_to_humans_default,
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = 115, # max_area is lower than default
max_iterations = max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_coevolution_bleep_name, "-runPlot")
)
# save
save(run_coevolution_bleep, file = run_coevolution_bleep_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_coevolution_bleep)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_coevolution_bleep_name)
}
```
```{r 1_run_coevolution_bleep-animation, eval=!params$ispdf, dependson='run_coevolution_bleep'}
knitr::include_graphics(run_coevolution_bleep_animationFileName)
```
```{r 1_run_coevolution_bleep-plot, cache=TRUE, eval=params$ispdf, dependson='run_coevolution_bleep', fig.width=8, fig.height=8}
# load
load(run_coevolution_bleep_runDataFileName)
hpcModel.plot(run_coevolution_bleep, scale_override = 1)
```
```{r 1_run_coevolution_bleep-clear, include=FALSE}
rm(run_coevolution_bleep)
```
\newpage
## Coevolution with population "boom"
```{r 1_run_coevolution_boom-name, cache=TRUE}
run_coevolution_boom_name <- "coevolution-boom"
run_coevolution_boom_runDataFileName = paste0(dataDirectory, run_coevolution_boom_name,'.RData')
run_coevolution_boom_animationFileName = paste0(runPlotDirectory, run_coevolution_boom_name, "-anim.gif")
```
```{r 1_run_coevolution_boom, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_coevolution_boom-name')}
if(!file.exists(run_coevolution_boom_runDataFileName) | !file.exists(run_coevolution_boom_animationFileName))
{
run_coevolution_boom <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = 2, # utility type n plant is higher than default
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = utility_per_capita_type_1_plants_to_humans_default,
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = 500, # max_area is higher than default
max_iterations = max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_coevolution_boom_name, "-runPlot")
)
# save
save(run_coevolution_boom, file = run_coevolution_boom_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_coevolution_boom)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_coevolution_boom_name)
}
```
```{r 1_run_coevolution_boom-animation, eval=!params$ispdf, dependson='run_coevolution_boom'}
knitr::include_graphics(run_coevolution_boom_animationFileName)
```
```{r 1_run_coevolution_boom-plot, cache=TRUE, eval=params$ispdf, dependson='run_coevolution_boom', fig.width=8, fig.height=8}
# load
load(run_coevolution_boom_runDataFileName)
hpcModel.plot(run_coevolution_boom, scale_override = 1)
```
```{r 1_run_coevolution_boom-clear, include=FALSE}
rm(run_coevolution_boom)
```
\newpage
## Coevolution with long population "boom"
```{r 1_run_coevolution_longBoom-name, cache=TRUE}
run_coevolution_longBoom_name <- "coevolution-long-boom"
run_coevolution_longBoom_runDataFileName = paste0(dataDirectory, run_coevolution_longBoom_name,'.RData')
run_coevolution_longBoom_animationFileName = paste0(runPlotDirectory, run_coevolution_longBoom_name, "-anim.gif")
```
```{r 1_run_coevolution_longBoom, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_coevolution_longBoom-name')}
if(!file.exists(run_coevolution_longBoom_runDataFileName) | !file.exists(run_coevolution_longBoom_animationFileName))
{
run_coevolution_longBoom <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = 1, # utility type n plant is the same than type 1 plants
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = 1, # utility type 1 plant is the same than type n plants
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = 1000, # max_area is much higher than default
max_iterations = 1000, # this is a dangerously long simulation!!!
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_coevolution_longBoom_name, "-runPlot")
)
# save
save(run_coevolution_longBoom, file = run_coevolution_longBoom_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_coevolution_longBoom)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_coevolution_longBoom_name)
}
```
```{r 1_run_coevolution_longBoom-animation, eval=!params$ispdf, dependson='run_coevolution_longBoom'}
knitr::include_graphics(run_coevolution_longBoom_animationFileName)
```
```{r 1_run_coevolution_longBoom-plot, cache=TRUE, eval=params$ispdf, dependson='run_coevolution_longBoom', fig.width=8, fig.height=8}
# load
load(run_coevolution_longBoom_runDataFileName)
hpcModel.plot(run_coevolution_longBoom, scale_override = 1)
```
```{r 1_run_coevolution_longBoom-clear, include=FALSE}
rm(run_coevolution_longBoom)
```
\newpage
## Semi-coevolution (stationary point)
```{r 1_run_partialCoevolution-name, cache=TRUE}
run_partialCoevolution_name <- "partial-coevolution"
run_partialCoevolution_runDataFileName = paste0(dataDirectory, run_partialCoevolution_name,'.RData')
run_partialCoevolution_animationFileName = paste0(runPlotDirectory, run_partialCoevolution_name, "-anim.gif")
```
```{r 1_run_partialCoevolution, cache=TRUE, include=FALSE, dependson=c('1_default-values', 'run_partialCoevolution-name')}
if(!file.exists(run_partialCoevolution_runDataFileName) | !file.exists(run_partialCoevolution_animationFileName))
{
run_partialCoevolution <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,
number_types_plants = number_types_plants_default,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = 0.5, # utility type n plant is the same than type 1 plants and lower than default
utility_per_capita_type_n_humans_to_plants = utility_per_capita_type_n_humans_to_plants_default,
utility_per_capita_type_1_plants_to_humans = 0.5, # utility type 1 plant is the same than type n plants and higher than default
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = utility_other_to_type_n_humans_default,
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = utility_other_to_type_1_humans_default,
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = max_area_default,
max_iterations = max_iterations_default,
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_partialCoevolution_name, "-runPlot")
)
# save
save(run_partialCoevolution, file = run_partialCoevolution_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_partialCoevolution)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_partialCoevolution_name)
}
```
```{r 1_run_partialCoevolution-animation, eval=!params$ispdf, dependson='run_partialCoevolution'}
knitr::include_graphics(run_partialCoevolution_animationFileName)
```
```{r 1_run_partialCoevolution-plot, cache=TRUE, eval=params$ispdf, dependson='run_partialCoevolution', fig.width=8, fig.height=8}
# load
load(run_partialCoevolution_runDataFileName)
hpcModel.plot(run_partialCoevolution, scale_override = 1)
```
```{r 1_run_partialCoevolution-clear, include=FALSE}
rm(run_partialCoevolution)
```
\newpage
## Semi-coevolution (oscillations)
```{r 1_run_partialCoevolution_oscillation1-name, cache=TRUE}
run_partialCoevolution_oscillation1_name <- "partial-coevolution-oscillation1"
run_partialCoevolution_oscillation1_runDataFileName = paste0(dataDirectory, run_partialCoevolution_oscillation1_name,'.RData')
run_partialCoevolution_oscillation1_animationFileName = paste0(runPlotDirectory, run_partialCoevolution_oscillation1_name, "-anim.gif")
```
```{r 1_run_partialCoevolution_oscillation1-frames, include=FALSE, dependson=c('1_default-values', '1_run_partialCoevolution_oscillation1-name')}
if(!file.exists(run_partialCoevolution_oscillation1_runDataFileName) | !file.exists(run_partialCoevolution_oscillation1_animationFileName))
{
run_partialCoevolution_oscillation1 <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = number_types_humans_default,#10,
number_types_plants = number_types_plants_default,#10,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = intrinsic_growth_rate_humans_default,
intrinsic_growth_rate_plants = intrinsic_growth_rate_plants_default,
utility_per_capita_type_n_plants_to_humans = 0.5, # utility type n plant is the same than type 1 plants and lower than default
utility_per_capita_type_n_humans_to_plants = 0.9, # utility type n humans is lower than default
utility_per_capita_type_1_plants_to_humans = 0.5, # utility type 1 plant is the same than type n plants and higher than default
utility_per_capita_type_1_humans_to_plants = utility_per_capita_type_1_humans_to_plants_default,
utility_other_to_type_n_humans = 20, # baseline carrying capacity for type n humans is higher than default
utility_other_to_type_n_plants = utility_other_to_type_n_plants_default,
utility_other_to_type_1_humans = 100, # baseline carrying capacity for type 1 humans is higher than default
utility_other_to_type_1_plants = utility_other_to_type_1_plants_default,
max_area = max_area_default,
max_iterations = 600, # limit iterations
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_partialCoevolution_oscillation1_name, "-runPlot")
)
# save
save(run_partialCoevolution_oscillation1, file = run_partialCoevolution_oscillation1_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_partialCoevolution_oscillation1)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_partialCoevolution_oscillation1_name)
}
```
```{r 1_run_partialCoevolution_oscillation1-animation, eval=!params$ispdf, dependson='run_partialCoevolution_oscillation1'}
knitr::include_graphics(run_partialCoevolution_oscillation1_animationFileName)
```
```{r 1_run_partialCoevolution_oscillation1-plot, cache=TRUE, eval=params$ispdf, dependson='run_partialCoevolution_oscillation1', fig.width=8, fig.height=8}
# load
load(run_partialCoevolution_oscillation1_runDataFileName)
hpcModel.plot(run_partialCoevolution_oscillation1, scale_override = 1)
```
```{r 1_run_partialCoevolution_oscillation1-clear, include=FALSE}
rm(run_partialCoevolution_oscillation1)
```
```{r 1_run_partialCoevolution_oscillation2-name, cache=TRUE}
run_partialCoevolution_oscillation2_name <- "partial-coevolution-oscillation2"
run_partialCoevolution_oscillation2_runDataFileName = paste0(dataDirectory, run_partialCoevolution_oscillation2_name,'.RData')
run_partialCoevolution_oscillation2_animationFileName = paste0(runPlotDirectory, run_partialCoevolution_oscillation2_name, "-anim.gif")
```
```{r 1_run_partialCoevolution_oscillation2-frames, include=FALSE, dependson=c('1_default-values', '1_run_partialCoevolution_oscillation2-name')}
if(!file.exists(run_partialCoevolution_oscillation2_runDataFileName) | !file.exists(run_partialCoevolution_oscillation2_animationFileName))
{
run_partialCoevolution_oscillation2 <- hpcModel.run(
initial_population_humans = initial_population_humans_default,
initial_population_plants = initial_population_plants_default,
number_types_humans = 10,
number_types_plants = 10,
undirected_variation_humans = undirected_variation_humans_default,
undirected_variation_plants = undirected_variation_plants_default,
intrinsic_growth_rate_humans = 0.15,
intrinsic_growth_rate_plants = 0.15,
utility_per_capita_type_n_plants_to_humans = 1,
utility_per_capita_type_n_humans_to_plants = 0.5, # utility type n humans is the same than type 1
utility_per_capita_type_1_plants_to_humans = 0.2,
utility_per_capita_type_1_humans_to_plants = 0.5,
utility_other_to_type_n_humans = 10,
utility_other_to_type_n_plants = 10,
utility_other_to_type_1_humans = 100,
utility_other_to_type_1_plants = 100,
max_area = max_area_default,
max_iterations = 600, # limit iterations
reltol_exponential = relreltol_exponential_exponential_default,
coevolution_threshold = coevolution_threshold_default,
save_trajectories = save_trajectories_default,
messages = messages_default,
# plotting
plot_preview = plot_preview_default,
plot_sleep = plot_sleep_default,
plot_save = plot_save_default,
plot_save_every = plot_save_every_default,
plot_directory = runPlotDirectory,
plot_file_name = paste0(run_partialCoevolution_oscillation2_name, "-runPlot")
)
# save
save(run_partialCoevolution_oscillation2, file = run_partialCoevolution_oscillation2_runDataFileName)
# clear memory so image magick won't get stuck
rm(run_partialCoevolution_oscillation2)
# Generate an animated GIF using the images in plot_directory folder
animateTrajectory(runPlotDirectory, run_partialCoevolution_oscillation2_name)
}
```
```{r 1_run_partialCoevolution_oscillation2-animation, eval=!params$ispdf, dependson='run_partialCoevolution_oscillation2'}
knitr::include_graphics(run_partialCoevolution_oscillation2_animationFileName)
```
```{r 1_run_partialCoevolution_oscillation2-plot, cache=TRUE, eval=params$ispdf, dependson='run_partialCoevolution_oscillation2', fig.width=8, fig.height=8}
# load
load(run_partialCoevolution_oscillation2_runDataFileName)
hpcModel.plot(run_partialCoevolution_oscillation2, scale_override = 1)
```
```{r 1_run_partialCoevolution_oscillation2-clear, include=FALSE}
rm(run_partialCoevolution_oscillation2)
```