library(ggplot2)
library(readr)
34 Loading and preparing simulation results
<- "assets/netlogo/experiments/Artificial Anasazi_experiments " experiments_path
<- c("historical households" = "blue",
color_mapping "simulation households" = "darkred")
34.1 Single run
<- "experiment single run" expname
Read output:
<- readr::read_csv(paste0(experiments_path, expname, "-table.csv"), skip = 6) results_single
Rows: 552 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): map-view
dbl (9): [run number], fertility, death-age, harvest-variance, fertility-end...
lgl (1): historic-view?
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Plot trajectories of metrics:
<- paste0(experiments_path, expname, "-trajectories.png")
plot_name
png(plot_name, width = 840, height = 540)
ggplot(results_single) +
geom_line(aes(x = `[step]`, y = `historical-total-households`, color = "historical data"),
linewidth = 1.2) +
geom_line(aes(x = `[step]`, y = `total-households`, color = "simulation households"),
linewidth = 1.2) +
labs(x = "steps", y = "households") +
scale_color_manual(name = "", values = color_mapping) +
theme(legend.position = "right")
dev.off()
svg
2
::include_graphics(plot_name) knitr
34.2 Multiple runs in single configuration
<- "experiment multiple runs" expname
Read output:
<- readr::read_csv(paste0(experiments_path, expname, "-table.csv"), skip = 6) results_single
Rows: 5520 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): map-view
dbl (9): [run number], fertility, death-age, harvest-variance, fertility-end...
lgl (1): historic-view?
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Plot trajectories of metrics:
<- paste0(experiments_path, expname, "-trajectories.png")
plot_name
png(plot_name, width = 840, height = 540)
ggplot(results_single) +
geom_line(aes(x = `[step]`, y = `total-households`, color = `[run number]`, group = `[run number]`),
linewidth = 1.2) +
geom_line(aes(x = `[step]`, y = `historical-total-households`),
color = color_mapping["historical households"],
linewidth = 1.2, linetype = 2) +
labs(x = "steps", y = "households") +
theme(legend.position = "right")
dev.off()
svg
2
::include_graphics(plot_name) knitr
34.3 Parameter exploration - regular intervals
34.3.1 One parameter
<- "experiment harvest adjustment" expname
Read output:
<- readr::read_csv(paste0(experiments_path, expname, "-table.csv"), skip = 6) results_harvest_adj
Rows: 104880 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): map-view
dbl (9): [run number], fertility, death-age, harvest-variance, fertility-end...
lgl (1): historic-view?
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Plot trajectories of metrics:
<- paste0(experiments_path, expname, "-trajectories.png")
plot_name
png(plot_name, width = 840, height = 540)
ggplot(results_harvest_adj) +
geom_line(aes(x = `[step]`, y = `total-households`, color = `harvest-adjustment`, group = `[run number]`),
linewidth = 1.2) +
geom_line(aes(x = `[step]`, y = `historical-total-households`), color = "black",
linewidth = 1.2, linetype = 2) +
labs(x = "steps", y = "households") +
theme(legend.position = "right")
dev.off()
svg
2
::include_graphics(plot_name) knitr
34.3.2 Two parameter
<- "experiment harvest adjustment variance" expname
Read output:
<- readr::read_csv(paste0(experiments_path, expname, "-table.csv"), skip = 6) results_harvest_adj
Rows: 441600 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): map-view
dbl (9): [run number], fertility, death-age, harvest-variance, fertility-end...
lgl (1): historic-view?
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Plot trajectories of metrics:
<- paste0(experiments_path, expname, "-trajectories.png")
plot_name
png(plot_name, width = 840, height = 540)
ggplot(results_harvest_adj) +
geom_line(aes(x = `[step]`, y = `total-households`, group = `[run number]`),
color = color_mapping["simulation households"],
linewidth = 1.2) +
geom_line(aes(x = `[step]`, y = `historical-total-households`),
color = color_mapping["historical households"],
linewidth = 1.2, linetype = 2) +
facet_grid(`harvest-adjustment` ~ `harvest-variance`) +
labs(x = "steps", y = "households") +
theme(legend.position = "right")
dev.off()
svg
2
::include_graphics(plot_name) knitr