The hands-on sessions are about going through the code together and understanding what each line approximately does.
- Assign someone to be the timekeeper & someone else with experience with R/RStudio to be the screen-sharer.
- Shortly (!) get to know each other.
- Open the file
01_example_sim.R
in RStudio. - Discuss and run the code until line 28.
- What is the proportion of happiness in the last subpopulation in
result_2
? - Compile the
C++
version of the ABM using the code on line 33. - Now run the same ABM as in
result_2
by using the C++ version (line 36). Do you notice the speedup? - Run the rest of the file. Discuss what is happening.
- Open the file
02_parallel_eval.R
in RStudio. - Run the file until line 22.
- Run the following code:
analysis_function(1)
. Discuss what this does. - Now run & discuss the code until line 37. What does the plot show & what does the mean value represent?
- Next, discuss & run the code until line 54. Edit the number of threads so that there are 1 or 2 threads left on your machine. For example, if
detectCores()
returns 8, then line 48 should ben_threads <- 6
orn_threads <- 7
. - Run & discuss the remainder of the file.