-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathS1.Rmd
More file actions
127 lines (92 loc) · 7.07 KB
/
Copy pathS1.Rmd
File metadata and controls
127 lines (92 loc) · 7.07 KB
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
---
title: "Supplementary Material 1: Animal & Farm technical details and database structure"
output:
word_document:
reference_docx: "template.docx"
html_document:
css: main_ms.css
bibliography: references.bib
link-citations: true
number-sections: true
---
```{r setup, include=FALSE}
library(flextable)
library(officer)
```
# Animal & Farm technical details
## Structure as relating to GMSE
A&F uses a development version of GMSE implemented in `r sessionInfo()$R.version$version.string`, the code for which is freely available: <https://github.com/ConFooBio/gmse/tree/man_control>.
In this version, the management model is replaced by player inputs, and the order of operations is altered to accommodate this.
To initialise each game session, four time steps are run using the default GMSE implementation; i.e. in these time steps the management decisions are chosen by the default GA, and the resource, observation and user models are run using the parameters as defined for the given scenario (see 4.2 below).
These time steps are followed by a "partial" time step where only the resource and observation models are run, skipping the management and user models.
As a result, at the end of these initial time steps ([`init_man_control()`](%5B%60https://github.com/ConFooBio/gmse/blob/0e8aab2fb325421915a7c3615820812e45f42a74/R/gmse_apply_control.R#L368%60%5D(https://github.com/ConFooBio/gmse/blob/0e8aab2fb325421915a7c3615820812e45f42a74/R/gmse_apply_control.R#L368))), the simulated system has five population and observation time steps and is ready for the next choice of management action at $t = 5$, pending the first player input.
This is done both to set up all the required GMSE data structures using existing code, as well as to provide the player with a short time series on which to base management decisions going forward.
## Score calculation
The scores are arbitrarily defined to reflect performance in terms of the animal population ("animal score", $A_t$) on the one hand, and overall agricultural yield ("yield score", $S_t$) on the other.
Both scores can be interpreted as the mean % of the initial (i.e. at time $t=5$) animal population size and landscape yield, respectively:
$A_t = \frac{1}{N}\sum_{t=6}^Nn_t\left( \frac{1}{n_6} \right) \cdot 100$ and $S_t = \frac{1}{N}\sum_{t=6}^Ny_t$
where $t\geq5$, and $n_t$ is the true size of the animal population at time step $t$, $N$ the total number of animal counts over all time steps in the session, and $y_t$ the mean landscape cell yield over the entire landscape.
These calculations are done by the app function [`addScores()`]([`https://github.com/jejoenje/GMSEGAME/blob/master/app/dbase_functions.R#L218-L243`](https://github.com/jejoenje/GMSEGAME/blob/master/app/dbase_functions.R#L218-L243)).
Both scores are intitialised as $A_t = S_t = 100$ when the game is first started, to ensure score development over a session can be interpreted as a change from that baseline.
## Database backend
In summary, six main tables are used to store data.
Tables are linked by the unique session ID present in each table.
- `run` (Table S1a)
Holding player name, start- and end times for the session and a flag for whether or not the animal population reached extinction or not (single record per session).
- `run_par` (Table S1b)
Holding game parameters for the GMSE simulation for a session, i.e. all values listed in Table S2.
In the example application presented in the main text, the majority of the parameters in this table will be constants, with only `ownership_var` and `remove_pr` varying per session.
Note that any GMSE parameters not stored in this table or listed in Table S2 are kept as the default in GMSE, which can be found in the `GMSE` package reference manual (<https://cran.r-project.org/web/packages/GMSE/GMSE.pdf>) listed under the function `gmse()`.
- `scores` (Table S1c)
Holding the number of time steps achieved per session and the animal and yield score.
- `gdata` (Table S1d)
A record per time step for each session, recording the true and observed population state, the number of actions of each type taken, and the costs set by the manager (player), as well as the total yield in the environment.
- `yield` (Table S1e)
The yield achieved by each farmer in each time step, per session.
Records in tables `run`, `run_par` and `scores` are only updated at the start and end of each session, whereas `gdata` and `yield` are the "live" tables that are appended to at each time step during a game session.
End times are recorded for each session where the player either reaches $t=25$, manually resets the game during a session, or as the animal population reaches extinction; i.e. when this field remains blank (`NULL`), it means that a session was not terminated "normally", i.e. by the browser being closed manually or timing out due to inactivity.
\newpage
```{r echo = FALSE}
s1a_dat = read.csv("run_table_metadata.csv")
tabS1a = flextable(s1a_dat)
tabS1a = set_caption(tabS1a, caption = "Table S1(a). Description of database table `run`. Unique line per game session ID. 'Type' is the MySQL variable type and NULL indicates whether the value is allowed to be empty.")
tabS1a <- autofit(tabS1a)
tabS1a <- set_table_properties(tabS1a, layout = "autofit")
tabS1a
```
\newpage
```{r echo = FALSE}
s1b_dat = read.csv("run_par_table_metadata.csv")
tabS1b = flextable(s1b_dat)
tabS1b = set_caption(tabS1b, caption = "Table S1(b). Description of database table `run_par`. Unique line per game session ID, storing GMSE parameter values for session. 'Type' is the MySQL variable type and NULL indicates whether the value is allowed to be empty.")
tabS1b <- autofit(tabS1b)
tabS1b <- set_table_properties(tabS1b, layout = "autofit")
tabS1b
```
\newpage
```{r echo = FALSE}
s1c_dat = read.csv("scores_table_metadata.csv")
tabS1c = flextable(s1c_dat)
tabS1c = set_caption(tabS1c, caption = "Table S1(c). Description of database table `scores`. Unique line per game session ID, storing session score data. 'Type' is the MySQL variable type and NULL indicates whether the value is allowed to be empty.")
tabS1c <- autofit(tabS1c)
tabS1c <- set_table_properties(tabS1c, layout = "autofit")
tabS1c
```
\newpage
```{r echo = FALSE}
s1d_dat = read.csv("gdata_table_metadata.csv")
tabS1d = flextable(s1d_dat)
tabS1d = set_caption(tabS1d, caption = "Table S1(d). Description of database table `gdata`. Unique line per game session and time step; stores observations (of animal population), farmer actions, and player actions per time step. 'Type' is the MySQL variable type and NULL indicates whether the value is allowed to be empty.")
tabS1d <- autofit(tabS1d)
tabS1d <- set_table_properties(tabS1d, layout = "autofit")
tabS1d
```
\newpage
```{r echo = FALSE}
s1e_dat = read.csv("yield_table_metadata.csv")
tabS1e = flextable(s1e_dat)
tabS1e = set_caption(tabS1e, caption = "Table S1(e). Description of database table `yield`. Unique line per farmer within time step, within session. 'Type' is the MySQL variable type and NULL indicates whether the value is allowed to be empty.")
tabS1e <- autofit(tabS1e)
tabS1e <- set_table_properties(tabS1e, layout = "autofit")
tabS1e
```